Skip to content

Commit fdc9b5f

Browse files
committed
Introduce Release Workflow
Signed-off-by: Ricardo Zanini <[email protected]>
1 parent 46a6900 commit fdc9b5f

File tree

6 files changed

+573
-290
lines changed

6 files changed

+573
-290
lines changed

.github/project.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
release:
2+
current-version: 5.0.0
3+
next-version: 6.0.0-SNAPSHOT

.github/workflows/maven-deploy.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# This workflow will build a Java project with Maven
22
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven
33

4-
name: Deploy JAVA SDK
4+
name: Deploy SNAPSHOT
55

66
on:
77
push:

.github/workflows/maven-verify.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# This workflow will build a Java project with Maven
22
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven
33

4-
name: Verify JAVA SDK
4+
name: Verify SNAPSHOT
55

66
on:
77
push:

.github/workflows/pre-release.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: sdk-java Pre Release
2+
3+
on:
4+
pull_request:
5+
paths:
6+
- '.github/project.yml'
7+
8+
jobs:
9+
release:
10+
runs-on: ubuntu-latest
11+
name: pre release
12+
13+
steps:
14+
- uses: radcortez/project-metadata-action@master
15+
name: retrieve project metadata
16+
id: metadata
17+
with:
18+
github-token: ${{secrets.GITHUB_TOKEN}}
19+
metadata-file-path: '.github/project.yml'
20+
21+
- name: Validate version
22+
if: contains(steps.metadata.outputs.current-version, 'SNAPSHOT')
23+
run: |
24+
echo '::error::Cannot release a SNAPSHOT version.'
25+
exit 1

.github/workflows/release.yml

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
name: sdk-java Release
2+
3+
on:
4+
pull_request:
5+
types: [closed]
6+
paths:
7+
- '.github/project.yml'
8+
9+
jobs:
10+
release:
11+
runs-on: ubuntu-latest
12+
name: release
13+
if: ${{github.event.pull_request.merged == true}}
14+
15+
steps:
16+
- uses: radcortez/project-metadata-action@main
17+
name: Retrieve project metadata
18+
id: metadata
19+
with:
20+
github-token: ${{secrets.GITHUB_TOKEN}}
21+
metadata-file-path: '.github/project.yml'
22+
23+
- uses: actions/checkout@v3
24+
25+
- name: Import GPG key
26+
id: import_gpg
27+
uses: crazy-max/ghaction-import-gpg@v5
28+
with:
29+
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
30+
passphrase: ${{ secrets.GPG_PASSPHRASE }}
31+
32+
- name: Set up JDK 11
33+
uses: actions/setup-java@v3
34+
with:
35+
distribution: temurin
36+
java-version: 11
37+
38+
- name: Cache local Maven repository
39+
uses: actions/cache@v3
40+
with:
41+
path: ~/.m2/repository
42+
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
43+
restore-keys: |
44+
${{ runner.os }}-maven-
45+
46+
- name: Configure Git author
47+
run: |
48+
git config --local user.email "[email protected]"
49+
git config --local user.name "GitHub Action"
50+
51+
- name: Maven release ${{steps.metadata.outputs.current-version}}
52+
run: |
53+
gpg --quiet --batch --yes --decrypt --passphrase="${{secrets.GPG_PASSPHRASE}}" --output /tmp/maven-settings.xml .github/release/maven-settings.xml.gpg
54+
git checkout -b release
55+
mvn -B release:prepare -Prelease -DreleaseVersion=${{steps.metadata.outputs.current-version}} -DdevelopmentVersion=${{steps.metadata.outputs.next-version}} -s /tmp/maven-settings.xml
56+
git checkout ${{github.base_ref}}
57+
git rebase release
58+
mvn -B release:perform -Darguments=-DperformRelease -DperformRelease -Prelease -s /tmp/maven-settings.xml
59+
60+
- name: Push changes to ${{github.base_ref}}
61+
uses: ad-m/[email protected]
62+
with:
63+
github_token: ${{ secrets.GITHUB_TOKEN }}
64+
branch: ${{github.base_ref}}
65+
66+
- name: Push tags
67+
uses: ad-m/[email protected]
68+
with:
69+
github_token: ${{ secrets.GITHUB_TOKEN }}
70+
tags: true
71+
branch: ${{github.base_ref}}

0 commit comments

Comments
 (0)