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.
811name : release-on-upstream
912
1013on :
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
0 commit comments