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
83 changes: 53 additions & 30 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,33 +56,6 @@ jobs:
VERSION=$(node -p "require('./manifest.json').version")
TAG="v${VERSION}"

# Never let an older version take over `releases/latest`.
# A failed lookup must NOT be read as "no release exists" — that
# would skip the guard and let an older version publish as latest.
RC=0
LATEST=$(gh release view --repo "$GITHUB_REPOSITORY" --json tagName --jq .tagName 2>"$RUNNER_TEMP/latest.err") || RC=$?
if [ "$RC" -ne 0 ]; then
if grep -qi "not found" "$RUNNER_TEMP/latest.err"; then
LATEST=""
else
echo "::error::could not determine the latest release; refusing to publish"
cat "$RUNNER_TEMP/latest.err"
exit 1
fi
fi
if [ -n "$LATEST" ] && node -e '
const parse = v => v.replace(/^v/, "").split(".").map(n => parseInt(n, 10) || 0);
const [version, latest] = process.argv.slice(1).map(parse);
for (let i = 0; i < Math.max(version.length, latest.length); i++) {
const d = (latest[i] || 0) - (version[i] || 0);
if (d !== 0) process.exit(d > 0 ? 0 : 1); // 0 = latest is newer
}
process.exit(1);
' "$VERSION" "$LATEST"; then
echo "v${VERSION} is older than latest release ${LATEST}; refusing to publish it as latest"
exit 0
fi

# Exit codes: 0 = CRX ready, 1 = secret absent (publish ZIP-only),
# 2 = packaging failed (abort — never publish a half-built release).
# Every step needs its own `|| return 2`: this function is invoked
Expand All @@ -101,9 +74,11 @@ jobs:
return 0
}

# Repair path: release already exists. Build from the tagged commit —
# not from main — so a repaired CRX matches the ZIP already published
# for this version instead of quietly shipping different code.
# Repair path comes FIRST, before the latest-version guard: a ZIP-only
# release stays repairable even after main has moved on to a newer
# version (otherwise it would remain CRX-less forever). Build from the
# tagged commit — not from main — so the repaired CRX matches the ZIP
# already published for this version instead of shipping different code.
if gh release view "$TAG" >/dev/null 2>&1; then
HAVE_CRX=$(gh release view "$TAG" --json assets --jq '[.assets[].name] | index("github-bot-command-palette.crx") != null')
if [ "$HAVE_CRX" = "true" ]; then
Expand All @@ -127,6 +102,54 @@ jobs:
exit 0
fi

# Nothing to repair. Never let an older version take over
# `releases/latest`. A failed lookup must NOT be read as "no release
# exists" — that would skip the guard and let an older version publish
# as latest.
RC=0
LATEST=$(gh release view --repo "$GITHUB_REPOSITORY" --json tagName --jq .tagName 2>"$RUNNER_TEMP/latest.err") || RC=$?
if [ "$RC" -ne 0 ]; then
if grep -qi "not found" "$RUNNER_TEMP/latest.err"; then
LATEST=""
else
echo "::error::could not determine the latest release; refusing to publish"
cat "$RUNNER_TEMP/latest.err"
exit 1
fi
fi
if [ -n "$LATEST" ]; then
# Exit codes from the comparison: 0 = latest is newer (refuse),
# 1 = this version is newer or equal (publish), anything else =
# comparison itself failed -> abort rather than guess.
RC=0
node -e '
const parse = v => v.replace(/^v/, "").split(".").map(n => parseInt(n, 10) || 0);
try {
const [version, latest] = process.argv.slice(1).map(parse);
for (let i = 0; i < Math.max(version.length, latest.length); i++) {
const d = (latest[i] || 0) - (version[i] || 0);
if (d !== 0) process.exit(d > 0 ? 0 : 1);
}
process.exit(1);
} catch (e) {
console.error(String(e));
process.exit(2);
}
' "$VERSION" "$LATEST" || RC=$?
case "$RC" in
0)
echo "v${VERSION} is older than latest release ${LATEST}; refusing to publish it as latest"
exit 0
;;
1)
;;
*)
echo "::error::version comparison failed (exit ${RC}); refusing to publish"
exit 1
;;
esac
fi

./scripts/package-extension.sh
# Unversioned copy so /releases/latest/download/github-bot-command-palette.zip
# is a stable URL for scripted updaters (e.g. Tasker on Android).
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ Verify it is wired up: `chrome://extensions` → the extension shows the latest

#### Manual updates

Side-loaded installs that don't use chromium-web-store get a notification instead: the extension checks `manifest.json` on `main` (on browser start, and when you open the popup or Settings) and shows an `↑` badge on the toolbar icon plus an **Update available** card in Settings with a **Reload extension** button. Web Store and chromium-web-store installs update themselves and skip the check.
Side-loaded installs that don't use chromium-web-store get a notification instead: the extension checks `manifest.json` on `main` (on browser start, and when you open the popup or Settings) and shows an `↑` badge on the toolbar icon plus an **Update available** card in Settings with a **Reload extension** button. Every install runs this check, including chromium-web-store ones: between a release landing and the moment you install it from chromium-web-store's badge, the `↑` badge can still appear — it clears once the extension is on the current version.

- **Desktop (git checkout):** `git pull`, then **Reload extension** in Settings (or the reload icon on `chrome://extensions`).
- **Desktop (zip):** download `github-bot-command-palette-vX.Y.Z.zip` from the [latest release](https://github.com/kaovilai/github-bot-command-palette/releases/latest), unzip it over the folder you loaded, then **Reload extension**.
Expand Down
2 changes: 1 addition & 1 deletion settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@
const releaseLink = document.getElementById('update-release-link');

const render = (info) => {
if (!info || info.managed) { section.hidden = true; return; }
if (!info) { section.hidden = true; return; }
section.hidden = false;
document.getElementById('ext-version').textContent = info.current;
actionsEl.hidden = !info.updateAvailable;
Expand Down
Loading