|
1 | | -name: Publish Package to GitHub Packages |
| 1 | +name: Publish to GitHub Packages |
2 | 2 |
|
3 | 3 | on: |
4 | 4 | push: |
|
9 | 9 |
|
10 | 10 | jobs: |
11 | 11 | publish: |
| 12 | + name: Build and Publish |
12 | 13 | runs-on: ubuntu-latest |
13 | 14 | permissions: |
14 | 15 | contents: read |
15 | 16 | packages: write |
16 | 17 |
|
17 | 18 | steps: |
18 | | - - name: Check out repository |
| 19 | + - name: Checkout repository |
19 | 20 | uses: actions/checkout@v4 |
20 | | - with: |
21 | | - fetch-depth: 0 |
22 | 21 |
|
23 | | - - name: Set up JDK 21 and Maven |
| 22 | + - name: Set up JDK 21 |
24 | 23 | uses: actions/setup-java@v4 |
25 | 24 | with: |
26 | 25 | java-version: '21' |
27 | 26 | distribution: 'temurin' |
28 | 27 | 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 |
29 | 38 |
|
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 |
32 | 44 |
|
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 |
35 | 47 | env: |
36 | 48 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments