|
| 1 | +name: Prepare Release |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + bump: |
| 7 | + description: Semver part to bump when set_version is empty. |
| 8 | + required: true |
| 9 | + default: patch |
| 10 | + type: choice |
| 11 | + options: |
| 12 | + - patch |
| 13 | + - minor |
| 14 | + - major |
| 15 | + set_version: |
| 16 | + description: Exact X.Y.Z version to release instead of bumping. |
| 17 | + required: false |
| 18 | + type: string |
| 19 | + base_branch: |
| 20 | + description: Branch to open the release PR against. |
| 21 | + required: true |
| 22 | + default: dev |
| 23 | + type: string |
| 24 | + dry_run: |
| 25 | + description: Show the planned release PR changes without pushing. |
| 26 | + required: true |
| 27 | + default: false |
| 28 | + type: boolean |
| 29 | + |
| 30 | +permissions: |
| 31 | + contents: write |
| 32 | + pull-requests: write |
| 33 | + |
| 34 | +concurrency: |
| 35 | + group: prepare-release-${{ inputs.base_branch }} |
| 36 | + cancel-in-progress: false |
| 37 | + |
| 38 | +jobs: |
| 39 | + prepare-release: |
| 40 | + name: Prepare Release PR |
| 41 | + runs-on: ubuntu-latest |
| 42 | + |
| 43 | + steps: |
| 44 | + - name: Check out base branch |
| 45 | + uses: actions/checkout@v4 |
| 46 | + with: |
| 47 | + ref: ${{ inputs.base_branch }} |
| 48 | + fetch-depth: 0 |
| 49 | + |
| 50 | + - name: Set up Python |
| 51 | + uses: actions/setup-python@v5 |
| 52 | + with: |
| 53 | + python-version: "3.12" |
| 54 | + |
| 55 | + - name: Fetch release comparison refs |
| 56 | + run: | |
| 57 | + git fetch --tags origin |
| 58 | + git fetch --no-tags origin main:refs/remotes/origin/main |
| 59 | +
|
| 60 | + - name: Prepare version metadata |
| 61 | + id: version |
| 62 | + env: |
| 63 | + BUMP: ${{ inputs.bump }} |
| 64 | + SET_VERSION: ${{ inputs.set_version }} |
| 65 | + run: | |
| 66 | + if [ -n "$SET_VERSION" ]; then |
| 67 | + scripts/release/bump-version.sh --set-version "$SET_VERSION" --no-commit |
| 68 | + else |
| 69 | + scripts/release/bump-version.sh "$BUMP" --no-commit |
| 70 | + fi |
| 71 | + version="$(tr -d '[:space:]' < plugins/cad/VERSION)" |
| 72 | + echo "version=$version" >> "$GITHUB_OUTPUT" |
| 73 | +
|
| 74 | + - name: Check release metadata |
| 75 | + run: | |
| 76 | + scripts/release/check-version.sh --incremented-from origin/main |
| 77 | + latest_tag="$(git tag --list '[0-9]*.[0-9]*.[0-9]*' --sort=-version:refname | head -n 1 || true)" |
| 78 | + if [ -n "$latest_tag" ]; then |
| 79 | + scripts/release/check-version.sh --incremented-from "refs/tags/$latest_tag" |
| 80 | + fi |
| 81 | +
|
| 82 | + - name: Check dev symlink layout |
| 83 | + run: scripts/dev/setup-symlinks.sh --check |
| 84 | + |
| 85 | + - name: Show dry-run diff |
| 86 | + if: inputs.dry_run |
| 87 | + run: | |
| 88 | + git diff --stat |
| 89 | + git diff -- plugins/cad/VERSION AGENTS.md CONTRIBUTING.md scripts/README.md |
| 90 | +
|
| 91 | + - name: Create release pull request |
| 92 | + if: ${{ !inputs.dry_run }} |
| 93 | + env: |
| 94 | + GH_TOKEN: ${{ github.token }} |
| 95 | + BASE_BRANCH: ${{ inputs.base_branch }} |
| 96 | + VERSION: ${{ steps.version.outputs.version }} |
| 97 | + run: | |
| 98 | + branch="release/$VERSION" |
| 99 | + git config user.name "github-actions[bot]" |
| 100 | + git config user.email "41898282+github-actions[bot]@users.noreply.github.com" |
| 101 | + git checkout -B "$branch" |
| 102 | + git add -A |
| 103 | + if git diff --cached --quiet; then |
| 104 | + echo "No release metadata changes to commit." |
| 105 | + exit 0 |
| 106 | + fi |
| 107 | + git commit -m "Release $VERSION" |
| 108 | + git push --force-with-lease origin "$branch" |
| 109 | + if gh pr view "$branch" --repo "$GITHUB_REPOSITORY" >/dev/null 2>&1; then |
| 110 | + gh pr edit "$branch" \ |
| 111 | + --repo "$GITHUB_REPOSITORY" \ |
| 112 | + --title "Release $VERSION" \ |
| 113 | + --body "Bumps repo-owned release metadata to $VERSION. Merging this PR lets the production branch builder materialize generated outputs and the release-tag workflow create the GitHub tag and draft release." |
| 114 | + else |
| 115 | + gh pr create \ |
| 116 | + --repo "$GITHUB_REPOSITORY" \ |
| 117 | + --base "$BASE_BRANCH" \ |
| 118 | + --head "$branch" \ |
| 119 | + --title "Release $VERSION" \ |
| 120 | + --body "Bumps repo-owned release metadata to $VERSION. Merging this PR lets the production branch builder materialize generated outputs and the release-tag workflow create the GitHub tag and draft release." |
| 121 | + fi |
0 commit comments