|
| 1 | +name: Release |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + version: |
| 7 | + description: 'Version to release (e.g. 1.0.0)' |
| 8 | + required: true |
| 9 | + type: string |
| 10 | + next_version: |
| 11 | + description: 'Next development version (e.g. 1.0.1-SNAPSHOT)' |
| 12 | + required: true |
| 13 | + type: string |
| 14 | + |
| 15 | +jobs: |
| 16 | + release: |
| 17 | + runs-on: ubuntu-latest |
| 18 | + permissions: |
| 19 | + contents: write |
| 20 | + packages: write |
| 21 | + id-token: write |
| 22 | + issues: write |
| 23 | + pull-requests: write |
| 24 | + |
| 25 | + steps: |
| 26 | + - name: Checkout |
| 27 | + uses: actions/checkout@v6 |
| 28 | + with: |
| 29 | + fetch-depth: 0 |
| 30 | + |
| 31 | + - name: Set up JDK |
| 32 | + uses: actions/setup-java@v5 |
| 33 | + with: |
| 34 | + distribution: zulu |
| 35 | + java-version: 11 |
| 36 | + cache: maven |
| 37 | + |
| 38 | + - name: Set version |
| 39 | + run: | |
| 40 | + # Configure git for any operations |
| 41 | + git config --global user.name "GitHub Actions" |
| 42 | + git config --global user.email "actions@github.com" |
| 43 | + |
| 44 | + # Check if we already have the release commit |
| 45 | + if git log --oneline -10 | grep -q "Release version ${{ github.event.inputs.version }}"; then |
| 46 | + echo "Release commit already exists, skipping version setting" |
| 47 | + elif [ "$CURRENT_VERSION" != "${{ github.event.inputs.version }}" ]; then |
| 48 | + echo "Setting version to ${{ github.event.inputs.version }}" |
| 49 | + mvn versions:set -DgenerateBackupPoms=false -DnewVersion=${{ github.event.inputs.version }} |
| 50 | + git add pom.xml "**/pom.xml" |
| 51 | + git commit -m "Release version ${{ github.event.inputs.version }}" |
| 52 | + git push origin main |
| 53 | + else |
| 54 | + echo "Version is already set to ${{ github.event.inputs.version }}" |
| 55 | + fi |
| 56 | +
|
| 57 | + - name: Build |
| 58 | + run: ./mvnw -Ppublication |
| 59 | + |
| 60 | + - name: Release |
| 61 | + env: |
| 62 | + JRELEASER_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 63 | + JRELEASER_MAVENCENTRAL_SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }} |
| 64 | + JRELEASER_MAVENCENTRAL_SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }} |
| 65 | + JRELEASER_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} |
| 66 | + JRELEASER_GPG_SECRET_KEY: ${{ secrets.GPG_PRIVATE_KEY }} |
| 67 | + JRELEASER_GPG_PUBLIC_KEY: ${{ secrets.GPG_PUBLIC_KEY }} |
| 68 | + run: ./mvnw -N -Ppublication jreleaser:full-release |
| 69 | + |
| 70 | + - name: Set next version |
| 71 | + if: github.event_name == 'workflow_dispatch' |
| 72 | + run: | |
| 73 | + # Configure git (in case it's needed again) |
| 74 | + git config --global user.name "GitHub Actions" |
| 75 | + git config --global user.email "actions@github.com" |
| 76 | + |
| 77 | + echo "Setting next version to ${{ github.event.inputs.next_version }}" |
| 78 | + mvn versions:set -DgenerateBackupPoms=false -DnewVersion=${{ github.event.inputs.next_version }} |
| 79 | + git add pom.xml "**/pom.xml" |
| 80 | + git commit -m "Prepare for next development version" |
| 81 | + git push origin main |
0 commit comments