|
| 1 | +name: Backfill Release Announcement |
| 2 | +run-name: Backfill from ${{ inputs.since_tag || 'r3_11_0' }}${{ inputs.dry_run == 'true' && ' (dry run)' || '' }} |
| 3 | + |
| 4 | +# This workflow runs the release_announcement Python package to populate |
| 5 | +# ReleaseAnnouncement.md with every merged PR since a given release tag. |
| 6 | +# |
| 7 | +# Trigger it once after a release tag is cut (e.g. r3_11_0) and this workflow |
| 8 | +# file is merged to main. It processes PRs in chronological order, calling |
| 9 | +# the GitHub Models API (openai/gpt-4o) for each one so the announcement builds |
| 10 | +# up exactly as it would have done if the per-PR workflow had been running all |
| 11 | +# along. |
| 12 | +# |
| 13 | +# The script commits one separate commit per PR that produced a user-relevant |
| 14 | +# change, then those commits are pushed back to the branch for review via PR. |
| 15 | +# Run this workflow from a non-main branch; the push step will update that branch. |
| 16 | + |
| 17 | +on: |
| 18 | + workflow_dispatch: |
| 19 | + inputs: |
| 20 | + since_tag: |
| 21 | + description: >- |
| 22 | + **Git release tag** to backfill from. |
| 23 | + PRs merged *after* this tag will be processed. |
| 24 | + (default: r3_11_0) |
| 25 | + required: false |
| 26 | + default: 'r3_11_0' |
| 27 | + dry_run: |
| 28 | + description: >- |
| 29 | + **Dry run**: commit changes locally but do not push; attach |
| 30 | + ReleaseAnnouncement.md as a workflow artifact for review. |
| 31 | + required: false |
| 32 | + default: 'false' |
| 33 | + type: choice |
| 34 | + options: |
| 35 | + - 'false' |
| 36 | + - 'true' |
| 37 | + allow_repo_override: |
| 38 | + description: >- |
| 39 | + **Allow non-jamulussoftware repositories**: set to 'true' to run this workflow |
| 40 | + outside the canonical repository owner. |
| 41 | + required: false |
| 42 | + default: 'false' |
| 43 | + type: choice |
| 44 | + options: |
| 45 | + - 'false' |
| 46 | + - 'true' |
| 47 | + |
| 48 | +permissions: {} |
| 49 | + |
| 50 | +jobs: |
| 51 | + backfill: |
| 52 | + name: Backfill release announcement |
| 53 | + # Default safety behavior limits execution to the canonical owner. |
| 54 | + # Set workflow_dispatch input allow_repo_override=true to bypass this. |
| 55 | + if: github.repository_owner == 'jamulussoftware' || inputs.allow_repo_override == 'true' |
| 56 | + runs-on: ubuntu-latest |
| 57 | + env: |
| 58 | + SINCE_TAG: ${{ inputs.since_tag || 'r3_11_0' }} |
| 59 | + DRY_RUN: ${{ inputs.dry_run || 'false' }} |
| 60 | + permissions: |
| 61 | + contents: write |
| 62 | + models: read |
| 63 | + |
| 64 | + steps: |
| 65 | + - name: Refuse to run on main |
| 66 | + if: github.ref == 'refs/heads/main' |
| 67 | + run: | |
| 68 | + echo "::error::Backfill must not run directly on main. Trigger this workflow from a non-main branch and merge via PR." |
| 69 | + exit 1 |
| 70 | +
|
| 71 | + - uses: actions/checkout@v6 |
| 72 | + with: |
| 73 | + fetch-depth: 0 |
| 74 | + |
| 75 | + - name: Fetch tags |
| 76 | + run: | |
| 77 | + git fetch --force --tags "https://github.com/${{ github.repository }}.git" |
| 78 | +
|
| 79 | + - name: Configure git identity |
| 80 | + run: | |
| 81 | + git config user.email "41898282+github-actions[bot]@users.noreply.github.com" |
| 82 | + git config user.name "github-actions[bot]" |
| 83 | +
|
| 84 | + - name: Install release announcement package |
| 85 | + run: | |
| 86 | + python3 -m pip install --user ./tools/release_announcement |
| 87 | +
|
| 88 | + - name: Record baseline commit |
| 89 | + id: baseline |
| 90 | + run: | |
| 91 | + echo "commit=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT" |
| 92 | +
|
| 93 | + - name: Run backfill script |
| 94 | + env: |
| 95 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 96 | + run: | |
| 97 | + DRY_RUN_FLAG="" |
| 98 | + [[ "$DRY_RUN" == "true" ]] && DRY_RUN_FLAG="--dry-run" |
| 99 | + python3 -m release_announcement \ |
| 100 | + "$SINCE_TAG" \ |
| 101 | + "HEAD" \ |
| 102 | + --file ReleaseAnnouncement.md \ |
| 103 | + --backend actions \ |
| 104 | + --delay-secs 5 \ |
| 105 | + $DRY_RUN_FLAG |
| 106 | +
|
| 107 | + - name: Check if backfill created commits |
| 108 | + id: check-updated |
| 109 | + run: | |
| 110 | + current_commit=$(git rev-parse HEAD) |
| 111 | + if [[ "$current_commit" == "${{ steps.baseline.outputs.commit }}" ]]; then |
| 112 | + echo "updated=false" >> "$GITHUB_OUTPUT" |
| 113 | + else |
| 114 | + echo "updated=true" >> "$GITHUB_OUTPUT" |
| 115 | + fi |
| 116 | +
|
| 117 | + - name: Push commits |
| 118 | + if: env.DRY_RUN != 'true' |
| 119 | + env: |
| 120 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 121 | + run: | |
| 122 | + git push |
| 123 | +
|
| 124 | + - name: Upload updated announcement |
| 125 | + if: steps.check-updated.outputs.updated == 'true' |
| 126 | + uses: actions/upload-artifact@v7 |
| 127 | + with: |
| 128 | + name: ReleaseAnnouncement-updated |
| 129 | + path: ReleaseAnnouncement.md |
| 130 | + |
0 commit comments