Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions .github/tests/check-concurrency.sh
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,29 @@ both "event form through an event exemption" 0 "ok r"
exemptions r '{"concurrency":{"exemptions":[{"workflow":"release.yml","form":"queue","reason":"deploys"}]}}'
both "sha group on a queue exemption is rejected" 1 "expected queue form"

recovery_workflow() { # <on> <group expression>
reset
workflow r release.yml <<EOF
on: $1
concurrency:
group: release-\${{ $2 }}
cancel-in-progress: false
jobs: {tag: {uses: o/w/.github/workflows/release-tag.yml@abc}}
EOF
}
RECOVERY_ON='{push: {}, workflow_dispatch: {inputs: {release-commit: {type: string, required: true}}}}'
recovery_workflow "$RECOVERY_ON" 'inputs.release-commit || github.sha'
both "recovery group with the release-commit input" 0 "ok r"
recovery_workflow "$RECOVERY_ON" 'github.sha'
both "sha group is still accepted with the release-commit input" 0 "ok r"
recovery_workflow "$RECOVERY_ON" 'github.ref'
# shellcheck disable=SC2016 # literal GitHub expression
both "wrong group recommends the recovery form" 1 'expected event form: group "release-${{ inputs.release-commit || github.sha }}"'
recovery_workflow '{push: {}, workflow_dispatch: {}}' 'inputs.release-commit || github.sha'
both "recovery group without the release-commit input is rejected" 1 "expected event form"
recovery_workflow '[push, workflow_dispatch]' 'inputs.release-commit || github.sha'
both "recovery group with list triggers is rejected" 1 "expected event form"

