Skip to content

Commit e4895d2

Browse files
chore: automated release with version commits
Signed-off-by: Joris Mancini <[email protected]>
1 parent ba26e85 commit e4895d2

File tree

3 files changed

+182
-13
lines changed

3 files changed

+182
-13
lines changed

.github/workflows/maven.yml renamed to .github/workflows/build.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/patch.yml

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
name: Patch
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
releaseVersion:
7+
description: Patch version (vX.X)
8+
required: true
9+
10+
jobs:
11+
patch:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Set up JDK 17
15+
uses: actions/setup-java@v1
16+
with:
17+
java-version: 17
18+
19+
- uses: actions/create-github-app-token@v1
20+
id: app-token
21+
name: Generate app token
22+
with:
23+
app-id: ${{ vars.GRIDSUITE_ACTIONS_APPID }}
24+
private-key: ${{ secrets.GRIDSUITE_ACTIONS_SECRET }}
25+
26+
- name: Checkout sources
27+
uses: actions/checkout@v4
28+
with:
29+
fetch-depth: 0
30+
token: ${{ steps.app-token.outputs.token }}
31+
32+
- name: Checkout on existing release branch
33+
run: |
34+
git checkout release/${{ github.event.inputs.releaseVersion }}
35+
36+
- name: Extract tag versions
37+
run: |
38+
lastTag=$(git describe --tags --abbrev=0)
39+
regex="v([0-9]+).([0-9]+).([0-9]+)"
40+
if [[ $lastTag =~ $regex ]]
41+
then
42+
major=${BASH_REMATCH[1]}
43+
minor=${BASH_REMATCH[2]}
44+
patch=${BASH_REMATCH[3]}
45+
((++patch))
46+
echo "GITHUB_MAJOR_VERSION=$major" >> $GITHUB_ENV
47+
echo "GITHUB_MINOR_VERSION=$minor" >> $GITHUB_ENV
48+
echo "GITHUB_PATCH_VERSION=$patch" >> $GITHUB_ENV
49+
echo "GITHUB_SHORT_VERSION=$major.$minor.$patch" >> $GITHUB_ENV
50+
fi
51+
52+
- name: Change Maven version to release version
53+
run: mvn --batch-mode versions:set -DgenerateBackupPoms=false -DnewVersion=${{ env.GITHUB_SHORT_VERSION }}
54+
55+
- name: Build with Maven
56+
run: mvn --batch-mode -Pjacoco verify
57+
58+
- name: Run SonarCloud analysis
59+
run: >
60+
mvn --batch-mode -DskipTests sonar:sonar
61+
-Dsonar.host.url=https://sonarcloud.io
62+
-Dsonar.organization=gridsuite
63+
-Dsonar.projectKey=gridsuite_spreadsheet-config-server
64+
env:
65+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
66+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
67+
68+
- name: Build Docker image
69+
run: >
70+
mvn --batch-mode deploy -DskipTests -Dmaven.install.skip -Dmaven.deploy.skip -Dpowsybl.docker.deploy
71+
-Djib.httpTimeout=60000
72+
-Djib.to.image=docker.io/gridsuite/spreadsheet-config-server:${{ env.GITHUB_SHORT_VERSION }}
73+
-Djib.to.auth.username=gridsuiteci
74+
-Djib.to.auth.password=${{ secrets.DOCKERHUB_TOKEN }}
75+
76+
- name: Commit and tag release version
77+
run: |
78+
git config --global user.name "github-actions[bot]"
79+
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
80+
git add .
81+
git commit -m "Patched release v${{ env.GITHUB_SHORT_VERSION }}"
82+
git tag v${{ env.GITHUB_SHORT_VERSION }}
83+
git push origin release/v${{ env.GITHUB_MAJOR_VERSION }}.${{ env.GITHUB_MINOR_VERSION }}
84+
git push origin v${{ env.GITHUB_SHORT_VERSION }}

