Repository navigation
feat(release): document centralized release runtime #326
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Release PR | |
| on: | |
| push: | |
| branches: [staging] | |
| permissions: | |
| contents: read | |
| pull-requests: write | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| jobs: | |
| create-release-pr: | |
| name: Create | |
| runs-on: ubuntu-slim | |
| timeout-minutes: 10 | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| steps: | |
| - name: Check | |
| id: check-pr | |
| run: | | |
| set -euo pipefail | |
| EXISTING=$(gh pr list \ | |
| --repo "$GITHUB_REPOSITORY" \ | |
| --limit 1 \ | |
| --base main \ | |
| --head staging \ | |
| --state open \ | |
| --json number | jq 'length') | |
| echo "existing=$EXISTING" >> "$GITHUB_OUTPUT" | |
| - name: Create | |
| if: steps.check-pr.outputs.existing == '0' | |
| run: | | |
| DATE=$(date +%Y-%m-%d) | |
| BODY_FILE="$RUNNER_TEMP/release-pr.md" | |
| COMPARE_URL="repos/${GITHUB_REPOSITORY}/compare/main...staging" | |
| COMPARE_FILE="$RUNNER_TEMP/release-compare.json" | |
| gh api "$COMPARE_URL?per_page=100" > "$COMPARE_FILE" | |
| TOTAL_COMMITS=$(jq -r '.total_commits // 0' "$COMPARE_FILE") | |
| if [ "$TOTAL_COMMITS" -gt 100 ]; then | |
| LAST_PAGE=$(( (TOTAL_COMMITS + 99) / 100 )) | |
| gh api "$COMPARE_URL?per_page=100&page=$LAST_PAGE" > "$COMPARE_FILE" | |
| fi | |
| COMMITS=$(jq -r '.commits[] | "- \(.commit.message | split("\\n")[0]) (\(.sha[0:7]))"' "$COMPARE_FILE") | |
| if [ -z "$COMMITS" ]; then | |
| COMMITS='- No commits found since main.' | |
| fi | |
| if [ "$TOTAL_COMMITS" -eq 1 ]; then | |
| CHANGE_LABEL=change | |
| else | |
| CHANGE_LABEL=changes | |
| fi | |
| cat > "$BODY_FILE" <<EOF | |
| ## Environment promotion | |
| Promote the validated \`staging\` environment into \`main\`. | |
| This is a deployment-promotion PR, not the version-release PR. | |
| - **Source:** \`staging\` | |
| - **Target:** \`main\` | |
| - **Changes:** $TOTAL_COMMITS $CHANGE_LABEL | |
| - **Created:** $DATE | |
| ### Commit summary | |
| $COMMITS | |
| ### Validation | |
| - Required CI, test, security, and CodeQL checks must pass before merge. | |
| - Merge with **rebase** to preserve the linear Conventional Commit history. | |
| - After merge, Release Please opens a separate versioned release PR with the changelog. | |
| EOF | |
| gh pr create \ | |
| --repo "$GITHUB_REPOSITORY" \ | |
| --base main \ | |
| --head staging \ | |
| --title "Promote staging -> main ($DATE)" \ | |
| --body-file "$BODY_FILE" |