-
Notifications
You must be signed in to change notification settings - Fork 0
publish-release: gate auto-publish to bot merges on main only (release-model pilot) #255
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
Open
ptr727
wants to merge
6
commits into
develop
Choose a base branch
from
feature/release-gate-pilot
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
aac4672
publish-release: gate auto-publish to bot merges on main only
ptr727 7827c81
publish-release: update header comment to the gated-release model
ptr727 1d6d2ca
publish-release: single-source the gate via a plan job (publish-plan-…
ptr727 9aae9e0
publish-plan-task: note it is shared across repo types (schedule bran…
ptr727 f6a7bcc
publish-plan-task: guard push on ref==main; document string outputs
ptr727 eb1e274
workflows: drop the out-of-place CODECOV_TOKEN comment above secrets:…
ptr727 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,84 @@ | ||
| name: Publish plan task | ||
|
|
||
| # Single source of truth for the release-gate decision, reused by every publish-release.yml job so the policy | ||
| # lives here, not scattered across job `if:` conditions. A human PR merge never auto-publishes; a release is a | ||
| # deliberate dispatch, a bot (Dependabot/codegen) code-merge to main, or the Docker weekly schedule. | ||
| # | ||
| # Outputs: | ||
| # publish - 'true' when this run should publish: a bot-authored push (the codegen App merges every bot PR, so | ||
| # its identity - or dependabot[bot] - is the gate), a schedule, or a workflow_dispatch of main/develop. | ||
| # A human push (a merge/promotion to main) or a dispatch from any other branch is 'false'. | ||
| # stable - 'true' when the target branch is main (stable channel); main-only jobs gate on publish && stable. | ||
| # Both outputs are the strings 'true'/'false' - gate with == 'true'; a bare `if: ${{ needs.plan.outputs.publish }}` | ||
| # is always truthy (a non-empty string is truthy in an Actions expression). | ||
| # | ||
| # Shared across repo types: a library/package repo triggers only push + dispatch and uses `publish`; a | ||
| # Docker/wrapper repo also triggers the weekly schedule and gates main-only jobs on `stable`. A case a given | ||
| # caller never triggers (e.g. schedule for a library) is simply inert for it - expected of a single-source task. | ||
|
|
||
| on: | ||
| workflow_call: | ||
| inputs: | ||
| event_name: | ||
| description: The triggering event (github.event_name). | ||
| required: true | ||
| type: string | ||
| actor: | ||
| description: The actor that triggered the run (github.actor). | ||
| required: true | ||
| type: string | ||
| ref_name: | ||
| description: The short ref name (github.ref_name). | ||
| required: true | ||
| type: string | ||
| outputs: | ||
| publish: | ||
| description: "'true' when this run should publish." | ||
| value: ${{ jobs.plan.outputs.publish }} | ||
| stable: | ||
| description: "'true' when the target branch is main (stable channel)." | ||
| value: ${{ jobs.plan.outputs.stable }} | ||
|
|
||
| jobs: | ||
|
|
||
| plan: | ||
| name: Plan release job | ||
| runs-on: ubuntu-latest | ||
| outputs: | ||
| publish: ${{ steps.decide.outputs.publish }} | ||
| stable: ${{ steps.decide.outputs.stable }} | ||
|
|
||
| steps: | ||
|
|
||
| - name: Decide release plan step | ||
| id: decide | ||
| env: | ||
| EVENT: ${{ inputs.event_name }} | ||
| ACTOR: ${{ inputs.actor }} | ||
| REF: ${{ inputs.ref_name }} | ||
| run: | | ||
| set -euo pipefail | ||
| publish=false | ||
| case "$EVENT" in | ||
| workflow_dispatch) | ||
| # A human release: only the long-lived branches publish (a stray feature-branch dispatch is a no-op). | ||
| [[ "$REF" == "main" || "$REF" == "develop" ]] && publish=true | ||
| ;; | ||
| schedule) | ||
| # Docker weekly refresh (main-only by schedule config). | ||
| publish=true | ||
| ;; | ||
| push) | ||
| # A human merge never auto-publishes; only a bot merge to main does. The codegen App merges every | ||
| # Dependabot/codegen PR, so github.actor is its identity (dependabot[bot] allowed defensively). The | ||
| # ref==main guard keeps the task self-contained even if a caller's push trigger is not main-only. | ||
| if [[ "$REF" == "main" ]] && { [[ "$ACTOR" == "ptr727-codegen[bot]" ]] || [[ "$ACTOR" == "dependabot[bot]" ]]; }; then | ||
| publish=true | ||
| fi | ||
| ;; | ||
| esac | ||
|
ptr727 marked this conversation as resolved.
|
||
| stable=false | ||
| [[ "$REF" == "main" ]] && stable=true | ||
| echo "publish=$publish" >> "$GITHUB_OUTPUT" | ||
| echo "stable=$stable" >> "$GITHUB_OUTPUT" | ||
| echo "Release plan: event=$EVENT actor=$ACTOR ref=$REF -> publish=$publish stable=$stable" | ||
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
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.
Uh oh!
There was an error while loading. Please reload this page.