.github/workflows/release.yml

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
name: Release
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
releaseVersion:
7+
description: Release version (vX.X)
8+
required: true
9+
commitSha:
10+
description: SHA of the commit from where to release
11+
required: true
12+
13+
jobs:
14+
release:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- name: Set up JDK 17
18+
uses: actions/setup-java@v1
19+
with:
20+
java-version: 17
21+
22+
- uses: actions/create-github-app-token@v1
23+
id: app-token
24+
name: Generate app token
25+
with:
26+
app-id: ${{ vars.GRIDSUITE_ACTIONS_APPID }}
27+
private-key: ${{ secrets.GRIDSUITE_ACTIONS_SECRET }}
28+
29+
- name: Checkout sources
30+
uses: actions/checkout@v4
31+
with:
32+
fetch-depth: 0
33+
token: ${{ steps.app-token.outputs.token }}
34+
35+
- name: Extract tag versions
36+
run: |
37+
regex="v([0-9]+).([0-9]+)"
38+
if [[ ${{ github.event.inputs.releaseVersion }} =~ $regex ]]
39+
then
40+
echo "GITHUB_MAJOR_VERSION=${BASH_REMATCH[1]}" >> $GITHUB_ENV
41+
echo "GITHUB_MINOR_VERSION=${BASH_REMATCH[2]}" >> $GITHUB_ENV
42+
echo "GITHUB_SHORT_VERSION=${BASH_REMATCH[1]}.${BASH_REMATCH[2]}.0" >> $GITHUB_ENV
43+
fi
44+
45+
- name: Checkout with new branch
46+
run: |
47+
git checkout -b release/v${{ env.GITHUB_MAJOR_VERSION }}.${{ env.GITHUB_MINOR_VERSION }} ${{ github.event.inputs.commitSha }}
48+
49+
- name: Change Maven version to release version
50+
run: mvn --batch-mode versions:set -DgenerateBackupPoms=false -DnewVersion=${{ env.GITHUB_SHORT_VERSION }}
51+
52+
- name: Build with Maven
53+
run: mvn --batch-mode -Pjacoco verify
54+
55+
- name: Run SonarCloud analysis
56+
run: >
57+
mvn --batch-mode -DskipTests sonar:sonar
58+
-Dsonar.host.url=https://sonarcloud.io
59+
-Dsonar.organization=gridsuite
60+
-Dsonar.projectKey=gridsuite_spreadsheet-config-server
61+
env:
62+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
63+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
64+
65+
- name: Build Docker image
66+
run: >
67+
mvn --batch-mode deploy -DskipTests -Dmaven.install.skip -Dmaven.deploy.skip -Dpowsybl.docker.deploy
68+
-Djib.httpTimeout=60000
69+
-Djib.to.image=docker.io/gridsuite/spreadsheet-config-server:${{ env.GITHUB_SHORT_VERSION }}
70+
-Djib.to.auth.username=gridsuiteci
71+
-Djib.to.auth.password=${{ secrets.DOCKERHUB_TOKEN }}
72+
73+
- name: Commit and tag release version
74+
run: |
75+
git config --global user.name "github-actions[bot]"
76+
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
77+
git add .
78+
git commit -m "Release v${{ env.GITHUB_SHORT_VERSION }}"
79+
git tag v${{ env.GITHUB_SHORT_VERSION }}
80+
git push origin release/v${{ env.GITHUB_MAJOR_VERSION }}.${{ env.GITHUB_MINOR_VERSION }}
81+
git push origin v${{ env.GITHUB_SHORT_VERSION }}
82+
83+
- name: Increment minor version
84+
run: |
85+
minor=${{ env.GITHUB_MINOR_VERSION }}
86+
((minor++))
87+
echo "GITHUB_MINOR_VERSION=${minor}" >> $GITHUB_ENV
88+
89+
- name: Update SNAPSHOT version on main
90+
run: |
91+
git checkout main
92+
git pull
93+
mvn --batch-mode versions:set -DgenerateBackupPoms=false -DnewVersion=${{ env.GITHUB_MAJOR_VERSION }}.${{ env.GITHUB_MINOR_VERSION }}.0-SNAPSHOT
94+
git add .
95+
git commit -m "Update SNAPSHOT version to v${{ env.GITHUB_MAJOR_VERSION }}.${{ env.GITHUB_MINOR_VERSION }}.0"
96+
git push

0 commit comments

Comments
 (0)