-
Notifications
You must be signed in to change notification settings - Fork 3
383 lines (322 loc) · 14.6 KB
/
release.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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
# This workflow will build a Java project with Maven
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven
name: Release new version
on:
workflow_dispatch:
inputs:
releaseversion:
description: 'Release version'
# required: true
# default: '2.4.0'
# snapshotversion:
# description: 'Next snapshot version'
# required: true
# default: '2.4.1'
env:
JAVA_VERSION: 11.0.3
SERVER_ID: ossrh
PYTHON_VERSION: '3.9.7'
MAVEN_VERSION: 3.8.1
WINDOWS_VERSION: 'windows-2019'
UBUNTU_VERSION: 'ubuntu-22.05'
MACOS_VERSION: 'macos-latest'
jobs:
version_change:
name: Create version and tag
runs-on: ${{ env.UBUNTU_VERSION }}
outputs:
build_tag: ${{ steps.tagging.outputs.build_tag }} # map step output to job output
build_tag_created: ${{ steps.tagging.outputs.build_tag_created }}
build_version: ${{ steps.tagging.outputs.build_version }} # map step output to job output
build_branch: ${{ steps.tagging.outputs.build_branch }}
previous_release_tag: ${{ steps.tagging.outputs.previous_release_tag }}
steps:
- name: Set up Java
uses: actions/setup-java@v1
with:
java-version: ${{ env.JAVA_VERSION }}
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: setup git config
run: |
# setup the username and email. I tend to use 'GitHub Actions Bot' with no email by default
git config user.name "GitHub Actions Bot"
git config user.email "<>"
- name: Maven download
run: mvn validate dependency:resolve-plugins -B --quiet
- name: Set release version
id: tagging
run: |
# make sure we are at the head of development
NEW_RELEASE_VERSION=${{ github.event.inputs.releaseversion }}
echo "Input version is $NEW_RELEASE_VERSION"
# remove all but the release version
mvn -B --quiet org.codehaus.mojo:versions-maven-plugin:2.8.1:set-property -Dproperty=changelist "-DnewVersion="
mvn -B --quiet org.codehaus.mojo:versions-maven-plugin:2.8.1:set-property -Dproperty=sha1 "-DnewVersion="
# detect if a override version is given
if [ "$NEW_RELEASE_VERSION" == "" ]; then
echo "Input version not set. Use current version"
NEW_RELEASE_VERSION=$(mvn -q -Dexec.executable=echo -Dexec.args='${project.version}' --non-recursive exec:exec)
fi
# set the version to be released
NEW_RELEASE_TAG="Release/${NEW_RELEASE_VERSION}"
NEW_RELEASE_BRANCH="prepare-release/${NEW_RELEASE_VERSION}"
echo "::set-output name=build_tag::${NEW_RELEASE_TAG}"
echo "::set-output name=build_version::${NEW_RELEASE_VERSION}"
echo "::set-output name=build_branch::${NEW_RELEASE_BRANCH}"
PREVIOUS_RELEASE_TAG=$(git tag | grep Release | sort -V | tail -1)
echo "::set-output name=previous_release_tag::${PREVIOUS_RELEASE_TAG}"
echo "release version is $NEW_RELEASE_VERSION"
echo "Tag release version is now $NEW_RELEASE_TAG"
mvn -B --quiet org.codehaus.mojo:versions-maven-plugin:2.8.1:set-property -Dproperty=revision "-DnewVersion=${NEW_RELEASE_VERSION}"
git checkout -b $NEW_RELEASE_BRANCH
git push -f --set-upstream origin $NEW_RELEASE_BRANCH
git add pom.xml
git commit -m "New release version ${NEW_RELEASE_VERSION}"
git tag -a "${NEW_RELEASE_TAG}" -m "Release version ${NEW_RELEASE_VERSION}"
git push origin "${NEW_RELEASE_TAG}"
echo "::set-output name=build_tag_created::YES"
# prepare next snapshot for development
mvn -B --quiet ci-friendly-flatten:version -Dprefix.regex="Release/*"
SNAPSHOTVERSION=$(cat revision.txt)
mvn -B --quiet org.codehaus.mojo:versions-maven-plugin:2.8.1:set-property -Dproperty=revision "-DnewVersion=$SNAPSHOTVERSION"
mvn -B --quiet org.codehaus.mojo:versions-maven-plugin:2.8.1:set-property -Dproperty=changelist "-DnewVersion=-SNAPSHOT"
mvn -B --quiet org.codehaus.mojo:versions-maven-plugin:2.8.1:set-property -Dproperty=sha1 "-DnewVersion="
git add pom.xml
git commit -m "Next snapshot version $SNAPSHOTVERSION"
git push
build:
name: Java and Native Compilation
runs-on: ${{ matrix.os }}
needs: version_change
strategy:
fail-fast: false
matrix:
os: [ ${{ env.UBUNTU_VERSION }}, windows-2019, macos-latest ] # ubuntu-latest, , macos-latest
platform: [ x64 ] #x32, x64 ]
exclude:
- os: macos-latest
platform: x32
steps:
- name: Set up Java
uses: actions/[email protected]
with:
java-version: ${{ env.JAVA_VERSION }}
- name: Set up maven
uses: stCarolas/[email protected]
with:
maven-version: ${{ ENV.MAVEN_VERSION }}
- name: Setup Python
uses: actions/setup-python@v2
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Install Python Pipenv
run: |
python -m pip install --upgrade pip
python -m pip install pipenv
- name: Put MSYS2_MinGW64 on PATH for windows
if: ${{matrix.os == env.WINDOWS_VERSION }}
# there is not yet an environment variable for this path from msys2/setup-msys2
run: echo "C:\msys64/mingw64/bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
- uses: actions/checkout@v2
- name: Cache local Maven repository
uses: actions/cache@v3
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Maven Build
run: mvn -B package --file pom.xml -DskipTests -fae
- name: Maven Test
# if: matrix.os == env.WINDOWS_VERSION
# shell: msys2 {0}
run: mvn -Pinclude-fullSpecCppTest test
- name: Install Python Dependencies
run: |
cd external_tester
pipenv install
- name: CLI Test
timeout-minutes: 5
run: |
cd external_tester
pipenv run python maestro_cli_test.py --includeSlowTests
- name: Web API Test
timeout-minutes: 2
run: |
cd external_tester
pipenv run python webapi_test.py
- name: Legacy CLI Test
timeout-minutes: 2
run: |
cd external_tester
pipenv run python cli_legacy_test.py
final:
name: Build and Deploy Combined Release
runs-on: ${{ env.UBUNTU_VERSION }}
needs: [ version_change , build ]
steps:
- uses: actions/checkout@v2
with:
submodules: 'true'
ref: ${{ needs.version_change.outputs.build_tag }}
- id: install-secret-key
name: Install gpg secret key
run: |
cat <(echo -e "${{ secrets.OSSRH_GPG_SECRET_KEY }}") | gpg --batch --import
gpg --list-secret-keys --keyid-format LONG
- name: Environment variables
run: echo ${{ env.SERVER_ID }}
- name: Deploy server
uses: actions/setup-java@v1
with:
java-version: ${{ env.JAVA_VERSION }}
server-id: ${{ env.SERVER_ID }}
server-username: MAVEN_USERNAME
server-password: MAVEN_PASSWORD
gpg-passphrase: MAVEN_GPG_PASSPHRASE
- name: Set up maven
uses: stCarolas/[email protected]
with:
maven-version: ${{ ENV.MAVEN_VERSION }}
- name: Cache local Maven repository
uses: actions/cache@v3
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Maven download
run: mvn validate dependency:resolve-plugins -B --quiet
- name: Maven Build Final
run: mvn -B package -Psonatype -Prelease --file pom.xml -Dmaven.test.skip=true
- name: Maven Deploy RELEASE
# If autorelease is false then it must be released from here: https://oss.sonatype.org/#stagingRepositories
run: mvn -B deploy -Dchangelist= -Dsha1= -Dmaven.test.skip=true -DskipITs -fae -Prelease -Psonatype -DautoReleaseAfterClose=true
env:
MAVEN_USERNAME: ${{ secrets.OSS_SONATYPE_USERNAME }}
MAVEN_PASSWORD: ${{ secrets.OSS_SONATYPE_PASSWORD }}
MAVEN_GPG_PASSPHRASE: ${{ secrets.OSSRH_GPG_SECRET_KEY_PASSWORD }}
- name: Create changelog config
run: echo '{"max_back_track_time_days":1095}' > configuration.json
- name: Generate changelog
id: changelog
uses: mikepenz/[email protected]
with:
configurationJson: |
{
"template": "#{{CHANGELOG}}\n\n<details>\n<summary>Uncategorized</summary>\n\n#{{UNCATEGORIZED}}\n</details>",
"categories": [
{
"title": "## 🚀 Features",
"labels": ["feature"]
},
{
"title": "## 🐛 Fixes",
"labels": ["fix"]
},
{
"title": "## 🧪 Tests",
"labels": ["test"]
},
{
"title": "## 💬 Other",
"labels": ["other"]
},
{
"title": "## 📦 Dependencies",
"labels": ["dependencies"]
}
]
}
toTag: ${{ needs.version_change.outputs.build_tag }}
fromTag: ${{ needs.version_change.outputs.previous_release_tag }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: md5sum
id: release_asserts_md5sum
run: |
echo "::set-output name=maestro_md5::$(md5sum maestro/target/maestro-${{ needs.version_change.outputs.build_version }}-jar-with-dependencies.jar)"
echo "::set-output name=maestro_web_md5::$(md5sum maestro-webapi/target/maestro-webapi-${{ needs.version_change.outputs.build_version }}-bundle.jar)"
- name: Create GitHub Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ needs.version_change.outputs.build_tag }}
release_name: ${{ needs.version_change.outputs.build_tag }}
body: |
Grab the new version from Maven central https://search.maven.org/artifact/org.into-cps.maestro/maestro/${{ needs.version_change.outputs.build_version }}/jar
and https://search.maven.org/artifact/org.into-cps.maestro/maestro-webapi/${{ needs.version_change.outputs.build_version }}/jar:
```
<dependency>
<groupId>org.into-cps.maestro</groupId>
<artifactId>maestro</artifactId>
<version>${{ needs.version_change.outputs.build_version }}</version>
</dependency>
<dependency>
<groupId>org.into-cps.maestro</groupId>
<artifactId>maestro-webapi</artifactId>
<version>${{ needs.version_change.outputs.build_version }}</version>
</dependency>
```
${{ steps.release_asserts_md5sum.outputs.maestro_md5 }}
${{ steps.release_asserts_md5sum.outputs.maestro_web_md5 }}
### Things that changed in this release
${{ steps.changelog.outputs.changelog }}
draft: false
prerelease: false
- name: Upload Release Asset - maestro
id: upload-release-asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
asset_path: maestro/target/maestro-${{ needs.version_change.outputs.build_version }}-jar-with-dependencies.jar
asset_name: maestro-${{ needs.version_change.outputs.build_version }}-jar-with-dependencies.jar
asset_content_type: application/zip
- name: Upload Release Asset - maestro-webapi-bundle
id: upload-release-asset-web
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
asset_path: maestro-webapi/target/maestro-webapi-${{ needs.version_change.outputs.build_version }}-bundle.jar
asset_name: maestro-webapi-${{ needs.version_change.outputs.build_version }}-bundle.jar
asset_content_type: application/zip
rollback:
name: Rollback on error
runs-on: ${{ env.UBUNTU_VERSION }}
needs: [ version_change , build, final ]
if: always() && (needs.version_change.result == 'failure' || needs.build.result == 'failure' || needs.final.result == 'failure')
steps:
- uses: actions/checkout@v2
- name: Rolling back tag
continue-on-error: true
if: needs.version_change.outputs.build_tag_created == 'YES'
# we don't want to accidentally delete an existing tag from an existing release
run: git push --delete origin ${{ needs.version_change.outputs.build_tag }}
- name: Rolling back branch
continue-on-error: true
run: git push origin --delete ${{ needs.version_change.outputs.build_branch }}
cleanup:
name: Update development and master with new release
runs-on: ${{ env.UBUNTU_VERSION }}
needs: [ final,version_change ]
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Merging release
run: |
git fetch origin ${{ needs.version_change.outputs.build_branch }}
git checkout development
git merge origin/${{ needs.version_change.outputs.build_branch }}
git push
git checkout master
git reset --hard ${{ needs.version_change.outputs.build_tag }}
git push -f origin master