ci: manual publish-dist workflow + shared tap-push script - #32
Merged
Conversation
Extracts the Homebrew/Scoop push into scripts/publish-tap.sh (VERSION + TAP_TOKEN env; no-ops without the token, skips prereleases) so the release job and a new manual workflow can't drift. publish-dist.yml is a workflow_dispatch entry point to (re)publish a version's tap files without re-running the whole release — handy for testing TAP_TOKEN or backfilling. Claude-Session: https://claude.ai/code/session_018dRMUUj9vpKp3tqKQFsvE9
Comment on lines
+31
to
+44
| push_file() { | ||
| repo="$1"; src="$2"; dest="$3" | ||
| tmp="$(mktemp -d)" | ||
| git clone --depth 1 "https://x-access-token:${TAP_TOKEN}@github.com/${repo}.git" "$tmp" | ||
| mkdir -p "$(dirname "$tmp/$dest")" | ||
| cp "$src" "$tmp/$dest" | ||
| git -C "$tmp" add "$dest" | ||
| if git -C "$tmp" commit -m "pdcli $VERSION"; then | ||
| git -C "$tmp" push | ||
| echo "pushed $repo/$dest" | ||
| else | ||
| echo "no change for $repo/$dest" | ||
| fi | ||
| } |
There was a problem hiding this comment.
tmp is not declared with local, making it a global variable that is overwritten on each call to push_file. If set -e causes the script to exit mid-way (e.g., on a failed push), the temp directory from any prior call is never cleaned up. Declaring it local also makes the function self-contained and safe to call in any order.
Suggested change
| push_file() { | |
| repo="$1"; src="$2"; dest="$3" | |
| tmp="$(mktemp -d)" | |
| git clone --depth 1 "https://x-access-token:${TAP_TOKEN}@github.com/${repo}.git" "$tmp" | |
| mkdir -p "$(dirname "$tmp/$dest")" | |
| cp "$src" "$tmp/$dest" | |
| git -C "$tmp" add "$dest" | |
| if git -C "$tmp" commit -m "pdcli $VERSION"; then | |
| git -C "$tmp" push | |
| echo "pushed $repo/$dest" | |
| else | |
| echo "no change for $repo/$dest" | |
| fi | |
| } | |
| push_file() { | |
| local repo="$1" src="$2" dest="$3" | |
| local tmp | |
| tmp="$(mktemp -d)" | |
| trap 'rm -rf "$tmp"' RETURN | |
| git clone --depth 1 "https://x-access-token:${TAP_TOKEN}@github.com/${repo}.git" "$tmp" | |
| mkdir -p "$(dirname "$tmp/$dest")" | |
| cp "$src" "$tmp/$dest" | |
| git -C "$tmp" add "$dest" | |
| if git -C "$tmp" commit -m "pdcli $VERSION"; then | |
| git -C "$tmp" push | |
| echo "pushed $repo/$dest" | |
| else | |
| echo "no change for $repo/$dest" | |
| fi | |
| } |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Adds a
workflow_dispatchworkflow to (re)publish the Homebrew/Scoop tap files for a version without re-running the full release, and factors the push logic intoscripts/publish-tap.shso the release job and the manual one share one implementation. No-ops withoutTAP_TOKEN; skips prereleases.https://claude.ai/code/session_018dRMUUj9vpKp3tqKQFsvE9
Greptile Summary
This PR factors the Homebrew/Scoop tap-push logic out of the inline release workflow step into
scripts/publish-tap.sh, and adds a newworkflow_dispatchworkflow (publish-dist.yml) so operators can (re)publish tap files for any already-published version without re-running the full release pipeline.scripts/publish-tap.shis a self-contained bash script withset -euo pipefail, fast-fail on missingVERSION, no-op whenTAP_TOKENis absent, and prerelease skipping — all guards that were present in the old inline block.release.yml'sdistjob is simplified to a singlebash scripts/publish-tap.shcall; the env var rename fromVtoVERSIONis intentional and correctly matches the script's expectation.publish-dist.ymlresolves the version from user input orpackage.json, callsgen-dist.mjs, then delegates to the shared script withVERSION=\"$V\" bash scripts/publish-tap.sh.Confidence Score: 4/5
Safe to merge — the refactor faithfully replicates the existing inline tap-push logic, and both callers wire VERSION and TAP_TOKEN correctly.
The new shared script correctly handles all the guards (prerelease skip, missing token no-op, fast-fail on missing VERSION) that the old inline block had. The only concern is a style-level issue in push_file where tmp is not declared local and temp dirs are never explicitly cleaned up, harmless in ephemeral CI runners but inconsistent with the set -euo pipefail rigor otherwise applied throughout the script.
scripts/publish-tap.sh warrants a quick look at the push_file function for the local/cleanup pattern.
Important Files Changed
Sequence Diagram
%%{init: {'theme': 'neutral'}}%% sequenceDiagram participant GH as GitHub Actions participant RW as release.yml (dist job) participant MW as publish-dist.yml (manual) participant GD as gen-dist.mjs participant PS as publish-tap.sh participant HB as wavyx/homebrew-tap participant SC as wavyx/scoop-pdcli note over GH,SC: Automatic release path (on tag push) GH->>RW: tag push trigger RW->>GD: node scripts/gen-dist.mjs VERSION GD-->>RW: pdcli.rb + pdcli.json written RW->>PS: bash scripts/publish-tap.sh PS->>PS: skip if prerelease PS->>PS: no-op if TAP_TOKEN unset PS->>HB: git clone, cp, commit, push PS->>SC: git clone, cp, commit, push note over GH,SC: Manual re-publish path (workflow_dispatch) GH->>MW: manual trigger MW->>GD: node scripts/gen-dist.mjs V GD-->>MW: pdcli.rb + pdcli.json written MW->>PS: "VERSION=V bash scripts/publish-tap.sh" PS->>PS: skip if prerelease PS->>PS: no-op if TAP_TOKEN unset PS->>HB: git clone, cp, commit, push PS->>SC: git clone, cp, commit, push%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%% sequenceDiagram participant GH as GitHub Actions participant RW as release.yml (dist job) participant MW as publish-dist.yml (manual) participant GD as gen-dist.mjs participant PS as publish-tap.sh participant HB as wavyx/homebrew-tap participant SC as wavyx/scoop-pdcli note over GH,SC: Automatic release path (on tag push) GH->>RW: tag push trigger RW->>GD: node scripts/gen-dist.mjs VERSION GD-->>RW: pdcli.rb + pdcli.json written RW->>PS: bash scripts/publish-tap.sh PS->>PS: skip if prerelease PS->>PS: no-op if TAP_TOKEN unset PS->>HB: git clone, cp, commit, push PS->>SC: git clone, cp, commit, push note over GH,SC: Manual re-publish path (workflow_dispatch) GH->>MW: manual trigger MW->>GD: node scripts/gen-dist.mjs V GD-->>MW: pdcli.rb + pdcli.json written MW->>PS: "VERSION=V bash scripts/publish-tap.sh" PS->>PS: skip if prerelease PS->>PS: no-op if TAP_TOKEN unset PS->>HB: git clone, cp, commit, push PS->>SC: git clone, cp, commit, pushReviews (1): Last reviewed commit: "ci: add manual publish-dist workflow; sh..." | Re-trigger Greptile