reset
workflow r release.yml <<'EOF'
on: {push: {}}
Expand Down
22 changes: 15 additions & 7 deletions .github/workflows/publish-python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,25 +65,30 @@ jobs:
[[ "$WORKFLOW_SHA" =~ ^[0-9a-f]{40}$ ]] || { echo 'Workflow commit SHA unavailable' >&2; exit 1; }
test "$WORKFLOW_REPOSITORY" = BehindTheMusicTree/github-workflows
echo "sha=$WORKFLOW_SHA" >> "$GITHUB_OUTPUT"
- name: Require a main push, a release tag and a known registry
- name: Require a main push or release-commit dispatch, a release tag and a known registry
env:
EVENT: ${{ github.event_name }}
REF: ${{ github.ref }}
DELETED: ${{ github.event.deleted }}
RELEASE_COMMIT: ${{ github.event.inputs.release-commit }}
RELEASE_TAG: ${{ inputs.release-tag }}
REGISTRY: ${{ inputs.registry }}
run: |
test "$EVENT" = push
test "$REF" = refs/heads/main
test "$DELETED" = false
case "$EVENT" in
push) test "$DELETED" = false; test -z "$RELEASE_COMMIT" ;;
workflow_dispatch) test -n "$RELEASE_COMMIT" || { echo 'release-commit input missing' >&2; exit 1; } ;;
*) echo "Unsupported event: $EVENT" >&2; exit 1 ;;
esac
test -n "$RELEASE_TAG" || { echo 'release-tag is empty: no release tag was created in this run' >&2; exit 1; }
case "$REGISTRY" in
pypi|testpypi) ;;
*) echo "Unknown registry: $REGISTRY" >&2; exit 1 ;;
esac
- uses: actions/checkout@v5
with:
ref: ${{ github.sha }}
# The release commit, not the tag: python-artifact.py then rejects a tag pointing anywhere else.
ref: ${{ github.event.inputs.release-commit || github.sha }}
fetch-depth: 0
persist-credentials: false
path: caller
Expand All @@ -97,13 +102,16 @@ jobs:
auth="$(printf 'x-access-token:%s' "$GITHUB_TOKEN" | base64 -w0 2>/dev/null || printf 'x-access-token:%s' "$GITHUB_TOKEN" | base64)"
echo "::add-mask::$auth"
# A tag just created through the API can take a moment to be served by git.
fetched=false
for attempt in 1 2 3 4 5 6; do
git -c "http.extraheader=AUTHORIZATION: basic $auth" fetch --no-tags origin "+refs/tags/$RELEASE_TAG:refs/tags/$RELEASE_TAG" && exit 0
if git -c "http.extraheader=AUTHORIZATION: basic $auth" fetch --no-tags origin "+refs/tags/$RELEASE_TAG:refs/tags/$RELEASE_TAG"; then
fetched=true
break
fi
echo "Tag $RELEASE_TAG not yet fetchable (attempt $attempt/6)" >&2
sleep 5
done
echo "Tag $RELEASE_TAG could not be fetched" >&2
exit 1
[ "$fetched" = true ] || { echo "Tag $RELEASE_TAG could not be fetched" >&2; exit 1; }
- uses: actions/checkout@v5
with:
repository: BehindTheMusicTree/github-workflows
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/python-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ name: Python check
on:
workflow_call:
inputs:
ref:
description: Commit to check, empty for the triggering commit; a release gate passes inputs.release-commit || github.sha
default: ''
type: string
target:
description: check.sh target, lint or test; any other value fails before the job starts work
required: true
Expand Down Expand Up @@ -64,6 +68,7 @@ jobs:
fi
- uses: actions/checkout@v5
with:
ref: ${{ inputs.ref }}
persist-credentials: false
- name: Write environment
if: ${{ inputs.env != '' }}
Expand Down
11 changes: 8 additions & 3 deletions .github/workflows/release-please.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,19 @@ jobs:
run: |
[[ "$WORKFLOW_SHA" =~ ^[0-9a-f]{40}$ ]] || { echo 'Workflow commit SHA unavailable' >&2; exit 1; }
test "$WORKFLOW_REPOSITORY" = BehindTheMusicTree/github-workflows || { echo 'Unexpected workflow repository' >&2; exit 1; }
- name: Require a main push
- name: Require a main push or a main release-commit dispatch
env:
EVENT: ${{ github.event_name }}
REF: ${{ github.ref }}
DELETED: ${{ github.event.deleted }}
RELEASE_COMMIT: ${{ github.event.inputs.release-commit }}
run: |
test "$EVENT" = push
test "$REF" = refs/heads/main
test "$DELETED" = false
case "$EVENT" in
push) test "$DELETED" = false; test -z "$RELEASE_COMMIT" ;;
workflow_dispatch) test -n "$RELEASE_COMMIT" || { echo 'release-commit input missing' >&2; exit 1; } ;;
*) echo "Unsupported event: $EVENT" >&2; exit 1 ;;
esac
- name: Require App configuration
env:
APP_ID: ${{ inputs.app-id }}
Expand Down Expand Up @@ -98,6 +102,7 @@ jobs:
env:
RELEASE_PR_APP_TOKEN: ${{ steps.app.outputs.token }}
POLICIES: ${{ inputs.release-policies }}
CALLER_WORKFLOW: ${{ github.workflow_ref }}
run: |
mapfile -t policies < <(grep '[^[:space:]]' <<< "$POLICIES" | sed -E 's/^[[:space:]]+|[[:space:]]+$//g')
python3 ../foundation/release/reconcile-release-prs.py "${policies[@]}"
Expand Down
25 changes: 19 additions & 6 deletions .github/workflows/release-tag.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,19 @@ jobs:
run: |
[[ "$WORKFLOW_SHA" =~ ^[0-9a-f]{40}$ ]] || { echo 'Workflow commit SHA unavailable' >&2; exit 1; }
test "$WORKFLOW_REPOSITORY" = BehindTheMusicTree/github-workflows || { echo 'Unexpected workflow repository' >&2; exit 1; }
- name: Require a main push
- name: Require a main push or a main release-commit dispatch
env:
EVENT: ${{ github.event_name }}
REF: ${{ github.ref }}
DELETED: ${{ github.event.deleted }}
RELEASE_COMMIT: ${{ github.event.inputs.release-commit }}
run: |
test "$EVENT" = push
test "$REF" = refs/heads/main
test "$DELETED" = false
case "$EVENT" in
push) test "$DELETED" = false; test -z "$RELEASE_COMMIT" ;;
workflow_dispatch) test -n "$RELEASE_COMMIT" || { echo 'release-commit input missing' >&2; exit 1; } ;;
*) echo "Unsupported event: $EVENT" >&2; exit 1 ;;
esac
- uses: actions/checkout@v5
with:
ref: ${{ github.sha }}
Expand All @@ -72,10 +76,19 @@ jobs:
id: intent
working-directory: caller
env:
BEFORE: ${{ github.event.before }}
AFTER: ${{ github.sha }}
EVENT: ${{ github.event_name }}
PUSH_BEFORE: ${{ github.event.before }}
PUSH_AFTER: ${{ github.sha }}
RELEASE_COMMIT: ${{ github.event.inputs.release-commit }}
POLICY: ${{ inputs.release-policy-path }}
run: |
# Assign before reading: a process substitution would hide the script's exit status.
if [ "$EVENT" = workflow_dispatch ]; then
range=$(python3 ../foundation/release/release-range.py dispatch "$RELEASE_COMMIT")
else
range=$(python3 ../foundation/release/release-range.py push "$PUSH_BEFORE" "$PUSH_AFTER")
fi
read -r BEFORE AFTER <<< "$range"
python3 ../foundation/release/validate-release.py "$BEFORE" "$AFTER" "$POLICY" > "$RUNNER_TEMP/release-intent.json"
jq -r '"release=\(.release)", "tag=\(.tag // "")", "commit=\(.commit // "")", "github_release=\(.github_release // false)"' "$RUNNER_TEMP/release-intent.json" >> "$GITHUB_OUTPUT"

Expand All @@ -84,7 +97,7 @@ jobs:
if: needs.validate.outputs.release == 'true'
runs-on: ubuntu-latest
timeout-minutes: 5
# Each event is independent: callers use a per-commit group (`<stem>-${{ github.sha }}`, no cancel); a ref-level group replaces a pending run and drops its bump.
# Each event is independent: callers use a per-commit group (`<stem>-${{ inputs.release-commit || github.sha }}`, no cancel); a ref-level group replaces a pending run and drops its bump.
steps:
- name: Require the caller-pinned workflow commit
env:
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ After opening the PR, maintainers will review and may request changes. Once appr

Release Please prepares releases from conventional PR titles squash merged into `main`. Use `fix:` for a patch, `feat:` for a minor release, and `!` for a breaking change. Keep `CHANGELOG.md` and `VERSION` edits in the generated release PR.

The release caller sets `auto-merge: true`. GitHub squash merges the release PR once the required checks pass. The main-push workflow validates the version and changelog, creates the annotated tag on the squash commit, and publishes the GitHub Release. Rerun the original main-push workflow to recover from a tagging or publication failure.
The release caller sets `auto-merge: true`. GitHub squash merges the release PR once the required checks pass. The main-push workflow validates the version and changelog, creates the annotated tag on the squash commit, and publishes the GitHub Release. Rerun the original main-push workflow to recover from a tagging or publication failure; if the push produced no run at all, [dispatch the recovery](README.md#recovering-a-release-push-that-produced-no-run).

#### Choosing the version

Expand Down
Loading