|
| 1 | +# This workflow will build a package using Maven and then publish it to GitHub packages when a release is created |
| 2 | +## For more information see: https://github.com/actions/setup-java/blob/main/docs/advanced-usage.md#apache-maven-with-a-settings-path |
| 3 | + |
| 4 | +name: Maven Manual Deploy |
| 5 | + |
| 6 | +on: |
| 7 | + workflow_dispatch: |
| 8 | + inputs: |
| 9 | + ref: |
| 10 | + description: "Git ref to release" |
| 11 | + required: true |
| 12 | + version: |
| 13 | + description: "Maven version to release (without 'v' prefix)" |
| 14 | + required: true |
| 15 | + deployArgs: |
| 16 | + description: "Additional Maven deploy arguments (e.g. '--debug -DautoReleaseAfterClose=false')" |
| 17 | + required: false |
| 18 | + |
| 19 | +jobs: |
| 20 | + build: |
| 21 | + runs-on: ubuntu-latest |
| 22 | + env: |
| 23 | + SONATYPE_USER: ${{secrets.SONATYPE_USER}} |
| 24 | + SONATYPE_PASSWORD: ${{secrets.SONATYPE_PASSWORD}} |
| 25 | + GPG_KEY_NAME: ${{secrets.GPG_KEY_NAME}} |
| 26 | + GPG_PASSPHRASE: ${{secrets.GPG_PASSPHRASE}} |
| 27 | + MAVEN_OPTS: "--add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.base/java.lang.reflect=ALL-UNNAMED --add-opens=java.base/java.text=ALL-UNNAMED --add-opens=java.desktop/java.awt.font=ALL-UNNAMED" |
| 28 | + REF_NAME: ${{ inputs.ref }} |
| 29 | + |
| 30 | + steps: |
| 31 | + - uses: actions/checkout@v4 |
| 32 | + with: |
| 33 | + ref: ${{ inputs.ref }} |
| 34 | + - uses: actions/setup-go@v5 |
| 35 | + with: |
| 36 | + go-version: 'stable' |
| 37 | + - name: Set VERSION variable from tag |
| 38 | + run: | |
| 39 | + echo "VERSION=${{ inputs.VERSION }}" >> $GITHUB_ENV |
| 40 | +
|
| 41 | + - name: 'Configure GPG signing' |
| 42 | + env: |
| 43 | + GPG_KEY: ${{ secrets.GPG_PRIVATE_KEY }} |
| 44 | + GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} |
| 45 | + run: | |
| 46 | + # https://github.com/keybase/keybase-issues/issues/2798 |
| 47 | + export GPG_TTY=$(tty) |
| 48 | + # Import gpg keys and warm the passphrase to avoid the gpg |
| 49 | + # passphrase prompt when initating a deploy |
| 50 | + # `--pinentry-mode=loopback` could be needed to ensure we |
| 51 | + # suppress the gpg prompt |
| 52 | + echo $GPG_KEY | base64 --decode > signing-key |
| 53 | + gpg --passphrase $GPG_PASSPHRASE --batch --import signing-key |
| 54 | + shred signing-key |
| 55 | +
|
| 56 | + - name: Configure GIT |
| 57 | + run: | |
| 58 | + git config --global user.email "[email protected]" |
| 59 | + git config --global user.name "envoy-bot" |
| 60 | +
|
| 61 | + - name: Set up JDK |
| 62 | + uses: actions/setup-java@v4 |
| 63 | + with: |
| 64 | + distribution: 'temurin' |
| 65 | + java-version: '17' |
| 66 | + cache: 'maven' |
| 67 | + server-id: ossrh |
| 68 | + server-username: ${ env.SONATYPE_USER } |
| 69 | + server-password: ${ env.SONATYPE_PASSWORD } |
| 70 | + gpg-private-key: ${{ secrets.GPG_SECRET_KEY }} |
| 71 | + gpg-passphrase: ${ env.GPG_PASSPHRASE } |
| 72 | + |
| 73 | + - name: Update version in pom |
| 74 | + working-directory: ${{ github.workspace }}/java |
| 75 | + run: ./mvnw -B versions:set -DnewVersion=${{ env.VERSION }} -DgenerateBackupPoms=false |
| 76 | + |
| 77 | + - name: Publish to Maven Packages Apache Maven |
| 78 | + working-directory: ${{ github.workspace }}/java |
| 79 | + run: | |
| 80 | + ./mvnw -B -s settings.xml ${{ inputs.deployArgs }} clean deploy \ |
| 81 | + -Darguments="-s settings.xml" \ |
| 82 | + -DreleaseVersion=${{ env.VERSION }} \ |
| 83 | + -DdevelopmentVersion=${{ env.VERSION }}-SNAPSHOT \ |
| 84 | + -DscmCommentPrefix="java release: " |
| 85 | + env: |
| 86 | + MAVEN_USERNAME: ${{ env.SONATYPE_USER }} |
| 87 | + MAVEN_CENTRAL_TOKEN: ${{ env.SONATYPE_PASSWORD }} |
| 88 | + MAVEN_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} |
0 commit comments