microsoft/gctoolkit
Publicmirrored fromhttps://github.com/microsoft/gctoolkitAvailable
.github/workflows/publish.yml
64lines · modecode
| 1 | name: Publish to Maven Central |
| 2 | |
| 3 | on: |
| 4 | workflow_dispatch: |
| 5 | |
| 6 | jobs: |
| 7 | publish: |
| 8 | |
| 9 | runs-on: ubuntu-latest |
| 10 | |
| 11 | steps: |
| 12 | - name: Checkout project |
| 13 | uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 |
| 14 | with: |
| 15 | ref: main |
| 16 | fetch-depth: 0 |
| 17 | |
| 18 | - name: Cache Maven |
| 19 | uses: actions/cache@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3 |
| 20 | with: |
| 21 | path: ~/.m2/repository |
| 22 | key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} |
| 23 | restore-keys: ${{ runner.os }}-m2 |
| 24 | |
| 25 | - name: Setup Java JDK |
| 26 | uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5.2.0 |
| 27 | with: |
| 28 | java-version: '11' |
| 29 | distribution: 'microsoft' |
| 30 | server-id: ossrh |
| 31 | server-username: MAVEN_USERNAME |
| 32 | server-password: MAVEN_CENTRAL_TOKEN |
| 33 | gpg-private-key: ${{ secrets.GPG_PRIVATEKEY }} |
| 34 | gpg-passphrase: MAVEN_GPG_PASSPHRASE |
| 35 | |
| 36 | - name: Configure Git user |
| 37 | run: | |
| 38 | git config user.email "actions@github.com" |
| 39 | git config user.name "GitHub Actions" |
| 40 | |
| 41 | - name: Version |
| 42 | id: version |
| 43 | run: | |
| 44 | release_version=$(./mvnw help:evaluate -Dexpression=project.version -q -DforceStdout) |
| 45 | release_version=${release_version%-*} |
| 46 | echo ::set-output name=version::${release_version} |
| 47 | |
| 48 | - name: Release |
| 49 | run: | |
| 50 | export GPG_TTY=$(tty) |
| 51 | ./mvnw -Darguments="-Drelease=true" -B release:prepare release:perform -Drelease=true \ |
| 52 | -Drepository.url=https://${{ github.actor }}:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git |
| 53 | |
| 54 | env: |
| 55 | MAVEN_USERNAME: ${{ secrets.SONATYPE_NAME }} |
| 56 | MAVEN_CENTRAL_TOKEN: ${{ secrets.SONATYPE_PASSWORD }} |
| 57 | MAVEN_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} |
| 58 | |
| 59 | - name: Git-release |
| 60 | run: | |
| 61 | ./mvnw -B versions:set -DnewVersion=${{steps.version.outputs.version}} |
| 62 | ./mvnw -B -pl :gctoolkit -Pjreleaser jreleaser:release |
| 63 | env: |
| 64 | JRELEASER_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |