Skip to content

Commit a799ec1

Browse files
committed
release-on-upstream: source busbar ref from a plain .busbar-ref file (PAT can't edit workflow files) + version-based cut guard (no spurious re-cut on a same-version core re-tag)
1 parent b9658a6 commit a799ec1

3 files changed

Lines changed: 47 additions & 54 deletions

File tree

.busbar-ref

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
83412dc0306dfe9fc7905249dccdcfd61d43e355 1.5.0

.github/workflows/release-on-upstream.yml

Lines changed: 39 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
1-
# Re-cut this plugin's own next signed release when busbar core ships.
1+
# Re-cut this plugin's own next signed release when busbar core ships a NEWER version.
22
#
3-
# On an upstream-release dispatch (or daily self-heal cron, or a manual run) this re-pins
4-
# release.yml's BUSBAR_REF to the new core SHA, patch-bumps THIS repo's own version line, and pushes
5-
# a v* tag — which fires release.yml (build + sign + publish). No plain `push:` trigger, so merging
6-
# this file cannot itself cut a release. Cron only cuts when core's latest release SHA is ahead of
7-
# our pin, so an idle day is a no-op. Pushes use RELEASE_DISPATCH_TOKEN (bypass-capable) as busbar-bot.
3+
# On an upstream-release dispatch (or daily self-heal cron, or a manual run) this compares the
4+
# incoming busbar version against the version recorded in .busbar-ref (field 2) and cuts ONLY when
5+
# the incoming version is strictly newer (sort -V). A same-version core re-tag is a clean no-op:
6+
# no commit, no tag. On a real cut it overwrites .busbar-ref with "<new-sha> <new-version>" — a
7+
# PLAIN data file the RELEASE_DISPATCH_TOKEN can push, unlike release.yml which is a workflow file
8+
# the PAT is refused (GH013) — patch-bumps THIS repo's own v* tag, and pushes it, firing release.yml
9+
# (build + sign + publish). No plain `push:` trigger, so merging this file cannot itself cut a
10+
# release. Pushes use RELEASE_DISPATCH_TOKEN (bypass-capable) as busbar-bot.
811
name: release-on-upstream
912

1013
on:
@@ -44,7 +47,7 @@ jobs:
4447
git config user.name "busbar-bot"
4548
git config user.email "bot@getbusbar.com"
4649
47-
- name: Resolve whether a new busbar release warrants a cut
50+
- name: Resolve whether a newer busbar version warrants a cut
4851
id: resolve
4952
env:
5053
GH_TOKEN: ${{ secrets.RELEASE_DISPATCH_TOKEN }}
@@ -53,59 +56,51 @@ jobs:
5356
EVENT_NAME: ${{ github.event_name }}
5457
run: |
5558
set -euo pipefail
56-
cur_pin="$(awk '/^[[:space:]]*BUSBAR_REF:/{print $2; exit}' .github/workflows/release.yml)"
57-
echo "current BUSBAR_REF pin: ${cur_pin:-<none>}"
58-
target_sha=""
59-
bver=""
59+
rec_sha="$(cut -d' ' -f1 .busbar-ref)"
60+
rec_ver="$(cut -d' ' -f2 .busbar-ref)"
61+
echo "recorded busbar ref: ${rec_sha:-<none>} ${rec_ver:-<none>}"
62+
in_sha=""
63+
in_ver=""
6064
force=no
6165
case "$EVENT_NAME" in
6266
repository_dispatch)
63-
target_sha="${DISPATCH_SHA:-}"
64-
bver="${DISPATCH_VERSION:-}"
67+
in_sha="${DISPATCH_SHA:-}"
68+
in_ver="${DISPATCH_VERSION:-}"
6569
;;
6670
workflow_dispatch)
6771
force=yes # a human explicitly asked for a re-cut
6872
;;
6973
schedule)
7074
# Self-heal: discover busbar's latest RELEASE and the commit it points at. Best-effort —
71-
# if we cannot read it, do nothing (never guess a SHA, so the cron never spuriously cuts).
75+
# if we cannot read it, do nothing (never guess, so the cron never spuriously cuts).
7276
tag="$(gh api repos/GetBusbar/busbar/releases/latest --jq .tag_name 2>/dev/null || true)"
7377
if [ -n "$tag" ]; then
74-
bver="${tag#v}"
75-
target_sha="$(gh api "repos/GetBusbar/busbar/commits/${tag}" --jq .sha 2>/dev/null || true)"
78+
in_ver="${tag#v}"
79+
in_sha="$(gh api "repos/GetBusbar/busbar/commits/${tag}" --jq .sha 2>/dev/null || true)"
7680
fi
7781
;;
7882
esac
83+
in_ver="${in_ver#v}"
7984
should_cut=no
80-
repin_sha=""
8185
if [ "$force" = yes ]; then
8286
should_cut=yes
8387
echo "::notice::manual workflow_dispatch -> cutting a release"
84-
elif [ -n "$target_sha" ] && [ "$target_sha" != "$cur_pin" ]; then
88+
elif [ -z "$in_ver" ]; then
89+
echo "::notice::no incoming busbar version (recorded=${rec_ver:-none}) -> nothing to do"
90+
elif [ "$in_ver" = "$rec_ver" ]; then
91+
echo "::notice::incoming busbar ${in_ver} == recorded ${rec_ver} (same-version re-tag) -> nothing to do"
92+
elif [ "$(printf '%s\n%s\n' "$rec_ver" "$in_ver" | sort -V | tail -1)" = "$in_ver" ]; then
8593
should_cut=yes
86-
repin_sha="$target_sha"
87-
echo "::notice::busbar advanced (pinned=${cur_pin:-none} -> ${target_sha}) -> cutting a release"
94+
echo "::notice::busbar advanced (recorded=${rec_ver:-none} -> ${in_ver}) -> cutting a release"
8895
else
89-
echo "::notice::no new busbar release (pinned=${cur_pin:-none}, target=${target_sha:-none}) -> nothing to do"
96+
echo "::notice::incoming busbar ${in_ver} not newer than recorded ${rec_ver} -> nothing to do"
9097
fi
9198
{
9299
echo "should_cut=$should_cut"
93-
echo "repin_sha=$repin_sha"
94-
echo "bver=$bver"
100+
echo "in_sha=$in_sha"
101+
echo "in_ver=$in_ver"
95102
} >> "$GITHUB_OUTPUT"
96103
97-
- name: Re-pin BUSBAR_REF to the new busbar SHA
98-
if: steps.resolve.outputs.should_cut == 'yes' && steps.resolve.outputs.repin_sha != ''
99-
env:
100-
REPIN_SHA: ${{ steps.resolve.outputs.repin_sha }}
101-
BVER: ${{ steps.resolve.outputs.bver }}
102-
run: |
103-
set -euo pipefail
104-
today="$(date -u +%Y-%m-%d)"
105-
vlabel="${BVER:+v${BVER} }"
106-
sed -i -E "s|^([[:space:]]*BUSBAR_REF:[[:space:]]*)[0-9a-fA-F]+.*\$|\\1${REPIN_SHA} # busbar ${vlabel}release SHA (GetBusbar/busbar main, ${today})|" .github/workflows/release.yml
107-
grep -n 'BUSBAR_REF:' .github/workflows/release.yml
108-
109104
- name: Compute this repo's next version
110105
id: ver
111106
if: steps.resolve.outputs.should_cut == 'yes'
@@ -145,18 +140,20 @@ jobs:
145140
echo "exists=no" >> "$GITHUB_OUTPUT"
146141
fi
147142
148-
- name: Commit the re-pin to main
149-
if: steps.guard.outputs.exists == 'no' && steps.resolve.outputs.repin_sha != ''
143+
- name: Record the new busbar ref in .busbar-ref
144+
if: steps.guard.outputs.exists == 'no' && steps.resolve.outputs.in_sha != ''
150145
env:
151146
TAG: ${{ steps.ver.outputs.tag }}
152-
REPIN_SHA: ${{ steps.resolve.outputs.repin_sha }}
147+
IN_SHA: ${{ steps.resolve.outputs.in_sha }}
148+
IN_VER: ${{ steps.resolve.outputs.in_ver }}
153149
run: |
154150
set -euo pipefail
155-
if git diff --quiet .github/workflows/release.yml; then
156-
echo "::notice::BUSBAR_REF already at ${REPIN_SHA}, no re-pin commit needed"
151+
printf '%s %s\n' "${IN_SHA}" "${IN_VER}" > .busbar-ref
152+
if git diff --quiet .busbar-ref; then
153+
echo "::notice::.busbar-ref already at ${IN_SHA} ${IN_VER}, no commit needed"
157154
else
158-
git add .github/workflows/release.yml
159-
git commit -m "release.yml: re-pin busbar sibling to ${REPIN_SHA} for the ${TAG} release"
155+
git add .busbar-ref
156+
git commit -m ".busbar-ref: record busbar ${IN_VER} (${IN_SHA}) for the ${TAG} release"
160157
git push origin HEAD:main
161158
fi
162159

