|
| 1 | +# Releases a patch by cherrypicking commits into a release branch based on the previous |
| 2 | +# release tag. |
| 3 | +name: Patch Release Build |
| 4 | +on: |
| 5 | + workflow_dispatch: |
| 6 | + inputs: |
| 7 | + version: |
| 8 | + description: The version to tag the release with, e.g., 1.2.1, 1.2.2 |
| 9 | + required: true |
| 10 | + commits: |
| 11 | + description: Comma separated list of commit shas to cherrypick |
| 12 | + required: false |
| 13 | + |
| 14 | +jobs: |
| 15 | + prepare-release-branch: |
| 16 | + runs-on: ubuntu-latest |
| 17 | + outputs: |
| 18 | + release-branch-name: ${{ steps.parse-release-branch.outputs.release-branch-name }} |
| 19 | + steps: |
| 20 | + - id: parse-release-branch |
| 21 | + name: Parse release branch name |
| 22 | + run: | |
| 23 | + # Sets the release-branch-name output to the version number with the last non-period element replaced with an 'x' and preprended with v. |
| 24 | + echo "::set-output name=release-branch-name::$(echo '${{ github.event.inputs.version }}' | sed -E 's/([^.]+)\.([^.]+)\.([^.]+)/v\1.\2.x/')" |
| 25 | + # Sets the release-tag-name output to the version number with the last non-period element replace with a '0' and prepended with v |
| 26 | + echo "::set-output name=release-tag-name::$(echo '${{ github.event.inputs.version }}' | sed -E 's/([^.]+)\.([^.]+)\.([^.]+)/v\1.\2.0/')" |
| 27 | +
|
| 28 | + - id: checkout-release-branch |
| 29 | + name: Check out release branch |
| 30 | + continue-on-error: true |
| 31 | + |
| 32 | + with: |
| 33 | + ref: ${{ steps.parse-release-branch.outputs.release-branch-name }} |
| 34 | + fetch-depth: 0 |
| 35 | + |
| 36 | + - id: checkout-release-tag |
| 37 | + name: Check out release tag |
| 38 | + if: ${{ steps.checkout-release-branch.outcome == 'failure' }} |
| 39 | + |
| 40 | + with: |
| 41 | + ref: ${{ steps.parse-release-branch.outputs.release-tag-name }} |
| 42 | + fetch-depth: 0 |
| 43 | + |
| 44 | + - name: Create release branch |
| 45 | + if: ${{ steps.checkout-release-tag.outcome == 'success' }} |
| 46 | + run: | |
| 47 | + git checkout -b ${{ steps.parse-release-branch.outputs.release-branch-name }} |
| 48 | + git push --set-upstream origin ${{ steps.parse-release-branch.outputs.release-branch-name }} |
| 49 | +
|
| 50 | + build: |
| 51 | + name: build |
| 52 | + needs: prepare-release-branch |
| 53 | + runs-on: ubuntu-latest |
| 54 | + steps: |
| 55 | + - uses: actions/checkout@v2 |
| 56 | + with: |
| 57 | + fetch-depth: 0 |
| 58 | + - name: Setup Java 11 |
| 59 | + uses: actions/setup-java@v2 |
| 60 | + with: |
| 61 | + distribution: adopt |
| 62 | + java-version: 11 |
| 63 | + - uses: burrunan/gradle-cache-action@v1 |
| 64 | + name: Build |
| 65 | + with: |
| 66 | + arguments: --stacktrace build |
| 67 | + remote-build-cache-proxy-enabled: false |
| 68 | + - uses: actions/upload-artifact@v2 |
| 69 | + name: Save unit test results |
| 70 | + if: always() |
| 71 | + with: |
| 72 | + name: test-results |
| 73 | + path: jmx-metrics/build/reports/tests/test |
| 74 | + integration-test: |
| 75 | + name: integration-test |
| 76 | + needs: prepare-release-branch |
| 77 | + runs-on: ubuntu-latest |
| 78 | + steps: |
| 79 | + - uses: actions/checkout@v2 |
| 80 | + with: |
| 81 | + fetch-depth: 0 |
| 82 | + - name: Setup Java 11 |
| 83 | + uses: actions/setup-java@v2 |
| 84 | + with: |
| 85 | + distribution: adopt |
| 86 | + java-version: 11 |
| 87 | + - uses: burrunan/gradle-cache-action@v1 |
| 88 | + name: Integration Tests |
| 89 | + with: |
| 90 | + arguments: --stacktrace integrationTest |
| 91 | + remote-build-cache-proxy-enabled: false |
| 92 | + - uses: actions/upload-artifact@v2 |
| 93 | + name: Save integrationTest results |
| 94 | + if: always() |
| 95 | + with: |
| 96 | + name: integration-test-results |
| 97 | + path: jmx-metrics/build/reports/tests/test |
| 98 | + publish: |
| 99 | + name: publish |
| 100 | + runs-on: ubuntu-latest |
| 101 | + needs: [ build, integration-test ] |
| 102 | + steps: |
| 103 | + - uses: actions/checkout@v2 |
| 104 | + with: |
| 105 | + fetch-depth: 0 |
| 106 | + - name: Setup Java 11 |
| 107 | + uses: actions/setup-java@v2 |
| 108 | + with: |
| 109 | + distribution: adopt |
| 110 | + java-version: 11 |
| 111 | + - uses: burrunan/gradle-cache-action@v1 |
| 112 | + name: Publish |
| 113 | + with: |
| 114 | + arguments: --stacktrace final closeAndReleaseSonatypeStagingRepository -Prelease.version=${{ github.event.inputs.version }} |
| 115 | + env: |
| 116 | + SONATYPE_USER: ${{ secrets.SONATYPE_USER }} |
| 117 | + SONATYPE_KEY: ${{ secrets.SONATYPE_KEY }} |
| 118 | + GRGIT_USER: ${{ github.actor }} |
| 119 | + GRGIT_PASS: ${{ secrets.GITHUB_TOKEN }} |
| 120 | + GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }} |
| 121 | + GPG_PASSWORD: ${{ secrets.GPG_PASSWORD }} |
| 122 | + - name: Create Release |
| 123 | + id: create_release |
| 124 | + |
| 125 | + env: |
| 126 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 127 | + with: |
| 128 | + tag_name: v${{ github.event.inputs.version }} |
| 129 | + release_name: Release v${{ github.event.inputs.version }} |
| 130 | + draft: true |
| 131 | + prerelease: false |
0 commit comments