|
| 1 | +--- |
| 2 | +name: Pre/Post Release |
| 3 | + |
| 4 | +on: |
| 5 | + workflow_call: |
| 6 | + ref: |
| 7 | + description: 'Branch or tag ref to run the workflow on' |
| 8 | + required: true |
| 9 | + default: 'main' |
| 10 | + version: |
| 11 | + description: 'The version to release (e.g. 1.2.3). This workflow will automatically perform the required version bumps' |
| 12 | + required: true |
| 13 | + phase: |
| 14 | + description: 'Pre or post release phase' |
| 15 | + type: choice |
| 16 | + options: |
| 17 | + - pre |
| 18 | + - post |
| 19 | + required: true |
| 20 | + |
| 21 | +env: |
| 22 | + RELEASE_VERSION: ${{ inputs.version }} |
| 23 | + BRANCH_NAME: ${{ inputs.phase }}-release-v${{ inputs.version }} |
| 24 | + |
| 25 | +permissions: |
| 26 | + contents: read |
| 27 | + |
| 28 | +concurrency: |
| 29 | + group: ${{ github.workflow }} |
| 30 | + |
| 31 | +jobs: |
| 32 | + validate-tag: |
| 33 | + runs-on: ubuntu-latest |
| 34 | + steps: |
| 35 | + - name: Checkout |
| 36 | + uses: actions/checkout@v4 |
| 37 | + with: |
| 38 | + fetch-depth: 0 |
| 39 | + - name: Validate tag does not exist on current commit |
| 40 | + uses: ./.github/workflows/validate-tag |
| 41 | + with: |
| 42 | + tag: v${{ env.RELEASE_VERSION }} |
| 43 | + |
| 44 | + create-pr: |
| 45 | + name: "Bump versions and create PR" |
| 46 | + runs-on: ubuntu-latest |
| 47 | + needs: |
| 48 | + - validate-tag |
| 49 | + permissions: |
| 50 | + contents: write |
| 51 | + steps: |
| 52 | + - uses: elastic/apm-pipeline-library/.github/actions/github-token@current |
| 53 | + with: |
| 54 | + url: ${{ secrets.VAULT_ADDR }} |
| 55 | + roleId: ${{ secrets.VAULT_ROLE_ID }} |
| 56 | + secretId: ${{ secrets.VAULT_SECRET_ID }} |
| 57 | + |
| 58 | + - uses: elastic/apm-pipeline-library/.github/actions/setup-git@current |
| 59 | + with: |
| 60 | + username: ${{ env.GIT_USER }} |
| 61 | + email: ${{ env.GIT_EMAIL }} |
| 62 | + token: ${{ env.GITHUB_TOKEN }} |
| 63 | + |
| 64 | + - uses: actions/checkout@v4 |
| 65 | + with: |
| 66 | + ref: ${{ inputs.ref }} |
| 67 | + token: ${{ env.GITHUB_TOKEN }} |
| 68 | + |
| 69 | + - name: Create the release tag (post phase) |
| 70 | + if: inputs.phase == 'post' |
| 71 | + run: | |
| 72 | + git tag "v${{ env.RELEASE_VERSION }}" |
| 73 | + git push origin "v${{ env.RELEASE_VERSION }}" |
| 74 | +
|
| 75 | + - name: Create a ${{ inputs.phase }} release branch |
| 76 | + run: git checkout -b ${{ env.BRANCH_NAME }} |
| 77 | + |
| 78 | + - name: Set release version (pre release) |
| 79 | + if: inputs.phase == 'pre' |
| 80 | + uses: ./.github/workflows/maven-goal |
| 81 | + with: |
| 82 | + command: ./mvnw -V versions:set -DprocessAllModules=true -DgenerateBackupPoms=false -DnewVersion=${{ env.RELEASE_VERSION }} |
| 83 | + |
| 84 | + - name: Set next snapshot version (post release) |
| 85 | + if: inputs.phase == 'post' |
| 86 | + uses: ./.github/workflows/maven-goal |
| 87 | + with: |
| 88 | + command: ./mvnw -V versions:set -DprocessAllModules=true -DgenerateBackupPoms=false -nextSnapshot=true |
| 89 | + |
| 90 | + - name: Push the ${{ inputs.phase }} release branch |
| 91 | + run: | |
| 92 | + git add --all |
| 93 | + git commit -m "${{ inputs.phase }} release: ecs-logging-java v${{ env.RELEASE_VERSION }}" |
| 94 | + git push origin ${{ env.BRANCH_NAME }} |
| 95 | +
|
| 96 | + - name: Create the ${{ inputs.phase }} release PR |
| 97 | + run: gh pr create --title="${{ inputs.phase }} release v${{ env.RELEASE_VERSION }}" --base main --head ${{ env.BRANCH_NAME }} -b "${{ inputs.phase }} release v${{ env.RELEASE_VERSION }}" |
0 commit comments