|
| 1 | +# Licensed to the Apache Software Foundation (ASF) under one |
| 2 | +# or more contributor license agreements. See the NOTICE file |
| 3 | +# distributed with this work for additional information |
| 4 | +# regarding copyright ownership. The ASF licenses this file |
| 5 | +# to you under the Apache License, Version 2.0 (the |
| 6 | +# "License"); you may not use this file except in compliance |
| 7 | +# with the License. You may obtain a copy of the License at |
| 8 | +# |
| 9 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | +# |
| 11 | +# Unless required by applicable law or agreed to in writing, |
| 12 | +# software distributed under the License is distributed on an |
| 13 | +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 14 | +# KIND, either express or implied. See the License for the |
| 15 | +# specific language governing permissions and limitations |
| 16 | +# under the License. |
| 17 | + |
| 18 | +# This workflow will choose a commit to be the basis of a release candidate |
| 19 | +## and push a new tagged commit for that RC. |
| 20 | + |
| 21 | +# To learn more about GitHub Actions in Apache Beam check the CI.md |
| 22 | + |
| 23 | +name: Choose RC Commit |
| 24 | +on: |
| 25 | + workflow_dispatch: |
| 26 | + inputs: |
| 27 | + RELEASE: |
| 28 | + description: Beam version of current release (e.g. 2.XX.0) |
| 29 | + required: true |
| 30 | + RC: |
| 31 | + description: Integer RC version for the release (e.g. 3 for RC3) |
| 32 | + required: true |
| 33 | + COMMIT: |
| 34 | + description: Selected commit to create the release (should be full commit sha) |
| 35 | + required: true |
| 36 | + PUSH_TAG: |
| 37 | + description: Push tag (yes/no) |
| 38 | + required: false |
| 39 | + default: no |
| 40 | + OVERWRITE: |
| 41 | + description: Overwrite RC Tag (yes/no) |
| 42 | + required: false |
| 43 | + default: no |
| 44 | + DEBUG: |
| 45 | + description: Debug enabled (yes/no) |
| 46 | + required: false |
| 47 | + default: no |
| 48 | + |
| 49 | +jobs: |
| 50 | + choose_rc_commit: |
| 51 | + runs-on: [self-hosted, ubuntu-20.04] |
| 52 | + env: |
| 53 | + RC_TAG: v${{ github.event.inputs.RELEASE }}-RC${{ github.event.inputs.RC }} |
| 54 | + SCRIPT_DIR: ./release/src/main/scripts |
| 55 | + DEBUG: "" |
| 56 | + steps: |
| 57 | + - name: Check out code |
| 58 | + uses: actions/checkout@v3 |
| 59 | + with: |
| 60 | + ref: release-${{ github.event.inputs.RELEASE }} |
| 61 | + - name: Set git config |
| 62 | + run: | |
| 63 | + git config user.name $GITHUB_ACTOR |
| 64 | + git config user.email actions@"$RUNNER_NAME".local |
| 65 | + - name: Enable debugging |
| 66 | + if: ${{github.event.inputs.DEBUG == 'yes'}} |
| 67 | + run: | |
| 68 | + echo "DEBUG=--debug" >> $GITHUB_ENV |
| 69 | + - name: Set version and commit |
| 70 | + run: | |
| 71 | + bash "${SCRIPT_DIR}/set_version.sh" "${{ github.event.inputs.RELEASE }}" --release \ |
| 72 | + --git-add $DEBUG |
| 73 | + # suppress warning about detached HEAD: we want it detached so we do not edit the branch |
| 74 | + git checkout --quiet ${{ github.event.inputs.COMMIT }} |
| 75 | + git commit -m "Set version for ${{ github.event.inputs.RELEASE }} RC${{ github.event.inputs.RC }}" |
| 76 | + - name: Overwrite tag |
| 77 | + run: | |
| 78 | + if git rev-parse "$RC_TAG" >/dev/null 2>&1; then |
| 79 | + if [[ "${{ github.event.inputs.OVERWRITE }}" == yes ]]; then |
| 80 | + git push origin ":refs/tags/$RC_TAG" |
| 81 | + else |
| 82 | + echo "Tag $RC_TAG already exists. Either delete it manually or run with --overwrite. Do not overwrite if an RC has been built and shared!" |
| 83 | + exit 1 |
| 84 | + fi |
| 85 | + fi |
| 86 | + - name: Tag for Go SDK |
| 87 | + # Go Modules defined in sub directories need to have a prefixed tag |
| 88 | + # in order to get the matching version. |
| 89 | + # See BEAM-13119 for context. |
| 90 | + run: git tag -a "sdks/$RC_TAG" -m "Go SDK $RC_TAG" HEAD |
| 91 | + - name: Primary tag for the repo |
| 92 | + run: git tag -a -m "$RC_TAG" "$RC_TAG" HEAD |
| 93 | + - name: Push tag |
| 94 | + if: ${{github.event.inputs.PUSH_TAG == 'yes'}} |
| 95 | + run: | |
| 96 | + git push --follow-tags origin "sdks/$RC_TAG" |
| 97 | + git push --follow-tags origin "$RC_TAG" |
| 98 | +
|
0 commit comments