-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathgit-toolkit.yml
More file actions
130 lines (125 loc) · 3.7 KB
/
git-toolkit.yml
File metadata and controls
130 lines (125 loc) · 3.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
---
.bump_minor_tag:
tags:
- docker
- miquido
stage: .post
image: frolvlad/alpine-bash
variables:
GITLAB_TOKEN: "<ENTER_VAR>"
before_script:
- apk add git
script:
- TXT_RED="\e[31m"
- |
if [ "$GITLAB_TOKEN" = "<ENTER_VAR>" ]; then
echo -e "${TXT_RED}Fatal: Missing GITLAB_TOKEN. \
Please setup GITLAB_TOKEN variable with token with write_repository rights"
exit 1
fi
- git tag -l | xargs git tag -d
- git fetch origin 'refs/tags/*:refs/tags/*'
- VERSION=$(git tag --sort=committerdate | { grep "[0-9]*.[0-9]*.[0-9]*$" || true; }| tail -1)
- git remote rm $CI_PIPELINE_ID &> /dev/null || true;
- |
export SERVER_URL_NO_SCHEMA=$(echo $CI_SERVER_URL | sed 's|^[^:]*://||')
git remote add $CI_PIPELINE_ID \
https://token:$GITLAB_TOKEN@$SERVER_URL_NO_SCHEMA/$CI_PROJECT_PATH.git
- |
if [[ "$VERSION" == "" ]]; then
echo "VERSION is unset"
VERSION="1.0.0"
else
echo "VERSION is set to '$VERSION'"
VERSION=$(echo "$VERSION" | awk -F. '{$NF = $NF + 1;} 1' | sed 's/ /./g')
fi
- git tag "$VERSION"
- git push $CI_PIPELINE_ID $VERSION -o ci.skip
rules:
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
.simple_changelog:
script:
- apk add git
- git log --pretty=format:%s%n%b%n------%n $CI_COMMIT_BEFORE_SHA.. > changelog.txt
tags:
- miquido
- docker
artifacts:
paths:
- changelog.txt
expire_in: 1 week
.changelog:
variables:
CHANGELOG_FILE: "CHANGELOG.md"
TAG_QUERY: ""
image: miquido/miquido-chglog:1.0.4
script:
- /chglog/latest-tag.sh $TAG_QUERY > $CHANGELOG_FILE
tags:
- miquido
- docker
rules:
- if: $CI_COMMIT_TAG
artifacts:
expire_in: "1 week"
paths:
- $CHANGELOG_FILE
.push-changelog:
stage: .post
image: frolvlad/alpine-bash
script:
- apk add git
- TXT_RED="\e[31m"
- |
if [ "$GITLAB_TOKEN" = "<ENTER_VAR>" ]; then
echo -e "${TXT_RED}Fatal: Missing GITLAB_TOKEN. \
Please setup GITLAB_TOKEN variable with token with write_repository rights"
exit 1
fi
- export SERVER_URL_NO_SCHEMA=$(echo $CI_SERVER_URL | sed 's|^[^:]*://||')
- git remote set-url origin https://token:$GITLAB_TOKEN@$SERVER_URL_NO_SCHEMA/$CI_PROJECT_PATH.git
- git config --global user.name "Changelog-bot"
- git config --global user.email "Changelog-bot@miquido.com"
- git stash
- git fetch
- git checkout $CI_DEFAULT_BRANCH
- git pull -s recursive -X ours --ff-only
- git stash apply || true
- git add CHANGELOG.md
- |
git commit -m "chore(changelog): Changelog $CI_COMMIT_TAG [skip-ci]"
git push -o ci.skip
tags:
- miquido
- docker
rules:
- if: $CI_COMMIT_TAG
.push_readme:
stage: .post
image: frolvlad/alpine-bash
script:
- apk add git
- TXT_RED="\e[31m"
- |
if [ "$GITLAB_TOKEN" = "<ENTER_VAR>" ]; then
echo -e "${TXT_RED}Fatal: Missing GITLAB_TOKEN. \
Please setup GITLAB_TOKEN variable with token with write_repository rights"
exit 1
fi
- export SERVER_URL_NO_SCHEMA=$(echo $CI_SERVER_URL | sed 's|^[^:]*://||')
- |
git remote add $CI_COMMIT_SHORT_SHA-$CI_PIPELINE_ID \
https://token:$GITLAB_TOKEN@$SERVER_URL_NO_SCHEMA/$CI_PROJECT_PATH.git
- git config --global user.name "bot"
- git config --global user.email "bot@miquido.com"
- git add .
- |
git commit -m "chore: readme" || true
git push $CI_COMMIT_SHORT_SHA-$CI_PIPELINE_ID HEAD:$CI_COMMIT_BRANCH -o ci.skip
after_script:
- git remote rm $CI_COMMIT_SHORT_SHA-$CI_PIPELINE_ID &> /dev/null || true;
tags:
- miquido
- docker
rules:
- if: $CI_COMMIT_BRANCH