|
| 1 | +name: Release |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + version: |
| 7 | + description: "Version to release" |
| 8 | + required: true |
| 9 | + type: string |
| 10 | + |
| 11 | +jobs: |
| 12 | + release: |
| 13 | + name: Release |
| 14 | + runs-on: ubuntu-latest |
| 15 | + steps: |
| 16 | + - name: Cancel previous run |
| 17 | + uses: styfle/cancel-workflow-action@0.12.1 |
| 18 | + with: |
| 19 | + access_token: ${{ secrets.GIT_ACCESS_TOKEN }} |
| 20 | + |
| 21 | + - name: Checkout |
| 22 | + uses: actions/checkout@v4 |
| 23 | + with: |
| 24 | + fetch-depth: 0 |
| 25 | + |
| 26 | + - name: Set up Java |
| 27 | + uses: actions/setup-java@v4 |
| 28 | + with: |
| 29 | + java-version: 21 |
| 30 | + distribution: 'zulu' |
| 31 | + |
| 32 | + - name: Cache Gradle |
| 33 | + uses: actions/cache@v4 |
| 34 | + with: |
| 35 | + path: ~/.gradle/caches |
| 36 | + key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}-${{ hashFiles('**/gradle.properties') }} |
| 37 | + restore-keys: | |
| 38 | + ${{ runner.os }}-gradle- |
| 39 | +
|
| 40 | + - name: Cache Gradle wrapper |
| 41 | + uses: actions/cache@v4 |
| 42 | + with: |
| 43 | + path: ~/.gradle/wrapper |
| 44 | + key: ${{ runner.os }}-gradlew-${{ hashFiles('**/gradlew') }} |
| 45 | + restore-keys: ${{ runner.os }}-gradlew- |
| 46 | + |
| 47 | + - name: Set up Git |
| 48 | + run: | |
| 49 | + git config user.name "GitHub Actions" |
| 50 | + git config user.email "actions@github.com" |
| 51 | +
|
| 52 | + - name: Bump version in gradle.properties |
| 53 | + id: bump |
| 54 | + run: | |
| 55 | + sed -i "s/^version\s*=.*/version = ${{ inputs.version }}/" gradle.properties |
| 56 | + git add gradle.properties |
| 57 | + git commit --allow-empty -m "Releasing version ${{ inputs.version }}" |
| 58 | + git push origin HEAD |
| 59 | +
|
| 60 | + - name: Build |
| 61 | + run: | |
| 62 | + ./gradlew build test aggregateTestReport publish -S |
| 63 | + env: |
| 64 | + GRGIT_USER: ${{ secrets.GIT_USER }} |
| 65 | + GRGIT_PASS: ${{ secrets.GIT_ACCESS_TOKEN }} |
| 66 | + |
| 67 | + - name: Upload test reports |
| 68 | + if: failure() |
| 69 | + uses: actions/upload-artifact@v4 |
| 70 | + with: |
| 71 | + name: test-reports |
| 72 | + path: | |
| 73 | + build/reports/tests/aggregate/ |
| 74 | +
|
| 75 | + - name: Assemble |
| 76 | + uses: jreleaser/release-action@v2 |
| 77 | + with: |
| 78 | + arguments: assemble |
| 79 | + env: |
| 80 | + JRELEASER_PROJECT_VERSION: ${{ inputs.version }} |
| 81 | + |
| 82 | + - name: Release |
| 83 | + uses: jreleaser/release-action@v2 |
| 84 | + with: |
| 85 | + arguments: full-release |
| 86 | + env: |
| 87 | + JRELEASER_GITHUB_PASSWORD: ${{ secrets.GIT_ACCESS_TOKEN }} |
| 88 | + JRELEASER_GITHUB_TOKEN: ${{ secrets.GIT_ACCESS_TOKEN }} |
| 89 | + JRELEASER_GITHUB_USERNAME: ${{ secrets.GIT_USER }} |
| 90 | + JRELEASER_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} |
| 91 | + JRELEASER_GPG_PUBLIC_KEY: ${{ secrets.GPG_PUBLIC_KEY }} |
| 92 | + JRELEASER_GPG_SECRET_KEY: ${{ secrets.GPG_SECRET_KEY }} |
| 93 | + JRELEASER_MAVENCENTRAL_USERNAME: ${{ secrets.SONATYPE_USERNAME }} |
| 94 | + JRELEASER_MAVENCENTRAL_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }} |
| 95 | + JRELEASER_PROJECT_VERSION: ${{ inputs.version }} |
| 96 | + JRELEASER_SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }} |
| 97 | + |
| 98 | + - name: JReleaser output |
| 99 | + if: always() |
| 100 | + uses: actions/upload-artifact@v4 |
| 101 | + with: |
| 102 | + name: artifact |
| 103 | + path: | |
| 104 | + out/jreleaser/trace.log |
| 105 | + out/jreleaser/output.properties |
0 commit comments