1
1
# DO NOT EDIT. Generated with:
2
2
#
3
- # devctl gen workflows
3
+ # devctl@5.12.0
4
4
#
5
5
name : Create Release
6
6
on :
7
7
push :
8
8
branches :
9
9
- ' legacy'
10
+ - ' main'
10
11
- ' master'
11
12
- ' release-v*.*.x'
12
13
# "!" negates previous positive patterns so it has to be at the end.
13
14
- ' !release-v*.x.x'
14
15
jobs :
15
16
debug_info :
16
17
name : Debug info
17
- runs-on : ubuntu-18 .04
18
+ runs-on : ubuntu-20 .04
18
19
steps :
19
20
- name : Print github context JSON
20
21
run : |
23
24
EOF
24
25
gather_facts :
25
26
name : Gather facts
26
- runs-on : ubuntu-18 .04
27
+ runs-on : ubuntu-20 .04
27
28
outputs :
28
29
project_go_path : ${{ steps.get_project_go_path.outputs.path }}
29
30
ref_version : ${{ steps.ref_version.outputs.refversion }}
@@ -32,24 +33,27 @@ jobs:
32
33
- name : Get version
33
34
id : get_version
34
35
run : |
35
- title="$(echo "${{ github.event.head_commit.message }}" | head -n 1 -)"
36
+ title="$(cat <<- 'COMMIT_MESSAGE_END' | head -n 1 -
37
+ ${{ github.event.head_commit.message }}
38
+ COMMIT_MESSAGE_END
39
+ )"
36
40
# Matches strings like:
37
41
#
38
- # - "release v1.2.3"
39
- # - "release v1.2.3-r4"
40
- # - "release v1.2.3 (#56)"
41
- # - "release v1.2.3-r4 (#56)"
42
+ # - "Release v1.2.3"
43
+ # - "Release v1.2.3-r4"
44
+ # - "Release v1.2.3 (#56)"
45
+ # - "Release v1.2.3-r4 (#56)"
42
46
#
43
47
# And outputs version part (1.2.3).
44
- if echo $ title | grep -qE '^release v[0-9]+\.[0-9]+\.[0-9]+([.-][^ .-][^ ]*)?( \(#[0-9]+\))?$' ; then
45
- version=$(echo $ title | cut -d ' ' -f 2)
48
+ if echo "${ title}" | grep -iqE '^Release v[0-9]+\.[0-9]+\.[0-9]+([.-][^ .-][^ ]*)?( \(#[0-9]+\))?$' ; then
49
+ version=$(echo "${ title}" | cut -d ' ' -f 2)
46
50
fi
47
51
version="${version#v}" # Strip "v" prefix.
48
- echo "version=\"$version\""
49
- echo "::set-output name= version:: ${version}"
52
+ echo "version=\"${ version} \""
53
+ echo "version= ${version}" >> $GITHUB_OUTPUT
50
54
- name : Checkout code
51
55
if : ${{ steps.get_version.outputs.version != '' }}
52
- uses : actions/checkout@v2
56
+ uses : actions/checkout@v3
53
57
- name : Get project.go path
54
58
id : get_project_go_path
55
59
if : ${{ steps.get_version.outputs.version != '' }}
@@ -59,81 +63,47 @@ jobs:
59
63
path=''
60
64
fi
61
65
echo "path=\"$path\""
62
- echo "::set-output name= path:: ${path}"
66
+ echo "path= ${path}" >> $GITHUB_OUTPUT
63
67
- name : Check if reference version
64
68
id : ref_version
65
69
run : |
66
- title="$(echo "${{ github.event.head_commit.message }}" | head -n 1 -)"
67
- if echo $title | grep -qE '^release v[0-9]+\.[0-9]+\.[0-9]+([.-][^ .-][^ ]*)?( \(#[0-9]+\))?$' ; then
68
- version=$(echo $title | cut -d ' ' -f 2)
70
+ title="$(cat <<- 'COMMIT_MESSAGE_END' | head -n 1 -
71
+ ${{ github.event.head_commit.message }}
72
+ COMMIT_MESSAGE_END
73
+ )"
74
+ if echo "${title}" | grep -qE '^release v[0-9]+\.[0-9]+\.[0-9]+([.-][^ .-][^ ]*)?( \(#[0-9]+\))?$' ; then
75
+ version=$(echo "${title}" | cut -d ' ' -f 2)
69
76
fi
70
- version=$(echo $ title | cut -d ' ' -f 2)
77
+ version=$(echo "${ title}" | cut -d ' ' -f 2)
71
78
version="${version#v}" # Strip "v" prefix.
72
79
refversion=false
73
80
if [[ "${version}" =~ ^[0-9]+.[0-9]+.[0-9]+-[0-9]+$ ]]; then
74
81
refversion=true
75
82
fi
76
- echo "refversion =\"$refversion\""
77
- echo "::set-output name=refversion::$refversion"
78
- install_semver :
79
- name : Install semver
80
- runs-on : ubuntu-18.04
81
- env :
82
- BINARY : " semver"
83
- URL : " https://raw.githubusercontent.com/fsaintjacques/semver-tool/3.0.0/src/semver"
84
- steps :
85
- - name : Key
86
- id : key
87
- run : |
88
- cache_dir="/opt/cache"
89
- cache_key="install-${BINARY}-${URL}"
90
- echo "::set-output name=binary::${BINARY}"
91
- echo "::set-output name=cache_dir::${cache_dir}"
92
- echo "::set-output name=cache_key::${cache_key}"
93
- echo "::set-output name=url::${URL}"
94
- - name : Cache
95
- id : cache
96
- uses : actions/cache@v1
97
- with :
98
- key : " ${{ steps.key.outputs.cache_key }}"
99
- path : " ${{ steps.key.outputs.cache_dir }}"
100
- - name : Download
101
- if : ${{ steps.cache.outputs.cache-hit != 'true' }}
102
- run : |
103
- # TODO check hash
104
- binary="${{ steps.key.outputs.binary }}"
105
- cache_dir="${{ steps.key.outputs.cache_dir }}"
106
- url="${{ steps.key.outputs.url }}"
107
- mkdir $cache_dir
108
- curl -fsSLo $cache_dir/$binary $url
109
- chmod +x $cache_dir/$binary
110
- - name : Smoke test
111
- run : |
112
- ${{ steps.key.outputs.cache_dir }}/${{ steps.key.outputs.binary }} --version
113
- - name : Upload artifact
114
- uses : actions/upload-artifact@v1
115
- with :
116
- name : " ${{ steps.key.outputs.binary }}"
117
- path : " ${{ steps.key.outputs.cache_dir }}/${{ steps.key.outputs.binary }}"
83
+ echo "refversion =\"${refversion}\""
84
+ echo "refversion=${refversion}" >> $GITHUB_OUTPUT
118
85
update_project_go :
119
86
name : Update project.go
120
- runs-on : ubuntu-18 .04
87
+ runs-on : ubuntu-20 .04
121
88
if : ${{ needs.gather_facts.outputs.version != '' && needs.gather_facts.outputs.project_go_path != '' && needs.gather_facts.outputs.ref_version != 'true' }}
122
89
needs :
123
90
- gather_facts
124
- - install_semver
125
91
steps :
126
- - name : Download semver artifact to /opt/bin
127
- uses : actions/download-artifact@v2
92
+ - name : Install architect
93
+ uses :
giantswarm/[email protected]
128
94
with :
129
- name : semver
130
- path : /opt/bin
131
- - name : Prepare /opt/bin
132
- run : |
133
- chmod +x /opt/bin/*
134
- echo "::add-path::/opt/bin"
95
+ binary : " architect"
96
+ version : " 6.1.0"
97
+ - name : Install semver
98
+ uses :
giantswarm/[email protected]
99
+ with :
100
+ binary : " semver"
101
+ version : " 3.2.0"
102
+ download_url : " https://github.com/fsaintjacques/${binary}-tool/archive/${version}.tar.gz"
103
+ tarball_binary_path : " */src/${binary}"
104
+ smoke_test : " ${binary} --version"
135
105
- name : Checkout code
136
- uses : actions/checkout@v2
106
+ uses : actions/checkout@v3
137
107
- name : Update project.go
138
108
id : update_project_go
139
109
env :
@@ -144,17 +114,19 @@ jobs:
144
114
version="${{ needs.gather_facts.outputs.version }}"
145
115
new_version="$(semver bump patch $version)-dev"
146
116
echo "version=\"$version\" new_version=\"$new_version\""
147
- echo "::set-output name= new_version:: ${new_version}"
117
+ echo "new_version= ${new_version}" >> $GITHUB_OUTPUT
148
118
sed -Ei "s/(version[[:space:]]*=[[:space:]]*)\"${version}\"/\1\"${new_version}\"/" $file
149
119
if git diff --exit-code $file ; then
150
120
echo "error: no changes in \"$file\"" >&2
151
121
exit 1
152
122
fi
123
+ - name : Set up git identity
124
+ run : |
125
+ git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
126
+ git config --local user.name "github-actions[bot]"
153
127
- name : Commit changes
154
128
run : |
155
129
file="${{ needs.gather_facts.outputs.project_go_path }}"
156
- git config --local user.email "[email protected] "
157
- git config --local user.name "GitHub Action"
158
130
git add $file
159
131
git commit -m "Bump version to ${{ steps.update_project_go.outputs.new_version }}"
160
132
- name : Push changes
@@ -174,15 +146,15 @@ jobs:
174
146
hub pull-request -f -m "${{ env.title }}" -b ${{ env.base }} -h ${{ env.branch }} -r ${{ github.actor }}
175
147
create_release :
176
148
name : Create release
177
- runs-on : ubuntu-18 .04
149
+ runs-on : ubuntu-20 .04
178
150
needs :
179
151
- gather_facts
180
152
if : ${{ needs.gather_facts.outputs.version }}
181
153
outputs :
182
154
upload_url : ${{ steps.create_gh_release.outputs.upload_url }}
183
155
steps :
184
156
- name : Checkout code
185
- uses : actions/checkout@v2
157
+ uses : actions/checkout@v3
186
158
with :
187
159
ref : ${{ github.sha }}
188
160
- name : Ensure correct version in project.go
@@ -191,10 +163,19 @@ jobs:
191
163
file="${{ needs.gather_facts.outputs.project_go_path }}"
192
164
version="${{ needs.gather_facts.outputs.version }}"
193
165
grep -qE "version[[:space:]]*=[[:space:]]*\"$version\"" $file
166
+ - name : Get Changelog Entry
167
+ id : changelog_reader
168
+ uses : mindsers/changelog-reader-action@v2
169
+ with :
170
+ version : ${{ needs.gather_facts.outputs.version }}
171
+ path : ./CHANGELOG.md
172
+ - name : Set up git identity
173
+ run : |
174
+ git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
175
+ git config --local user.name "github-actions[bot]"
194
176
- name : Create tag
195
177
run : |
196
178
version="${{ needs.gather_facts.outputs.version }}"
197
- git config --local user.name "github-actions"
198
179
git tag "v$version" ${{ github.sha }}
199
180
- name : Push tag
200
181
env :
@@ -207,36 +188,42 @@ jobs:
207
188
env :
208
189
GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
209
190
with :
191
+ body : ${{ steps.changelog_reader.outputs.changes }}
210
192
tag_name : " v${{ needs.gather_facts.outputs.version }}"
211
193
release_name : " v${{ needs.gather_facts.outputs.version }}"
194
+
212
195
create-release-branch :
213
196
name : Create release branch
214
- runs-on : ubuntu-18 .04
197
+ runs-on : ubuntu-20 .04
215
198
needs :
216
199
- gather_facts
217
- - install_semver
218
200
if : ${{ needs.gather_facts.outputs.version }}
219
201
steps :
220
- - name : Download semver artifact to /opt/bin
221
- uses : actions/download-artifact@v2
202
+ - name : Install semver
203
+ uses :
giantswarm/[email protected]
222
204
with :
223
- name : semver
224
- path : /opt/bin
225
- - name : Prepare /opt/bin
226
- run : |
227
- chmod +x /opt/bin/*
228
- echo "::add-path::/opt/bin"
229
- - uses : actions/checkout@v2
230
- name : Check out the repository
205
+ binary : " semver"
206
+ version : " 3.0.0"
207
+ download_url : " https://github.com/fsaintjacques/${binary}-tool/archive/${version}.tar.gz"
208
+ tarball_binary_path : " */src/${binary}"
209
+ smoke_test : " ${binary} --version"
210
+ - name : Check out the repository
211
+ uses : actions/checkout@v3
231
212
with :
232
213
fetch-depth : 0 # Clone the whole history, not just the most recent commit.
233
214
- name : Fetch all tags and branches
234
215
run : " git fetch --all"
235
216
- name : Create long-lived release branch
236
217
run : |
237
218
current_version="${{ needs.gather_facts.outputs.version }}"
238
- parent_version="$(git describe --tags --abbrev=0 HEAD^)"
219
+ parent_version="$(git describe --tags --abbrev=0 HEAD^ || true )"
239
220
parent_version="${parent_version#v}" # Strip "v" prefix.
221
+
222
+ if [[ -z "$parent_version" ]] ; then
223
+ echo "Unable to find a parent tag version. No branch to create."
224
+ exit 0
225
+ fi
226
+
240
227
echo "current_version=$current_version parent_version=$parent_version"
241
228
242
229
current_major=$(semver get major $current_version)
0 commit comments