|
| 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 | + |
| 13 | +jobs: |
| 14 | + # Runs once for a patch series to any given minor version to create the initial release branch. Subsequent patches |
| 15 | + # will be applied to the existing release branch. |
| 16 | + prepare-release-branch: |
| 17 | + runs-on: ubuntu-latest |
| 18 | + outputs: |
| 19 | + release-branch-name: ${{ steps.parse-release-branch.outputs.release-branch-name }} |
| 20 | + steps: |
| 21 | + - id: parse-release-branch |
| 22 | + name: Parse release branch name |
| 23 | + run: | |
| 24 | + # Sets the release-branch-name output to the version number with the last non-period element replaced with an 'x' and preprended with v. |
| 25 | + echo "::set-output name=release-branch-name::$(echo '${{ github.event.inputs.version }}' | sed -E 's/([^.]+)\.([^.]+)\.([^.]+)/v\1.\2.x/')" |
| 26 | + # Sets the release-tag-name output to the version number with the last non-period element replace with a '0' and prepended with v |
| 27 | + echo "::set-output name=release-tag-name::$(echo '${{ github.event.inputs.version }}' | sed -E 's/([^.]+)\.([^.]+)\.([^.]+)/v\1.\2.0/')" |
| 28 | + - id: checkout-release-branch |
| 29 | + name: Check out release branch |
| 30 | + # Will fail if there is no release branch yet or succeed otherwise |
| 31 | + continue-on-error: true |
| 32 | + uses: actions/checkout@v2 |
| 33 | + with: |
| 34 | + ref: ${{ steps.parse-release-branch.outputs.release-branch-name }} |
| 35 | + - id: checkout-release-tag |
| 36 | + name: Check out release tag |
| 37 | + # If there is already a release branch, the previous step succeeds and we don't run this or the next one. |
| 38 | + if: ${{ steps.checkout-release-branch.outcome == 'failure' }} |
| 39 | + uses: actions/checkout@v2 |
| 40 | + with: |
| 41 | + ref: ${{ steps.parse-release-branch.outputs.release-tag-name }} |
| 42 | + - name: Create release branch |
| 43 | + if: ${{ steps.checkout-release-tag.outcome == 'success' }} |
| 44 | + run: | |
| 45 | + git checkout -b ${{ steps.parse-release-branch.outputs.release-branch-name }} |
| 46 | + git push --set-upstream origin ${{ steps.parse-release-branch.outputs.release-branch-name }} |
| 47 | + build: |
| 48 | + runs-on: ubuntu-latest |
| 49 | + needs: prepare-release-branch |
| 50 | + steps: |
| 51 | + - name: Checkout release branch |
| 52 | + uses: actions/checkout@v2 |
| 53 | + with: |
| 54 | + ref: ${{ needs.prepare-release-branch.outputs.release-branch-name }} |
| 55 | + |
| 56 | + - uses: actions/setup-java@v1 |
| 57 | + with: |
| 58 | + java-version: 14 |
| 59 | + |
| 60 | + - name: Setup git name |
| 61 | + run: | |
| 62 | + git config user.name github-actions |
| 63 | + git config user.email [email protected] |
| 64 | +
|
| 65 | + - name: Cherrypicks |
| 66 | + if: ${{ github.event.inputs.commits != '' }} |
| 67 | + run: | |
| 68 | + git fetch origin master |
| 69 | + echo ${{ github.event.inputs.commits }} | sed -n 1'p' | tr ',' '\n' | while read word; do |
| 70 | + # Trim whitespaces and cherrypick |
| 71 | + echo $word | sed 's/ *$//g' | sed 's/^ *//g' | git cherry-pick --stdin |
| 72 | + done |
| 73 | +
|
| 74 | + - name: Build release with Gradle |
| 75 | + uses: burrunan/gradle-cache-action@v1 |
| 76 | + with: |
| 77 | + arguments: build jibDockerBuild final -Prelease.version=${{ github.event.inputs.version }} --stacktrace |
| 78 | + env: |
| 79 | + PUBLISH_USERNAME: ${{ github.actor }} |
| 80 | + PUBLISH_PASSWORD: ${{ secrets.GITHUB_TOKEN }} |
| 81 | + GRGIT_USER: ${{ github.actor }} |
| 82 | + GRGIT_PASS: ${{ secrets.GITHUB_TOKEN }} |
| 83 | + AWS_REGISTRY_ACCOUNT: ${{ secrets.AWS_ACCOUNT }} |
| 84 | + COMMIT_HASH: ${{ github.event.inputs.version }} |
| 85 | + |
| 86 | + - name: Configure AWS credentials |
| 87 | + uses: aws-actions/configure-aws-credentials@v1 |
| 88 | + with: |
| 89 | + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} |
| 90 | + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} |
| 91 | + aws-region: us-west-2 |
| 92 | + |
| 93 | + - name: Login to Amazon ECR |
| 94 | + id: login-ecr |
| 95 | + uses: aws-actions/amazon-ecr-login@v1 |
| 96 | + |
| 97 | + - name: Push image to Amazon ECR |
| 98 | + env: |
| 99 | + ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} |
| 100 | + run: | |
| 101 | + docker images |
| 102 | + docker push $ECR_REGISTRY/springboot:${{ github.event.inputs.version }} |
| 103 | + docker push $ECR_REGISTRY/spark:${{ github.event.inputs.version }} |
| 104 | +
|
| 105 | + - name: Create Release |
| 106 | + id: create_release |
| 107 | + uses: actions/create-release@v1 |
| 108 | + env: |
| 109 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 110 | + with: |
| 111 | + tag_name: v${{ github.event.inputs.version }} |
| 112 | + release_name: Release v${{ github.event.inputs.version }} |
| 113 | + draft: true |
| 114 | + prerelease: false |
| 115 | + |
| 116 | + - name: Upload Release Asset |
| 117 | + id: upload-release-asset |
| 118 | + uses: actions/upload-release-asset@v1 |
| 119 | + env: |
| 120 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 121 | + with: |
| 122 | + upload_url: ${{ steps.create_release.outputs.upload_url }} |
| 123 | + asset_path: otelagent/build/libs/aws-opentelemetry-agent-${{ github.event.inputs.version }}.jar |
| 124 | + asset_name: aws-opentelemetry-agent.jar |
| 125 | + asset_content_type: application/java-archive |
0 commit comments