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
39 changes: 35 additions & 4 deletions .github/workflows/bp-release.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# BluePilot: the release job (spec: #227). A pushed release tag (v7.2.0, v7.2.1) creates the version's branch (bp-7.2) for a
# new version and moves bp-stable when it's the highest version released. The rules are in .github/bp_release.py; any
# failed rule writes nothing. Full BluePilot only: this file doesn't exist in ford-op/bp-sunnypilot.
# new version and moves bp-stable when it's the highest version released, then leaves a draft GitHub release for the tag.
# The rules are in .github/bp_release.py; any failed rule writes nothing. Full BluePilot only: this file doesn't exist in ford-op/bp-sunnypilot.
#
# The App token can push to bp-stable, so only the default branch's reviewed workflow file may hold it. A tag push runs the
# The App token can push to bp-stable (and creates the draft release), so only the default branch's reviewed workflow file
# may hold it. A tag push runs the
# tagged commit's copy of this file: there, `dispatch` only checks the tag's form and starts a workflow_dispatch run on the
# default branch with the built-in token (one of the two events that token can start a run with). `release` runs only on
# workflow_dispatch, in the bpx-sync environment, whose single rule (the default branch) needs no tag rule. A ruleset
Expand Down Expand Up @@ -87,7 +88,7 @@ jobs:
private-key: ${{ secrets.SYNC_APP_PRIVATE_KEY }}
owner: BluePilotDev
repositories: bluepilot
permission-contents: write # the push; nothing else
permission-contents: write # the push and the draft release; nothing else
# the dispatched ref (the default branch) is the code; the tag is only read as data. History and trees only, no LFS,
# and the working tree is just .github. Pushes use the App token's URL.
- uses: actions/checkout@v7
Expand All @@ -107,3 +108,33 @@ jobs:
GH_TOKEN: ${{ github.token }}
BP_TOKEN: ${{ steps.bp.outputs.token }} # empty on a dry run
run: python3 .github/bp_release.py
# A draft GitHub release for the tag, with GitHub's list of the pull requests merged since the nearest earlier tag in
# its history. The maintainer writes the top of the notes and publishes it (docs/RELEASING.md); a draft notifies nobody.
# Runs only after bp_release.py accepted the tag, so the branches are already written: if this step fails, run the job
# again (bp_release.py then has nothing to do and the draft is made). A rerun leaves an existing release alone.
- name: Draft the GitHub release
if: inputs.dry_run != true
env:
TAG: ${{ inputs.tag }} # checked by bp_release.py in the step above
TAG_PREFIX: ${{ inputs.tag_prefix }}
GH_TOKEN: ${{ steps.bp.outputs.token }}
run: |
# every release, drafts included. A listing that fails stops the step here: guessing "none yet" could leave a
# second draft for the same tag
releases=$(gh release list -R "$GITHUB_REPOSITORY" --limit 1000 --json tagName --jq '.[].tagName')
if grep -qxF -- "$TAG" <<< "$releases"; then
echo "a release for $TAG already exists: left as it is"
exit 0
fi
# the list starts at the nearest tag before this one (the previous release, or the baseline tag for the first one);
# the job's throwaway test tags never count
since=()
if prev=$(git describe --tags --abbrev=0 --exclude 'bpx-test/*' "refs/tags/$TAG^" 2> /dev/null); then
since=(--notes-start-tag "$prev")
fi
# a test run's draft (docs/RELEASING.md, "Testing the release job") must not read as the real one
title="BluePilot ${TAG#"$TAG_PREFIX"}"
case "$TAG" in
bpx-test/*) title="TEST $TAG: not a release, delete this draft" ;;
esac
gh release create "$TAG" -R "$GITHUB_REPOSITORY" --draft --verify-tag --title "$title" --generate-notes "${since[@]}"
24 changes: 19 additions & 5 deletions docs/RELEASING.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,19 @@ A version number is `MAJOR.MINOR.PATCH`. `7.2.0` is a **new version**; `7.2.1` i
git tag v7.2.0 <commit> && git push origin v7.2.0
```
4. **Watch the `bpx release` run** in the Actions tab. It creates `bp-7.2` at the tagged commit and moves
`bp-stable` to it.
5. **Update the flasher** if this version runs a different AGNOS (see below).
6. **Tell people:** the install links in `README.md`, the short links, and the announcement on Discord.
`bp-stable` to it, then leaves a **draft** GitHub release for the tag. If the run goes red at the draft step,
the branches have already moved: run it again. It leaves them alone and makes the draft.
5. **Write the release notes and publish the draft** (Releases page). The draft already lists the pull requests
merged since the nearest earlier tag in the tag's history, which for a new version is the previous version's
first release (`v7.1.0` for `v7.2.0`). Fixes that also went out in a patch (`v7.1.1`) are listed again: remove
them. Add a section above the list, written for owners: what is new, what was not driven, and any warning.
Nobody is notified until it is published.

For `v7.1.0`, the first release made this way, the list starts at the tag `bp-7.0-base` (where `bp-dev` and
`bp-7.0` last shared a commit), so it includes the fixes `bp-dev` got that `bp-7.0` users never did. It also
lists #220, which `bp-7.0` already has: remove that line.
6. **Update the flasher** if this version runs a different AGNOS (see below).
7. **Tell people:** the install links in `README.md`, the short links, and the announcement on Discord.

## Releasing a patch (7.2.1)

Expand All @@ -43,6 +53,8 @@ A fix always lands on `bp-dev` first, so the next version has it too.
git tag v7.2.1 <tip of bp-7.2> && git push origin v7.2.1
```
`bp-stable` follows only if 7.2 is still the highest version. A patch to an older version leaves it alone.
5. Write the notes on the draft release and publish it, as for a new version. Its list covers what was merged into
`bp-7.2` since `v7.2.0`.

## What the job refuses

Expand Down Expand Up @@ -96,11 +108,13 @@ throwaway names, all under `bpx-test/`:
| `dry_run` | on prints what it would do; off does it |

Push CI runs on `bpx-test/**` branches, so a test commit can get the green checks the job looks for. Delete the test
branches and tags afterward.
branches and tags afterward, and the draft release a real (not dry) test run leaves. That draft is titled
"TEST ..." and carries the real list, since test tags are never a starting point.

## Why it works this way

- **Only the default branch's copy of the workflow holds the key** that can move `bp-stable`. A tag push runs the
- **Only the default branch's copy of the workflow holds the key** that can move `bp-stable` and create the draft
release. A tag push runs the
tagged commit's copy, which can only ask the default branch's copy to run.
- **Branch rules back the job up:** `v*` tags are admin-only, `bp-stable` accepts only the release job, and version
branches can't be deleted or force-pushed.
Expand Down
Loading