|
| 1 | +# Copyright 2026 "Google LLC" |
| 2 | +# |
| 3 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +# you may not use this file except in compliance with the License. |
| 5 | +# You may obtain a copy of the License at |
| 6 | +# |
| 7 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +# |
| 9 | +# Unless required by applicable law or agreed to in writing, software |
| 10 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +# See the License for the specific language governing permissions and |
| 13 | +# limitations under the License. |
| 14 | + |
| 15 | +name: Publish CTK Release |
| 16 | + |
| 17 | +on: |
| 18 | + pull_request: |
| 19 | + types: |
| 20 | + - closed |
| 21 | + branches: |
| 22 | + - main |
| 23 | + |
| 24 | +permissions: |
| 25 | + contents: write |
| 26 | + discussions: write |
| 27 | + |
| 28 | +jobs: |
| 29 | + publish-release: |
| 30 | + if: > |
| 31 | + github.event.pull_request.merged == true && |
| 32 | + ( |
| 33 | + startsWith(github.event.pull_request.head.ref, 'release-candidate-') || |
| 34 | + startsWith(github.event.pull_request.head.ref, 'hotfix-') |
| 35 | + ) |
| 36 | +
|
| 37 | + runs-on: ubuntu-latest |
| 38 | + |
| 39 | + steps: |
| 40 | + - name: Checkout Repository |
| 41 | + uses: actions/checkout@v4 |
| 42 | + with: |
| 43 | + fetch-depth: 0 |
| 44 | + |
| 45 | + - name: Get Release Version |
| 46 | + id: release |
| 47 | + shell: bash |
| 48 | + run: | |
| 49 | + RC_BRANCH="${{ github.event.pull_request.head.ref }}" |
| 50 | +
|
| 51 | + if [[ "$RC_BRANCH" == release-candidate-* ]]; then |
| 52 | + VERSION="${RC_BRANCH#release-candidate-}" |
| 53 | + elif [[ "$RC_BRANCH" == hotfix-* ]]; then |
| 54 | + VERSION="${RC_BRANCH#hotfix-}" |
| 55 | + else |
| 56 | + echo "Unsupported branch: $RC_BRANCH" |
| 57 | + exit 1 |
| 58 | + fi |
| 59 | +
|
| 60 | + echo "rc_branch=$RC_BRANCH" >> "$GITHUB_OUTPUT" |
| 61 | + echo "version=$VERSION" >> "$GITHUB_OUTPUT" |
| 62 | +
|
| 63 | + - name: Create Tag |
| 64 | + run: | |
| 65 | + git config user.name "github-actions" |
| 66 | + git config user.email "github-actions@github.com" |
| 67 | +
|
| 68 | + if git rev-parse "${{ steps.release.outputs.version }}" >/dev/null 2>&1; then |
| 69 | + echo "Tag already exists" |
| 70 | + else |
| 71 | + git tag "${{ steps.release.outputs.version }}" |
| 72 | + git push origin "${{ steps.release.outputs.version }}" |
| 73 | + fi |
| 74 | +
|
| 75 | + - name: Publish GitHub Release |
| 76 | + uses: softprops/action-gh-release@v2 |
| 77 | + with: |
| 78 | + tag_name: ${{ steps.release.outputs.version }} |
| 79 | + target_commitish: ${{ github.event.pull_request.merge_commit_sha }} |
| 80 | + name: ${{ steps.release.outputs.version }} |
| 81 | + generate_release_notes: true |
| 82 | + make_latest: true |
| 83 | + discussion_category_name: Announcements |
| 84 | + env: |
| 85 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments