|
1 | 1 | name: Release |
2 | 2 |
|
3 | 3 | on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + |
4 | 8 | workflow_dispatch: |
5 | 9 | inputs: |
6 | | - name: |
7 | | - description: 'Github Actions - Release' |
8 | | - required: true |
9 | | - default: 'Github Actions - Release' |
| 10 | + snapshot: |
| 11 | + description: 'Deploy SNAPSHOT' |
| 12 | + type: boolean |
| 13 | + default: false |
| 14 | + |
| 15 | +permissions: |
| 16 | + contents: read |
10 | 17 |
|
11 | 18 | jobs: |
12 | 19 |
|
13 | | - Publish: |
| 20 | + deploy-snapshot: |
| 21 | + if: github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && inputs.snapshot == true) |
| 22 | + runs-on: ubuntu-latest |
| 23 | + steps: |
| 24 | + - uses: actions/checkout@v6 |
| 25 | + |
| 26 | + - uses: actions/setup-java@v5 |
| 27 | + with: |
| 28 | + distribution: 'corretto' |
| 29 | + java-version: '11' |
| 30 | + |
| 31 | + - name: Grant Permission |
| 32 | + run: chmod +x ./mvnw |
| 33 | + |
| 34 | + - name: Check SNAPSHOT version |
| 35 | + id: check-version |
| 36 | + run: | |
| 37 | + VERSION=$(./mvnw help:evaluate -Dexpression=project.version -q -DforceStdout) |
| 38 | + echo "version=$VERSION" >> "$GITHUB_OUTPUT" |
| 39 | + if [[ "$VERSION" != *-SNAPSHOT ]]; then |
| 40 | + echo "::error::Version $VERSION is not a SNAPSHOT version" |
| 41 | + exit 1 |
| 42 | + fi |
| 43 | +
|
| 44 | + - name: Remove old Maven Settings |
| 45 | + run: rm -f /home/runner/.m2/settings.xml |
| 46 | + |
| 47 | + - name: Maven Settings |
| 48 | + uses: s4u/maven-settings-action@v4.0.0 |
| 49 | + with: |
| 50 | + servers: | |
| 51 | + [{ |
| 52 | + "id": "central", |
| 53 | + "username": "${{ secrets.OSSRH_USERNAME }}", |
| 54 | + "password": "${{ secrets.OSSRH_PASSWORD }}" |
| 55 | + }] |
| 56 | +
|
| 57 | + - name: Deploy Snapshot |
| 58 | + run: ./mvnw -B -ntp deploy -DskipTests |
| 59 | + |
| 60 | + publish-release: |
| 61 | + if: github.event_name == 'workflow_dispatch' && inputs.snapshot == false |
14 | 62 | runs-on: ubuntu-latest |
15 | 63 | steps: |
16 | 64 | - uses: actions/checkout@v6 |
|
41 | 89 | with: |
42 | 90 | gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }} |
43 | 91 | passphrase: ${{ secrets.GPG_PASSPHRASE }} |
44 | | - |
| 92 | + |
45 | 93 | - name: Build |
46 | 94 | run: mvn -ntp -B clean verify install -DskipTests -Prelease |
47 | 95 |
|
|
0 commit comments