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
95 changes: 0 additions & 95 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -156,98 +156,3 @@ jobs:
git add Formula/rk.rb
git commit -m "rk ${version}"
git push

# Placed LAST in the job — after the GitHub Release and Homebrew tap are
# already published — so the documented "best-effort, can't break the
# release" guarantee actually holds: any fatal line here runs only once
# the user-visible release artifacts exist.
- name: Publish help tree to shll.ai
env:
SHLLAI_TOKEN: ${{ secrets.SHLLAI_TOKEN }}
run: |
version="${{ steps.version.outputs.version }}"

# Emit the CLI help tree from the versioned linux/amd64 artifact so
# the dumped version is the real release version (not "dev"). A failure
# here (binary missing, dump errors, invalid JSON) is a real defect in
# THIS repo's build, so it correctly fails the job under `bash -e`.
# Because this step is last, that failure does NOT preempt the already-
# published GitHub Release / Homebrew tap above.
mkdir -p help
dist/rk-linux-amd64/rk help-dump help/run-kit.json
jq empty help/run-kit.json

# The cross-repo publish is best-effort: the GitHub Release and Homebrew
# tap are already produced by the time we get here, so a hiccup that is
# external to this repo (shll.ai unreachable, token scope, repo-level
# auto-merge disabled, a same-version re-run whose branch already
# exists, or an unchanged help tree) MUST NOT fail an otherwise-
# successful release. We surface the outcome in the log and leave any
# opened PR for a manual merge if auto-merge is unavailable.
publish_to_shllai() {
# Open a PR (not a direct push) into sahil87/shll.ai with the
# refreshed help tree, mirroring the Homebrew-tap token-clone pattern.
# The clone is EXTERNAL (an unreachable shll.ai must not fail the
# release), so it stays best-effort with `|| return 1`.
git clone "https://x-access-token:${SHLLAI_TOKEN}@github.com/sahil87/shll.ai.git" /tmp/shll-ai || return 1

branch="rk-help-dump-${version}"

# Copying the produced help tree into the clone is INTERNAL: a failure
# here means our source is wrong or the destination is unwritable — a
# real defect in THIS repo's publish, so it MUST fail the job loudly
# rather than be swallowed by the `if publish_to_shllai` wrapper (which
# neutralizes `set -e`). The explicit `exit 1` terminates the whole
# `run:` shell regardless of the `if`, so a bad copy fails the Release
# job and can never reach the "unchanged — nothing to publish" guard
# below. `mkdir -p` guarantees the destination dir exists in a fresh
# clone whose tree has no `help/` at that commit (the v2.1.8 blocker).
src="${PWD}/help/run-kit.json"
dest="/tmp/shll-ai/help/run-kit.json"
echo "Publishing help tree: src=${src} dest=${dest}"
mkdir -p /tmp/shll-ai/help
cp "$src" "$dest" || { echo "::error::Failed to copy ${src} to ${dest}"; exit 1; }
ls -l "$dest"

cd /tmp/shll-ai
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"

if [ -z "$(git status --porcelain help/run-kit.json)" ]; then
echo "help/run-kit.json unchanged since last release — nothing to publish."
return 0
fi

# --force-with-lease tolerates a re-dispatched release at the same
# version (branch may already exist from a prior attempt).
git checkout -B "$branch" || return 1
git add help/run-kit.json
git commit -m "rk help tree ${version}" || return 1
git push --force-with-lease --set-upstream origin "$branch" || return 1

# gh authenticates via GH_TOKEN; reuse the shll.ai token (contents +
# pull-request write). Explicit arguments only — no untrusted
# shell-string interpolation. If a PR for this head already exists,
# `gh pr create` is a no-op error we tolerate before attempting merge.
GH_TOKEN="$SHLLAI_TOKEN" gh pr create \
--repo sahil87/shll.ai \
--base main \
--head "$branch" \
--title "rk help tree ${version}" \
--body "Automated help-tree update for rk ${version}." \
|| echo "PR for ${branch} may already exist; continuing to merge."

# --auto requires repo-level "Allow auto-merge" on shll.ai. If that
# is off, leave the PR open for a manual merge rather than failing.
GH_TOKEN="$SHLLAI_TOKEN" gh pr merge "$branch" \
--repo sahil87/shll.ai \
--auto \
--squash \
|| echo "Auto-merge unavailable for ${branch}; PR left open for manual merge."
}

if publish_to_shllai; then
echo "shll.ai help-tree publish step completed."
else
echo "::warning::shll.ai help-tree publish failed (external to this repo); release is unaffected. Any PR opened was left for manual merge."
fi
Loading
Loading