Skip to content

Commit 90df89c

Browse files
ci(release) Release workflow
1 parent a9a06ab commit 90df89c

File tree

6 files changed

+399
-68
lines changed

6 files changed

+399
-68
lines changed

.github/deploy-settings.xml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,16 @@
66
<pluginGroup>com.sonatype.maven.plugins</pluginGroup>
77
<pluginGroup>org.sonatype.plugins</pluginGroup>
88
</pluginGroups>
9+
<properties>
10+
<gpg.keyname>${env.RELEASE_GPG_KEYNAME}</gpg.keyname>
11+
<gpg.passphrase>${env.RELEASE_GPG_PASSPHRASE}</gpg.passphrase>
12+
<!--gpg.defaultKeyring>false</gpg.defaultKeyring-->
13+
<gpg.useagent>true</gpg.useagent>
14+
<gpg.lockMode>never</gpg.lockMode>
15+
<!--gpg.homedir>/home/aurelien/.gnupg</gpg.homedir>
16+
<gpg.publicKeyring>/home/aurelien/.gnupg/pubring.gpg</gpg.publicKeyring>
17+
<gpg.secretKeyring>/home/aurelien/.gnupg/secring.gpg</gpg.secretKeyring-->
18+
</properties>
919
<servers>
1020
<server>
1121
<id>ossrh</id>

.github/workflows/build.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
name: Build
22

33
on:
4-
push:
5-
branches-ignore:
6-
- 'gh-*'
7-
- 'docs/**'
4+
# push:
5+
# branches-ignore:
6+
# - 'gh-*'
7+
# - 'docs/**'
8+
workflow_dispatch:
89

910
jobs:
1011
build:
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: Release
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
release-version:
7+
description: 'Release version to remove e.g 3.0.0. It will delete tag v3.0.0 and branch v3.0.x'
8+
required: true
9+
revert-to:
10+
description: 'The commit to revert to on the branch that originated the release'
11+
required: true
12+
13+
jobs:
14+
rollback:
15+
runs-on: ubuntu-18.04
16+
steps:
17+
- uses: actions/checkout@v2
18+
with:
19+
fetch-depth: 0
20+
- uses: actions/setup-java@v1
21+
with:
22+
java-version: 8
23+
- name: Cache Maven packages
24+
uses: actions/cache@v2
25+
with:
26+
path: |
27+
~/.m2/repository
28+
!~/.m2/repository/fr/sii/
29+
key: ${{ runner.os }}-m2-${{ secrets.CACHE_VERSION }}-${{ hashFiles('**/pom.xml') }}
30+
restore-keys: ${{ runner.os }}-m2-${{ secrets.CACHE_VERSION }}
31+
- name: Prepare git
32+
run: |
33+
git config user.email [email protected]
34+
git config user.name github-actions
35+
- name: "Remove tag"
36+
continue-on-error: true
37+
run: |
38+
git push origin --delete v${{ github.event.inputs.release-version }}
39+
- name: "Remove fix branch"
40+
continue-on-error: true
41+
run: |
42+
RELEASE_VERSION=${{ github.event.inputs.release-version }}
43+
FIX_BRANCH="v${RELEASE_VERSION%.*}.x"
44+
git push origin --delete "$FIX_BRANCH"
45+
- name: "Remove release commits"
46+
continue-on-error: true
47+
run: |
48+
git pull
49+
LATEST_COMMIT="$(git log -1 --format=%H)"
50+
echo "LATEST_COMMIT=$LATEST_COMMIT"
51+
echo "github.event.inputs.revert-to=${{ github.event.inputs.revert-to }}"
52+
if [ "$LATEST_COMMIT" != "${{ github.event.inputs.revert-to }}" ]; then
53+
ROLLBACK_BACKUP_BRANCH="rollback/backup/$LATEST-COMMIT"
54+
git branch "$ROLLBACK_BACKUP_BRANCH"
55+
git push origin "$ROLLBACK_BACKUP_BRANCH"
56+
git reset --hard ${{ github.event.inputs.revert-to }}
57+
git push --force
58+
fi
59+
# TODO: remove artifact from Maven repository: possible ?
60+
# - name: "Remove artifact"
61+
# if: always()
62+
# run:
63+

