-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgit-toolkit.yml
125 lines (120 loc) · 3.39 KB
/
git-toolkit.yml
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
---
.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;
- |
git remote add $CI_PIPELINE_ID \
https://token:[email protected]/$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
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
- git remote set-url origin https://token:[email protected]/$CI_PROJECT_PATH.git
- git config --global user.name "Changelog-bot"
- git config --global user.email "[email protected]"
- 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
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
- git remote add $CI_COMMIT_SHORT_SHA-$CI_PIPELINE_ID https://token:[email protected]/$CI_PROJECT_PATH.git
- git config --global user.name "bot"
- git config --global user.email "[email protected]"
- git add .
- |
git commit -m "chore: readme" || true
git push $CI_COMMIT_SHORT_SHA-$CI_PIPELINE_ID HEAD:$CI_COMMIT_BRANCH
after_script:
- git remote rm $CI_COMMIT_SHORT_SHA-$CI_PIPELINE_ID &> /dev/null || true;
tags:
- miquido
- docker
rules:
- if: $CI_COMMIT_BRANCH