Skip to content

Commit ec418b8

Browse files
committed
chore(ci): update ci pipeline to add partial commit sha in snapshot builds
1 parent 46cba7b commit ec418b8

File tree

1 file changed

+21
-9
lines changed

1 file changed

+21
-9
lines changed
Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Publish Package to GitHub Packages
1+
name: Publish to GitHub Packages
22

33
on:
44
push:
@@ -9,28 +9,40 @@ on:
99

1010
jobs:
1111
publish:
12+
name: Build and Publish
1213
runs-on: ubuntu-latest
1314
permissions:
1415
contents: read
1516
packages: write
1617

1718
steps:
18-
- name: Check out repository
19+
- name: Checkout repository
1920
uses: actions/checkout@v4
20-
with:
21-
fetch-depth: 0
2221

23-
- name: Set up JDK 21 and Maven
22+
- name: Set up JDK 21
2423
uses: actions/setup-java@v4
2524
with:
2625
java-version: '21'
2726
distribution: 'temurin'
2827
server-id: github
28+
settings-path: ${{ github.workspace }}
29+
30+
- name: Set snapshot version for main branch
31+
if: startsWith(github.ref, 'refs/heads/main')
32+
id: vars
33+
run: echo "sha=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
34+
35+
- name: Update POM for snapshot version
36+
if: startsWith(github.ref, 'refs/heads/main')
37+
run: mvn versions:set -DnewVersion=1.0-${{ steps.vars.outputs.sha }}-SNAPSHOT -DprocessAllModules -DgenerateBackupPoms=false
2938

30-
- name: Display Calculated Version
31-
run: mvn -B --no-transfer-progress help:evaluate -Dexpression=project.version -q -DforceStdout
39+
- name: Set release version from tag
40+
if: startsWith(github.ref, 'refs/tags/v')
41+
run: |
42+
VERSION=${{ github.ref_name#v }}
43+
mvn versions:set -DnewVersion=${VERSION} -DprocessAllModules -DgenerateBackupPoms=false
3244
33-
- name: Build and Publish Package
34-
run: mvn -B --no-transfer-progress deploy
45+
- name: Publish to GitHub Packages
46+
run: mvn -B deploy
3547
env:
3648
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)