.github/workflows/release.yml

Lines changed: 259 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,40 @@
11
name: Release
22

3+
# Process
4+
# -------
5+
#
6+
# 1) mvn release:prepare
7+
# => change version for release in pom.xml files to vX.Y.0
8+
# => update readme
9+
# => run unit+integration tests
10+
# => commit
11+
# => tag
12+
# => change version for future developments in pom.xml files to vU.V.0-SNAPSHOT
13+
#
14+
# 2) Trigger a full build on tagged version and wait for result
15+
# => build from tag
16+
# => run unit+integration tests
17+
# => run classpath-tests
18+
# => generate javadoc
19+
#
20+
# 3) mvn release:perform to finish the release
21+
# => deploy on Sonatype
22+
#
23+
# 4) Trigger a site generation on tagged version
24+
#
25+
# 5) Create branch for fixes
26+
# => change versions to vX.Y.1-SNAPSHOT
27+
#
28+
#
29+
# Rollback
30+
# --------
31+
#
32+
# 1) mvn release:rollback
33+
# 2) delete tag
34+
# 3) restore previous commit (before version changes)
35+
# 3) mvn release:clean
36+
# 4) remove from Sonatype if deployed
37+
338
on:
439
workflow_dispatch:
540
inputs:
@@ -11,9 +46,231 @@ on:
1146
description: 'Next dev version'
1247
required: true
1348
default: '3.1.0-SNAPSHOT'
49+
fix-version:
50+
description: 'Fixes version'
51+
required: true
52+
default: '3.0.1-SNAPSHOT'
1453

