|
| 1 | +name: Release |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + version: |
| 7 | + description: "Release version" |
| 8 | + required: true |
| 9 | + next: |
| 10 | + description: "Next version" |
| 11 | + required: false |
| 12 | + |
| 13 | +jobs: |
| 14 | + version: |
| 15 | + name: Release |
| 16 | + runs-on: ubuntu-latest |
| 17 | + steps: |
| 18 | + - uses: actions/checkout@v2 |
| 19 | + with: |
| 20 | + fetch-depth: 0 |
| 21 | + - uses: actions/setup-java@v2 |
| 22 | + with: |
| 23 | + java-version: 11 |
| 24 | + distribution: temurin |
| 25 | + - name: Set release version |
| 26 | + id: version |
| 27 | + run: | |
| 28 | + RELEASE_VERSION=${{ github.event.inputs.version }} |
| 29 | + NEXT_VERSION=${{ github.event.inputs.next }} |
| 30 | + PLAIN_VERSION=`echo ${RELEASE_VERSION} | awk 'match($0, /^(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)/) { print substr($0, RSTART, RLENGTH); }'` |
| 31 | + COMPUTED_NEXT_VERSION="${PLAIN_VERSION}-SNAPSHOT" |
| 32 | + if [ -z $NEXT_VERSION ] |
| 33 | + then |
| 34 | + NEXT_VERSION=$COMPUTED_NEXT_VERSION |
| 35 | + fi |
| 36 | + ./mvnw -B versions:set versions:commit -DnewVersion=$RELEASE_VERSION |
| 37 | + git config --global user.email "project.openubl.preview.bot@gmail.com" |
| 38 | + git config --global user.name "Project-Openubl Bot" |
| 39 | + git commit -a -m "🏁 Releasing version $RELEASE_VERSION" |
| 40 | + git push origin HEAD:master |
| 41 | + git rev-parse HEAD > HEAD |
| 42 | + echo $RELEASE_VERSION > RELEASE_VERSION |
| 43 | + echo $PLAIN_VERSION > PLAIN_VERSION |
| 44 | + echo $NEXT_VERSION > NEXT_VERSION |
| 45 | + - name: Upload version files |
| 46 | + uses: actions/upload-artifact@v2 |
| 47 | + with: |
| 48 | + name: artifacts |
| 49 | + path: | |
| 50 | + HEAD |
| 51 | + *_VERSION |
| 52 | +
|
| 53 | + release: |
| 54 | + needs: [ version ] |
| 55 | + runs-on: ubuntu-latest |
| 56 | + steps: |
| 57 | + - uses: actions/download-artifact@v2 |
| 58 | + with: |
| 59 | + name: artifacts |
| 60 | + path: artifacts |
| 61 | + - name: Read HEAD ref |
| 62 | + id: head |
| 63 | + uses: juliangruber/read-file-action@v1 |
| 64 | + with: |
| 65 | + path: artifacts/HEAD |
| 66 | + - uses: actions/checkout@v2 |
| 67 | + with: |
| 68 | + ref: ${{ steps.head.outputs.content }} |
| 69 | + |
| 70 | + - name: Release with JReleaser |
| 71 | + uses: jreleaser/release-action@v2 |
| 72 | + env: |
| 73 | + JRELEASER_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 74 | + JRELEASER_PROJECT_VERSION: ${{ steps.version.outputs.RELEASE_VERSION }} |
| 75 | + JRELEASER_ZULIP_API_KEY: ${{ secrets.JRELEASER_ZULIP_API_KEY }} |
| 76 | + JRELEASER_TWITTER_CONSUMER_KEY: ${{ secrets.JRELEASER_TWITTER_CONSUMER_KEY }} |
| 77 | + JRELEASER_TWITTER_CONSUMER_SECRET: ${{ secrets.JRELEASER_TWITTER_CONSUMER_SECRET }} |
| 78 | + JRELEASER_TWITTER_ACCESS_TOKEN: ${{ secrets.JRELEASER_TWITTER_ACCESS_TOKEN }} |
| 79 | + JRELEASER_TWITTER_ACCESS_TOKEN_SECRET: ${{ secrets.JRELEASER_TWITTER_ACCESS_TOKEN_SECRET }} |
| 80 | + - name: Release Maven package |
| 81 | + uses: samuelmeuli/action-maven-publish@v1 |
| 82 | + with: |
| 83 | + gpg_private_key: ${{ secrets.gpg_private_key }} |
| 84 | + gpg_passphrase: ${{ secrets.gpg_passphrase }} |
| 85 | + nexus_username: ${{ secrets.nexus_username }} |
| 86 | + nexus_password: ${{ secrets.nexus_password }} |
| 87 | + - name: Set next version |
| 88 | + env: |
| 89 | + NEXT_VERSION: ${{ steps.version.outputs.NEXT_VERSION }} |
| 90 | + run: | |
| 91 | + ./mvnw -B versions:set versions:commit -DnewVersion=$NEXT_VERSION |
| 92 | + git config --global user.email "project.openubl.preview.bot@gmail.com" |
| 93 | + git config --global user.name "Project-Openubl Bot" |
| 94 | + git commit -a -m "⬆️ Next version $NEXT_VERSION" |
| 95 | + git push origin HEAD:master |
0 commit comments