Skip to content

Commit 520c76b

Browse files
chore: integrate automated release in github workflows (#2)
Signed-off-by: Joris Mancini <[email protected]>
1 parent ba26e85 commit 520c76b

File tree

2 files changed

+101
-13
lines changed

2 files changed

+101
-13
lines changed

.github/workflows/maven.yml

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ on:
44
push:
55
branches:
66
- 'main'
7-
tags:
8-
- 'v[0-9]*'
97
pull_request:
108

119
jobs:
@@ -23,7 +21,7 @@ jobs:
2321
uses: actions/checkout@v1
2422

2523
- name: Build with Maven
26-
run: mvn --batch-mode -P jacoco verify
24+
run: mvn --batch-mode -Pjacoco verify
2725

2826
- name: Run SonarCloud analysis
2927
run: >
@@ -43,16 +41,7 @@ jobs:
4341
-Djib.to.image=docker.io/gridsuite/spreadsheet-config-server
4442
-Djib.to.auth.username=gridsuiteci
4543
-Djib.to.auth.password=${{ secrets.DOCKERHUB_TOKEN }}
46-
47-
- name: Build Docker image - Tag
48-
if: startsWith(github.ref, 'refs/tags/')
49-
run: >
50-
mvn --batch-mode deploy -DskipTests -Dmaven.install.skip -Dmaven.deploy.skip -Dpowsybl.docker.deploy
51-
-Djib.httpTimeout=60000
52-
-Djib.to.image=docker.io/gridsuite/spreadsheet-config-server:${GITHUB_REF_NAME#v}
53-
-Djib.to.auth.username=gridsuiteci
54-
-Djib.to.auth.password=${{ secrets.DOCKERHUB_TOKEN }}
55-
44+
5645
- name: Broadcast update event
5746
if: github.ref == 'refs/heads/main'
5847
uses: gridsuite/broadcast-event@main

.github/workflows/release.yml

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v[0-9]*'
7+
8+
jobs:
9+
build:
10+
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Set up JDK 17
15+
uses: actions/setup-java@v1
16+
with:
17+
java-version: 17
18+
19+
- name: Checkout sources
20+
uses: actions/checkout@v1
21+
22+
- name: Remove original tag
23+
run: |
24+
git tag -d ${{ github.ref_name }}
25+
git push origin :refs/tags/${{ github.ref_name }}
26+
27+
- name: Extract tag versions
28+
run: |
29+
regex="v([0-9]+).([0-9]+).([0-9]+)"
30+
if [[ $1 =~ $regex ]]
31+
then
32+
echo "GITHUB_MAJOR_VERSION=${BASH_REMATCH[1]}" >> $GITHUB_ENV
33+
echo "GITHUB_MINOR_VERSION=${BASH_REMATCH[2]}" >> $GITHUB_ENV
34+
echo "GITHUB_PATCH_VERSION=${BASH_REMATCH[3]}" >> $GITHUB_ENV
35+
fi
36+
37+
- name: Change Maven version to release version
38+
run: mvn --batch-mode versions:set -DgenerateBackupPoms=false -DnewVersion=${{ env.GITHUB_MAJOR_VERSION }}.${{ env.GITHUB_MINOR_VERSION }}.${{ env.GITHUB_PATCH_VERSION }}
39+
40+
- name: Commit and tag release version
41+
uses: stefanzweifel/[email protected]
42+
with:
43+
branch: release-${{ github.ref_name }}
44+
create_branch: true
45+
commit_message: Prepare release ${{ github.ref_name }}
46+
tagging_message: ${{ github.ref_name }}
47+
48+
- name: Build with Maven
49+
run: mvn --batch-mode -Pjacoco verify
50+
51+
- name: Run SonarCloud analysis
52+
run: >
53+
mvn --batch-mode -DskipTests sonar:sonar
54+
-Dsonar.host.url=https://sonarcloud.io
55+
-Dsonar.organization=gridsuite
56+
-Dsonar.projectKey=gridsuite_spreadsheet-config-server
57+
env:
58+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
59+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
60+
61+
- name: Build Docker image
62+
run: >
63+
mvn --batch-mode deploy -DskipTests -Dmaven.install.skip -Dmaven.deploy.skip -Dpowsybl.docker.deploy
64+
-Djib.httpTimeout=60000
65+
-Djib.to.image=docker.io/gridsuite/spreadsheet-config-server:${GITHUB_REF_NAME#v}
66+
-Djib.to.auth.username=gridsuiteci
67+
-Djib.to.auth.password=${{ secrets.DOCKERHUB_TOKEN }}
68+
69+
- name: Increment minor version
70+
run: |
71+
minor=${{ env.GITHUB_MINOR_VERSION }}
72+
((minor++))
73+
echo "GITHUB_MINOR_VERSION=${minor}" >> $GITHUB_ENV
74+
75+
- name: Change Maven version to next version
76+
run: mvn --batch-mode versions:set -DgenerateBackupPoms=false -DnewVersion=${{ env.GITHUB_MAJOR_VERSION }}.${{ env.GITHUB_MINOR_VERSION }}.${{ env.GITHUB_PATCH_VERSION }}-SNAPSHOT
77+
78+
- name: Commit next version
79+
uses: stefanzweifel/[email protected]
80+
with:
81+
branch: release-${{ github.ref_name }}
82+
commit_message: Prepare next release v${{ env.GITHUB_MAJOR_VERSION }}.${{ env.GITHUB_MINOR_VERSION }}.${{ env.GITHUB_PATCH_VERSION }}
83+
skip_fetch: true
84+
skip_checkout: true
85+
86+
- name: Merge automatically into main branch
87+
uses: devmasx/[email protected]
88+
with:
89+
type: now
90+
from_branch: release-${{ github.ref_name }}
91+
target_branch: main
92+
message: Automatic merge after release ${{ github.ref_name }}
93+
github_token: ${{ secrets.REPO_ACCESS_TOKEN }}
94+
95+
- name: Delete merged branch
96+
uses: dawidd6/[email protected]
97+
with:
98+
github_token: ${{ secrets.GITHUB_TOKEN }}
99+
branches: release-${{ github.ref_name }}

0 commit comments

Comments
 (0)