1554
jobs:
16-
mutation-tests:
55+
# FIXME: maven-release-plugin can't be used due to issue: https://issues.apache.org/jira/browse/MRELEASE-920
56+
# release:
57+
# runs-on: ubuntu-18.04
58+
# steps:
59+
# - uses: actions/checkout@v2
60+
# - uses: actions/setup-java@v1
61+
# with:
62+
# java-version: 8
63+
# - name: Cache Maven packages
64+
# uses: actions/cache@v2
65+
# with:
66+
# path: |
67+
# ~/.m2/repository
68+
# !~/.m2/repository/fr/sii/
69+
# key: ${{ runner.os }}-m2-${{ secrets.CACHE_VERSION }}-${{ hashFiles('**/pom.xml') }}
70+
# restore-keys: ${{ runner.os }}-m2-${{ secrets.CACHE_VERSION }}
71+
# - name: "Release"
72+
# run:
73+
# ./mvnw release:prepare
74+
# -DreleaseVersion=${{ github.event.inputs.release-version }}
75+
# -DdevelopmentVersion=${{ github.event.inputs.next-dev-version }}
76+
# -B
77+
release:
78+
runs-on: ubuntu-18.04
79+
steps:
80+
- uses: actions/checkout@v2
81+
- uses: actions/setup-java@v1
82+
with:
83+
java-version: 8
84+
- name: Cache Maven packages
85+
uses: actions/cache@v2
86+
with:
87+
path: |
88+
~/.m2/repository
89+
!~/.m2/repository/fr/sii/
90+
key: ${{ runner.os }}-m2-${{ secrets.CACHE_VERSION }}-${{ hashFiles('**/pom.xml') }}
91+
restore-keys: ${{ runner.os }}-m2-${{ secrets.CACHE_VERSION }}
92+
- name: Prepare git
93+
run: |
94+
git config user.email [email protected]
95+
git config user.name github-actions
96+
- name: "Set release version (${{ github.event.inputs.release-version }})"
97+
run: |
98+
./mvnw versions:set -DnewVersion=${{ github.event.inputs.release-version }} -DprocessAllModules
99+
./mvnw com.google.code.maven-replacer-plugin:replacer:replace -N
100+
./mvnw versions:commit
101+
- name: "Generate README.adoc"
102+
run:
103+
./mvnw initialize '-Dreadme.skip=false'
104+
- name: "Build to ensure that it works fine"
105+
run:
106+
./mvnw clean install '-Dmaven.test.redirectTestOutputToFile=true'
107+
- name: "Commit release version"
108+
run: |
109+
git add .
110+
git commit -m "release(${{ github.event.inputs.release-version }}) Prepare for release"
111+
git push
112+
113+
test-release:
114+
needs: [release]
115+
runs-on: ubuntu-18.04
116+
steps:
117+
- uses: aurelien-baudet/workflow-dispatch@master
118+
with:
119+
token: ${{ secrets.TRIGGER_WORKFLOW_TOKEN }}
120+
workflow: build.yml
121+
wait-for-completion-interval: 10m
122+
wait-for-completion-timeout: 4h
123+
# ref: v${{ github.event.inputs.release-version }}
124+
125+
deploy-release:
126+
needs: [test-release]
127+
runs-on: ubuntu-18.04
128+
steps:
129+
- uses: actions/checkout@v2
130+
with:
131+
fetch-depth: 0
132+
- uses: actions/setup-java@v1
133+
with:
134+
java-version: 8
135+
- name: Cache Maven packages
136+
uses: actions/cache@v2
137+
with:
138+
path: |
139+
~/.m2/repository
140+
!~/.m2/repository/fr/sii/
141+
key: ${{ runner.os }}-m2-${{ secrets.CACHE_VERSION }}-${{ hashFiles('**/pom.xml') }}
142+
restore-keys: ${{ runner.os }}-m2-${{ secrets.CACHE_VERSION }}
143+
- name: Prepare git
144+
run: |
145+
git config user.email [email protected]
146+
git config user.name github-actions
147+
- run: git pull
148+
- name: "Tag release version"
149+
run: |
150+
git tag -a "v${{ github.event.inputs.release-version }}" -m "release(${{ github.event.inputs.release-version }}) Release"
151+
git push origin "v${{ github.event.inputs.release-version }}"
152+
- name: "Import GPG key"
153+
uses: crazy-max/ghaction-import-gpg@v3
154+
with:
155+
gpg-private-key: ${{ secrets.RELEASE_GPG_PRIVATE_KEY }}
156+
passphrase: ${{ secrets.RELEASE_GPG_PASSPHRASE }}
157+
# - name: "Deploy release"
158+
# run:
159+
# ./mvnw -Prelease deploy
160+
# --settings .github/deploy-settings.xml
161+
# '-DskipTests=true'
162+
# -B
163+
164+
set-next-version:
165+
needs: [deploy-release]
166+
runs-on: ubuntu-18.04
167+
steps:
168+
- uses: actions/checkout@v2
169+
with:
170+
fetch-depth: 0
171+
- uses: actions/setup-java@v1
172+
with:
173+
java-version: 8
174+
- name: Cache Maven packages
175+
uses: actions/cache@v2
176+
with:
177+
path: |
178+
~/.m2/repository
179+
!~/.m2/repository/fr/sii/
180+
key: ${{ runner.os }}-m2-${{ secrets.CACHE_VERSION }}-${{ hashFiles('**/pom.xml') }}
181+
restore-keys: ${{ runner.os }}-m2-${{ secrets.CACHE_VERSION }}
182+
- name: Prepare git
183+
run: |
184+
git config user.email [email protected]
185+
git config user.name github-actions
186+
- run: git pull
187+
- name: "Set next development version on master (${{ github.event.inputs.next-dev-version }})"
188+
run: |
189+
./mvnw versions:set -DnewVersion=${{ github.event.inputs.next-dev-version }} -DprocessAllModules
190+
./mvnw com.google.code.maven-replacer-plugin:replacer:replace -N
191+
./mvnw versions:commit
192+
- name: "Generate README.adoc"
193+
run:
194+
./mvnw initialize '-Dreadme.skip=false'
195+
- name: "Commit next development iteration"
196+
run: |
197+
git add .
198+
git commit -m "release(${{ github.event.inputs.release-version }}) Prepare for next development iteration"
199+
git push
200+
201+
update-site:
202+
needs: [set-next-version]
203+
runs-on: ubuntu-18.04
204+
steps:
205+
- uses: aurelien-baudet/workflow-dispatch@master
206+
with:
207+
token: ${{ secrets.TRIGGER_WORKFLOW_TOKEN }}
208+
workflow: update-site.yml
209+
ref: v${{ github.event.inputs.release-version }}
210+
211+
create-or-update-fix-branch:
212+
needs: [update-site]
213+
runs-on: ubuntu-18.04
214+
steps:
215+
- uses: actions/checkout@v2
216+
with:
217+
fetch-depth: 0
218+
- uses: actions/setup-java@v1
219+
with:
220+
java-version: 8
221+
- name: Cache Maven packages
222+
uses: actions/cache@v2
223+
with:
224+
path: |
225+
~/.m2/repository
226+
!~/.m2/repository/fr/sii/
227+
key: ${{ runner.os }}-m2-${{ secrets.CACHE_VERSION }}-${{ hashFiles('**/pom.xml') }}
228+
restore-keys: ${{ runner.os }}-m2-${{ secrets.CACHE_VERSION }}
229+
- name: Prepare git
230+
run: |
231+
git config user.email [email protected]
232+
git config user.name github-actions
233+
- name: "Get fix branch"
234+
run:
235+
RELEASE_VERSION=${{ github.event.inputs.release-version }}
236+
FIX_BRANCH="v${RELEASE_VERSION%.*}.x"
237+
echo "FIX_BRANCH=$FIX_BRANCH" >> $GITHUB_ENV
238+
- name: "Set version"
239+
run: |
240+
echo "FIX_BRANCH=$FIX_BRANCH"
241+
EXISTS=$(git ls-remote --heads origin ${FIX_BRANCH})
242+
if [ -z "$EXISTS" ]; then
243+
git checkout "v${{ github.event.inputs.release-version }}"
244+
git checkout -b "$FIX_BRANCH"
245+
else
246+
git checkout "$FIX_BRANCH"
247+
fi
248+
./mvnw versions:set -DnewVersion=${{ github.event.inputs.fix-version }} -DprocessAllModules
249+
./mvnw com.google.code.maven-replacer-plugin:replacer:replace -N
250+
./mvnw versions:commit
251+
- name: "Generate README.adoc"
252+
run:
253+
./mvnw initialize '-Dreadme.skip=false'
254+
- name: "Create fix branch or update it"
255+
run:
256+
git add .
257+
git commit -m "chore(bump) Change version number for next fix version"
258+
git push
259+
260+
rollback:
261+
needs: [release, test-release, deploy-release, set-next-version, update-site, create-or-update-fix-branch]
262+
if: always()
17263
runs-on: ubuntu-18.04
18264
steps:
19-
- run: echo "foo"
265+
- uses: aurelien-baudet/workflow-dispatch@master
266+
with:
267+
token: ${{ secrets.TRIGGER_WORKFLOW_TOKEN }}
268+
inputs: |
269+
{
270+
"release-version": "${{ github.event.inputs.release-version }}",
271+
"revert-to": "${{ github.sha }}"
272+
}
273+
workflow: release-rollback.yml
274+
wait-for-completion-interval: 1m
275+
wait-for-completion-timeout: 1h
276+

0 commit comments

Comments
 (0)