Repository navigation
Release automatically on successful main CI with patch bumps #38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
8a1a1a3
Add manual release workflow with exact-SHA gates and moving major alias
jongio 6425ab2
Reject stale or draft release retries before publishing
jongio 60fdeaf
Accept any full setup-node SHA pin in release contract test
jongio 3304ec2
Fail release publication unless the environment requires reviewers
jongio 0fcb2ae
Release automatically on successful main CI with patch bumps
jongio 80a1d48
fix(release): match breaking subjects case-insensitively and keep que…
jongio 2e2edda
fix(release): count files moved out of shipped paths
jongio 63d4fc4
test: disable signing in the temporary release repository
jongio File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,208 @@ | ||
| name: Release | ||
| on: | ||
| workflow_run: | ||
| workflows: [Model-free CI] | ||
| types: [completed] | ||
| branches: [main] | ||
| schedule: | ||
| - cron: '23 */6 * * *' | ||
| workflow_dispatch: | ||
| inputs: | ||
| bump: | ||
| description: Version bump from the newest vMAJOR.MINOR.PATCH tag | ||
| required: true | ||
| default: minor | ||
| type: choice | ||
| options: [patch, minor, major] | ||
| prerelease: | ||
| description: Publish as a prerelease (required while bundled license text is unresolved) | ||
| required: true | ||
| default: true | ||
| type: boolean | ||
| dry_run: | ||
| description: Verify only; do not create tags or a release | ||
| required: true | ||
| default: true | ||
| type: boolean | ||
| permissions: | ||
| contents: read | ||
| concurrency: | ||
| group: release | ||
| cancel-in-progress: false | ||
| # Keep every pending run (such as a manual release) instead of replacing it. | ||
| queue: max | ||
| jobs: | ||
| verify: | ||
| name: Verify release candidate | ||
| # Unattended runs follow successful main pushes or reconcile on schedule; AUTO_RELEASE is the off switch. | ||
| if: >- | ||
| github.event_name == 'workflow_dispatch' || | ||
| (vars.AUTO_RELEASE == 'true' && (github.event_name == 'schedule' || | ||
| (github.event.workflow_run.event == 'push' && github.event.workflow_run.conclusion == 'success'))) | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 15 | ||
| permissions: | ||
| actions: read | ||
| contents: read | ||
| outputs: | ||
| release: ${{ steps.ci.outputs.release }} | ||
| sha: ${{ steps.head.outputs.sha }} | ||
| tag: ${{ steps.plan.outputs.tag }} | ||
| alias: ${{ steps.plan.outputs.alias }} | ||
| move-alias: ${{ steps.plan.outputs.move-alias }} | ||
| prerelease: ${{ steps.plan.outputs.prerelease }} | ||
| latest: ${{ steps.plan.outputs.latest }} | ||
| steps: | ||
| - name: Require dispatch from main | ||
| if: github.event_name == 'workflow_dispatch' && github.ref != 'refs/heads/main' | ||
| run: | | ||
| echo "::error::Releases are cut only from main." | ||
| exit 1 | ||
| - uses: actions/checkout@v7 | ||
| with: | ||
| ref: main | ||
| fetch-depth: 0 | ||
| persist-credentials: false | ||
| - name: Resolve main head | ||
| id: head | ||
| run: echo "sha=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT" | ||
| - uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0 | ||
| with: | ||
| node-version-file: .node-version | ||
| - name: Plan release | ||
| id: plan | ||
| env: | ||
| EVENT: ${{ github.event_name }} | ||
| BUMP: ${{ inputs.bump }} | ||
| PRERELEASE: ${{ inputs.prerelease }} | ||
| AUTO_PRERELEASE: ${{ vars.AUTO_RELEASE_PRERELEASE }} | ||
| run: | | ||
| if [ "$EVENT" = workflow_dispatch ]; then | ||
| node tooling/release.mjs plan "$BUMP" "$PRERELEASE" false | ||
| else | ||
| node tooling/release.mjs plan patch "${AUTO_PRERELEASE:-true}" true | ||
| fi | ||
| - name: Require Model-free CI success on this exact commit | ||
| id: ci | ||
| if: steps.plan.outputs.release == 'true' | ||
| env: | ||
| GH_TOKEN: ${{ github.token }} | ||
| EVENT: ${{ github.event_name }} | ||
| REPOSITORY: ${{ github.repository }} | ||
| SHA: ${{ steps.head.outputs.sha }} | ||
| run: | | ||
| count="$(gh api "repos/$REPOSITORY/actions/workflows/ci.yml/runs?head_sha=$SHA&event=push&branch=main&status=success&per_page=1" --jq '.total_count')" | ||
| if [ "$count" -lt 1 ]; then | ||
| if [ "$EVENT" = workflow_dispatch ]; then | ||
| echo "::error::Model-free CI has not succeeded for push $SHA on main." | ||
| exit 1 | ||
| fi | ||
| echo "::notice::Model-free CI has not succeeded for $SHA yet; its completion triggers the next release check." | ||
| echo "release=false" >> "$GITHUB_OUTPUT" | ||
| exit 0 | ||
| fi | ||
| echo "release=true" >> "$GITHUB_OUTPUT" | ||
| - run: corepack enable | ||
| if: steps.ci.outputs.release == 'true' | ||
| - run: corepack pnpm install --frozen-lockfile --ignore-scripts | ||
| if: steps.ci.outputs.release == 'true' | ||
| - run: corepack pnpm check | ||
| if: steps.ci.outputs.release == 'true' | ||
| - name: Require a clean checkout | ||
| if: steps.ci.outputs.release == 'true' | ||
| run: | | ||
| if [ -n "$(git status --porcelain --untracked-files=normal)" ]; then | ||
| git status --short | ||
| echo "::error::pnpm check left the checkout dirty." | ||
| exit 1 | ||
| fi | ||
| publish: | ||
| name: Publish ${{ needs.verify.outputs.tag }} | ||
| needs: verify | ||
| if: needs.verify.outputs.release == 'true' && inputs.dry_run != true | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 5 | ||
| environment: release | ||
|
jongio marked this conversation as resolved.
Resolved
|
||
| permissions: | ||
| actions: read | ||
| contents: write | ||
| env: | ||
| GH_TOKEN: ${{ github.token }} | ||
| REPOSITORY: ${{ github.repository }} | ||
| SHA: ${{ needs.verify.outputs.sha }} | ||
| TAG: ${{ needs.verify.outputs.tag }} | ||
| ALIAS: ${{ needs.verify.outputs.alias }} | ||
| steps: | ||
| - name: Require a branch-restricted release environment | ||
| run: | | ||
| restricted="$(gh api "repos/$REPOSITORY/environments/release" --jq '.deployment_branch_policy != null')" | ||
| if [ "$restricted" != true ]; then | ||
| echo "::error::The release environment must restrict deployments to selected branches before unattended publication." | ||
| exit 1 | ||
| fi | ||
|
jongio marked this conversation as resolved.
Resolved
|
||
| - uses: actions/checkout@v7 | ||
| with: | ||
| ref: ${{ needs.verify.outputs.sha }} | ||
| persist-credentials: false | ||
| - uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0 | ||
| with: | ||
| node-version-file: .node-version | ||
| - name: Recheck release plan against current tags | ||
| env: | ||
| PRERELEASE: ${{ needs.verify.outputs.prerelease }} | ||
| MOVE_ALIAS: ${{ needs.verify.outputs.move-alias }} | ||
| LATEST: ${{ needs.verify.outputs.latest }} | ||
| run: | | ||
| RELEASE_TAGS="$(gh api --paginate "repos/$REPOSITORY/git/matching-refs/tags/v" --jq '.[].ref | ltrimstr("refs/tags/")')" | ||
| export RELEASE_TAGS | ||
| node tooling/release.mjs recheck "$TAG" "$PRERELEASE" "$MOVE_ALIAS" "$LATEST" | ||
| - name: Create annotated version tag | ||
| run: | | ||
| if gh api "repos/$REPOSITORY/git/ref/tags/$TAG" > /dev/null 2>&1; then | ||
| actual="$(gh api "repos/$REPOSITORY/commits/refs/tags/$TAG" --jq '.sha')" | ||
| if [ "$actual" != "$SHA" ]; then | ||
| echo "::error::$TAG already exists at $actual, expected $SHA." | ||
| exit 1 | ||
| fi | ||
| echo "$TAG already points to $SHA; resuming." | ||
| else | ||
| object="$(gh api "repos/$REPOSITORY/git/tags" -f tag="$TAG" -f message="$TAG" -f object="$SHA" -f type=commit --jq '.sha')" | ||
| gh api "repos/$REPOSITORY/git/refs" -f ref="refs/tags/$TAG" -f sha="$object" > /dev/null | ||
| fi | ||
| - name: Publish GitHub Release | ||
|
jongio marked this conversation as resolved.
Resolved
|
||
| env: | ||
| PRERELEASE: ${{ needs.verify.outputs.prerelease }} | ||
| LATEST: ${{ needs.verify.outputs.latest }} | ||
| run: | | ||
| if state="$(gh release view "$TAG" --repo "$REPOSITORY" --json isDraft,isPrerelease --jq '"\(.isDraft) \(.isPrerelease)"' 2>/dev/null)"; then | ||
| if [ "$state" != "false $PRERELEASE" ]; then | ||
| echo "::error::Release $TAG exists but is not a published release with prerelease=$PRERELEASE (draft/prerelease: $state)." | ||
| exit 1 | ||
| fi | ||
| echo "Release $TAG is already published; resuming." | ||
| exit 0 | ||
| fi | ||
| flags=(--verify-tag --generate-notes --title "$TAG" "--latest=$LATEST") | ||
| if [ "$PRERELEASE" = true ]; then flags+=(--prerelease); fi | ||
| gh release create "$TAG" --repo "$REPOSITORY" "${flags[@]}" | ||
| - name: Advance major alias | ||
| if: needs.verify.outputs.move-alias == 'true' | ||
| run: | | ||
| if gh api "repos/$REPOSITORY/git/ref/tags/$ALIAS" > /dev/null 2>&1; then | ||
| gh api -X PATCH "repos/$REPOSITORY/git/refs/tags/$ALIAS" -f sha="$SHA" -F force=true > /dev/null | ||
| else | ||
| gh api "repos/$REPOSITORY/git/refs" -f ref="refs/tags/$ALIAS" -f sha="$SHA" > /dev/null | ||
| fi | ||
| - name: Verify published refs | ||
| env: | ||
| MOVE_ALIAS: ${{ needs.verify.outputs.move-alias }} | ||
| run: | | ||
| refs=("$TAG") | ||
| if [ "$MOVE_ALIAS" = true ]; then refs+=("$ALIAS"); fi | ||
| for ref in "${refs[@]}"; do | ||
| actual="$(gh api "repos/$REPOSITORY/commits/refs/tags/$ref" --jq '.sha')" | ||
| if [ "$actual" != "$SHA" ]; then | ||
| echo "::error::$ref resolves to $actual, expected $SHA." | ||
| exit 1 | ||
| fi | ||
| done | ||
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
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
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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[Low] Prefer fully qualified
ref: refs/heads/mainUsing
ref: refs/heads/maininstead ofref: mainavoids ref disambiguation if a tag namedmainwere ever created (for example, pointing to an oldermaincommit that already has a passingModel-free CIpush run).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Declined (Low): hardening only; no
maintag exists, and kept out of this fix's scope.