.github/workflows/release.yml

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#
1010
# This plugin's own version (the `v*` tag pushed here) is NOT tied to busbar's version number —
1111
# it is independently versioned starting at 1.0.0 (see README), separate from whichever busbar
12-
# branch it happens to build against via BUSBAR_REF below.
12+
# branch it happens to build against via the .busbar-ref file at repo root.
1313
name: release
1414

1515
on:
@@ -22,16 +22,6 @@ permissions:
2222
id-token: write # OIDC identity for keyless Sigstore signing (provenance)
2323
attestations: write # record the build-provenance attestation
2424

25-
env:
26-
# Which busbar commit to check out as the sibling path dependency (used only to build
27-
# busbar-plugin-pack, which then packs + signs this plugin under BUSBAR_SIGN_KEY) — same
28-
# BUSBAR_REF convention ci.yml already established. Pinned to a commit SHA on the `dev` branch,
29-
# not the branch name itself, since a mutable branch checked out while holding the signing key
30-
# is a supply-chain foot-gun. To bump deliberately: confirm the new SHA builds
31-
# busbar-plugin-pack cleanly, then update this value in a reviewed PR — never track the branch
32-
# automatically.
33-
BUSBAR_REF: 5b78db9fe0059a08907978f15bcde67e8cd757f9 # v1.5.0 release SHA (GetBusbar/busbar main, 2026-08-02)
34-
3525
jobs:
3626
# Create the Release first so the parallel per-target upload jobs have something to attach to
3727
# (uploading from a matrix without a pre-existing release races -> "release not found").
@@ -89,11 +79,16 @@ jobs:
8979
with:
9080
path: hashicorp-vault
9181

82+
- name: Resolve busbar ref from .busbar-ref
83+
id: ref
84+
run: echo "sha=$(cut -d' ' -f1 hashicorp-vault/.busbar-ref)" >> "$GITHUB_OUTPUT"
85+
shell: bash
86+
9287
- name: Checkout busbar (sibling path dependency)
9388
uses: actions/checkout@v7
9489
with:
9590
repository: GetBusbar/busbar
96-
ref: ${{ env.BUSBAR_REF }}
91+
ref: ${{ steps.ref.outputs.sha }}
9792
path: busbarAI
9893

9994
- uses: dtolnay/rust-toolchain@stable

0 commit comments

Comments
 (0)