|
| 1 | +name: Release |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + releaseVersion: |
| 7 | + description: "Release version" |
| 8 | + required: true |
| 9 | + default: "2.9.9.99" |
| 10 | + nextDevVersion: |
| 11 | + description: "Next development version (must end with -SNAPSHOT)" |
| 12 | + required: true |
| 13 | + default: "2.9.9.100-SNAPSHOT" |
| 14 | + |
| 15 | +permissions: |
| 16 | + contents: write |
| 17 | + |
| 18 | +jobs: |
| 19 | + release: |
| 20 | + runs-on: ubuntu-latest |
| 21 | + steps: |
| 22 | + - name: Checkout code |
| 23 | + uses: actions/checkout@v4 |
| 24 | + with: |
| 25 | + fetch-depth: 0 |
| 26 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 27 | + |
| 28 | + - name: Set up JDK 8 |
| 29 | + uses: actions/setup-java@v4 |
| 30 | + with: |
| 31 | + java-version: "8" |
| 32 | + distribution: "temurin" |
| 33 | + server-id: sonatype-nexus-staging |
| 34 | + server-username: ${{ secrets.OSSRH_USERNAME }} |
| 35 | + server-password: ${{ secrets.OSSRH_TOKEN }} |
| 36 | + gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }} |
| 37 | + gpg-passphrase: ${{ secrets.GPG_PASSPHRASE }} |
| 38 | + |
| 39 | + - name: Configure Git |
| 40 | + run: | |
| 41 | + git config user.email "hudson@whitesourcesoftware.com" |
| 42 | + git config user.name "whitesource-ci" |
| 43 | + # Configure Git to use HTTPS instead of SSH |
| 44 | + git config --global url."https://x-access-token:${{ github.token }}@github.com/".insteadOf "git@github.com:" |
| 45 | +
|
| 46 | + - name: Configure GPG |
| 47 | + run: | |
| 48 | + mkdir -p ~/.gnupg |
| 49 | + chmod 700 ~/.gnupg |
| 50 | + echo "allow-loopback-pinentry" > ~/.gnupg/gpg-agent.conf |
| 51 | + echo "pinentry-mode loopback" > ~/.gnupg/gpg.conf |
| 52 | +
|
| 53 | + - name: Create Maven settings.xml |
| 54 | + run: | |
| 55 | + mkdir -p ~/.m2 |
| 56 | + echo "<settings> |
| 57 | + <servers> |
| 58 | + <server> |
| 59 | + <id>sonatype-nexus-staging</id> |
| 60 | + <username>${{ secrets.OSSRH_USERNAME }}</username> |
| 61 | + <password>${{ secrets.OSSRH_TOKEN }}</password> |
| 62 | + </server> |
| 63 | + </servers> |
| 64 | + <profiles> |
| 65 | + <profile> |
| 66 | + <id>gpg-settings</id> |
| 67 | + <properties> |
| 68 | + <gpg.executable>gpg</gpg.executable> |
| 69 | + <gpg.passphrase>${{ secrets.GPG_PASSPHRASE }}</gpg.passphrase> |
| 70 | + </properties> |
| 71 | + </profile> |
| 72 | + </profiles> |
| 73 | + <activeProfiles> |
| 74 | + <activeProfile>gpg-settings</activeProfile> |
| 75 | + </activeProfiles> |
| 76 | + </settings>" > ~/.m2/settings.xml |
| 77 | +
|
| 78 | + - name: Maven Release |
| 79 | + run: | |
| 80 | + export GPG_TTY=$(tty) |
| 81 | + mvn -B -DsourceLevel=1.8 -Djava.version=1.8 \ |
| 82 | + -DreleaseVersion=${{ github.event.inputs.releaseVersion }} \ |
| 83 | + -DdevelopmentVersion=${{ github.event.inputs.nextDevVersion }} \ |
| 84 | + -DscmCommentPrefix="[maven-release-plugin] [skip ci] " \ |
| 85 | + -Darguments="-Dgpg.passphrase=${{ secrets.GPG_PASSPHRASE }} -Pci-build -PRelease" \ |
| 86 | + release:clean release:prepare release:perform |
| 87 | + env: |
| 88 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 89 | + GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} |
0 commit comments