|
12 | 12 | # See the License for the specific language governing permissions and |
13 | 13 | # limitations under the License. |
14 | 14 |
|
15 | | -# Step 1: Starts the release process by creating a release/candidate branch. |
16 | | -# Generates a changelog PR for review (step 2). |
| 15 | +# Unified release manager. Supports: |
| 16 | +# 1. Cutting a new release candidate branch from main or v1. |
| 17 | +# 2. Regenerating/updating the changelog PR on an existing candidate branch. |
17 | 18 | name: "Release: Cut" |
18 | 19 |
|
19 | 20 | on: |
20 | 21 | workflow_dispatch: |
21 | 22 | inputs: |
| 23 | + action: |
| 24 | + description: 'Action to perform' |
| 25 | + required: true |
| 26 | + default: 'cut' |
| 27 | + type: choice |
| 28 | + options: |
| 29 | + - cut |
| 30 | + - regenerate |
| 31 | + branch: |
| 32 | + description: 'Branch to release from (main or v1)' |
| 33 | + required: true |
| 34 | + default: 'main' |
| 35 | + type: choice |
| 36 | + options: |
| 37 | + - main |
| 38 | + - v1 |
22 | 39 | commit_sha: |
23 | | - description: 'Commit SHA to cut from (leave empty for latest main)' |
| 40 | + description: 'Optional Commit SHA (only used for "cut" action; overrides branch latest)' |
24 | 41 | required: false |
25 | 42 | type: string |
26 | 43 |
|
27 | 44 | permissions: |
28 | 45 | contents: write |
29 | | - actions: write |
| 46 | + pull-requests: write |
30 | 47 |
|
31 | 48 | jobs: |
32 | | - cut-release: |
| 49 | + cut-or-regenerate: |
33 | 50 | runs-on: ubuntu-latest |
34 | 51 | steps: |
35 | | - - uses: actions/checkout@v6 |
| 52 | + - name: Determine Branch Configurations |
| 53 | + id: config |
| 54 | + run: | |
| 55 | + BRANCH="${{ inputs.branch }}" |
| 56 | + if [ "$BRANCH" = "v1" ]; then |
| 57 | + echo "base_ref=v1" >> $GITHUB_OUTPUT |
| 58 | + echo "candidate_branch=release/v1-candidate" >> $GITHUB_OUTPUT |
| 59 | + echo "config_file=.github/release-please-config-v1.json" >> $GITHUB_OUTPUT |
| 60 | + echo "manifest_file=.github/.release-please-manifest-v1.json" >> $GITHUB_OUTPUT |
| 61 | + else |
| 62 | + echo "base_ref=main" >> $GITHUB_OUTPUT |
| 63 | + echo "candidate_branch=release/candidate" >> $GITHUB_OUTPUT |
| 64 | + echo "config_file=.github/release-please-config.json" >> $GITHUB_OUTPUT |
| 65 | + echo "manifest_file=.github/.release-please-manifest.json" >> $GITHUB_OUTPUT |
| 66 | + fi |
| 67 | +
|
| 68 | + # Action: CUT NEW RELEASE |
| 69 | + - name: Checkout base ref (Cut) |
| 70 | + if: inputs.action == 'cut' |
| 71 | + uses: actions/checkout@v6 |
36 | 72 | with: |
37 | | - ref: ${{ inputs.commit_sha || 'main' }} |
| 73 | + ref: ${{ inputs.commit_sha || steps.config.outputs.base_ref }} |
| 74 | + token: ${{ secrets.RELEASE_PAT }} |
38 | 75 |
|
39 | | - - name: Check for existing release/candidate branch |
40 | | - env: |
41 | | - GH_TOKEN: ${{ github.token }} |
| 76 | + - name: Check for existing candidate branch (Cut) |
| 77 | + if: inputs.action == 'cut' |
42 | 78 | run: | |
43 | | - if git ls-remote --exit-code --heads origin release/candidate &>/dev/null; then |
44 | | - echo "Error: release/candidate branch already exists" |
45 | | - echo "Please finalize or delete the existing release candidate before starting a new one" |
| 79 | + CANDIDATE_BRANCH="${{ steps.config.outputs.candidate_branch }}" |
| 80 | + if git ls-remote --exit-code --heads origin "$CANDIDATE_BRANCH" &>/dev/null; then |
| 81 | + echo "Error: Branch $CANDIDATE_BRANCH already exists." |
| 82 | + echo "Please finalize or delete the existing release candidate before starting a new one." |
46 | 83 | exit 1 |
47 | 84 | fi |
48 | 85 |
|
49 | | - - name: Create and push release/candidate branch |
| 86 | + - name: Create and push candidate branch (Cut) |
| 87 | + if: inputs.action == 'cut' |
50 | 88 | run: | |
51 | | - git checkout -b release/candidate |
52 | | - git push origin release/candidate |
53 | | - echo "Created branch: release/candidate" |
| 89 | + CANDIDATE_BRANCH="${{ steps.config.outputs.candidate_branch }}" |
| 90 | + git checkout -b "$CANDIDATE_BRANCH" |
| 91 | + git push origin "$CANDIDATE_BRANCH" |
| 92 | + echo "Created and pushed branch: $CANDIDATE_BRANCH" |
54 | 93 |
|
55 | | - - name: Trigger Release Please |
56 | | - env: |
57 | | - GH_TOKEN: ${{ github.token }} |
58 | | - run: | |
59 | | - gh workflow run release-please.yml --repo ${{ github.repository }} --ref release/candidate |
60 | | - echo "Triggered Release Please workflow" |
| 94 | + # Action: REGENERATE EXISTING PR |
| 95 | + - name: Checkout existing candidate branch (Regenerate) |
| 96 | + if: inputs.action == 'regenerate' |
| 97 | + uses: actions/checkout@v6 |
| 98 | + with: |
| 99 | + ref: ${{ steps.config.outputs.candidate_branch }} |
| 100 | + token: ${{ secrets.RELEASE_PAT }} |
| 101 | + |
| 102 | + # Run Release Please |
| 103 | + - name: Run Release Please |
| 104 | + uses: googleapis/release-please-action@v4 |
| 105 | + with: |
| 106 | + token: ${{ secrets.RELEASE_PAT }} |
| 107 | + config-file: ${{ steps.config.outputs.config_file }} |
| 108 | + manifest-file: ${{ steps.config.outputs.manifest_file }} |
| 109 | + target-branch: ${{ steps.config.outputs.candidate_branch }} |
0 commit comments