|
| 1 | +--- |
| 2 | +description: Merge a PR and release it to production |
| 3 | +argument-hint: [pr-number] |
| 4 | +allowed-tools: Bash(gh pr checks:*), Bash(gh pr view:*), Bash(gh pr merge:*), Bash(gh run list:*), Bash(gh run view:*), Bash(gh run watch:*), Bash(gh release list:*), Bash(gh release view:*), Bash(gh release edit:*) |
| 5 | +--- |
| 6 | + |
| 7 | +## PR to release |
| 8 | + |
| 9 | +PR number: $ARGUMENTS |
| 10 | + |
| 11 | +## Step 1: Wait for PR checks to pass |
| 12 | + |
| 13 | +Poll until all checks on the PR succeed: |
| 14 | + |
| 15 | +```bash |
| 16 | +gh pr checks $ARGUMENTS --watch --interval 30 |
| 17 | +``` |
| 18 | + |
| 19 | +If any check fails, stop and report the failure to the user. Do not proceed. |
| 20 | + |
| 21 | +## Step 2: Merge the PR |
| 22 | + |
| 23 | +Merge the PR using a merge commit: |
| 24 | + |
| 25 | +```bash |
| 26 | +gh pr merge $ARGUMENTS --merge --delete-branch |
| 27 | +``` |
| 28 | + |
| 29 | +## Step 3: Wait for main branch CI to complete |
| 30 | + |
| 31 | +After merging, the CI workflow runs on `main`. Find the run triggered by the merge and wait for it: |
| 32 | + |
| 33 | +```bash |
| 34 | +gh run list --branch main --workflow ci.yml --limit 1 --json databaseId,status |
| 35 | +``` |
| 36 | + |
| 37 | +Wait a few seconds if the run hasn't appeared yet, then watch it: |
| 38 | + |
| 39 | +```bash |
| 40 | +gh run watch <run-id> --interval 30 |
| 41 | +``` |
| 42 | + |
| 43 | +The `update-release-draft` job at the end of CI creates or updates the draft release. If any job on `main` fails, stop and report to the user. |
| 44 | + |
| 45 | +## Step 4: Find the draft release |
| 46 | + |
| 47 | +List recent releases to find the draft that was just updated: |
| 48 | + |
| 49 | +```bash |
| 50 | +gh release list --limit 5 --json tagName,name,isDraft |
| 51 | +``` |
| 52 | + |
| 53 | +Identify the draft release (isDraft: true). Confirm its name with the user before publishing. |
| 54 | + |
| 55 | +## Step 5: Publish the draft release |
| 56 | + |
| 57 | +```bash |
| 58 | +gh release edit <tag> --draft=false |
| 59 | +``` |
| 60 | + |
| 61 | +## Step 6: Wait for the release workflow to complete |
| 62 | + |
| 63 | +After publishing, the release workflow runs. Find and watch it: |
| 64 | + |
| 65 | +```bash |
| 66 | +gh run list --workflow release.yml --limit 1 --json databaseId,status |
| 67 | +``` |
| 68 | + |
| 69 | +```bash |
| 70 | +gh run watch <run-id> --interval 30 |
| 71 | +``` |
| 72 | + |
| 73 | +Once complete, report success to the user with the release name and a summary of what was released. |
0 commit comments