feat: publish Firefox releases to GitHub

This commit is contained in:
2026-07-12 22:30:04 +08:00
parent 7a278a162a
commit 8315d49a58
4 changed files with 79 additions and 3 deletions
+43
View File
@@ -0,0 +1,43 @@
#!/usr/bin/env bash
set -euo pipefail
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
cd "$ROOT_DIR"
REPOSITORY="mirivlad/verstak-browser-extension"
SOURCE_DIR="${VERSTAK_FIREFOX_SOURCE_DIR:-dist/firefox}"
RELEASE_DIR="${VERSTAK_FIREFOX_RELEASE_DIR:-release/firefox}"
if ! command -v gh >/dev/null; then
echo "ERROR: gh CLI is required to publish a GitHub Release" >&2
exit 1
fi
gh auth status
./scripts/release-firefox-xpi.sh
VERSION="$(node -e "console.log(require('./${SOURCE_DIR}/manifest.json').version)")"
TAG="v${VERSION}"
XPI="$RELEASE_DIR/verstak-firefox-${VERSION}.xpi"
UPDATES="$RELEASE_DIR/updates.json"
for artifact in "$XPI" "$UPDATES"; do
if [[ ! -f "$artifact" ]]; then
echo "ERROR: release artifact not found: $artifact" >&2
exit 1
fi
done
if gh release view "$TAG" --repo "$REPOSITORY" >/dev/null 2>&1; then
gh release upload "$TAG" "$XPI" "$UPDATES" --repo "$REPOSITORY" --clobber
else
gh release create "$TAG" "$XPI" "$UPDATES" \
--repo "$REPOSITORY" \
--title "Verstak Browser Extension $VERSION" \
--generate-notes \
--latest \
--target "$(git rev-parse HEAD)"
fi
echo "GitHub release:"
gh release view "$TAG" --repo "$REPOSITORY" --json url --jq .url
+8
View File
@@ -1,5 +1,6 @@
#!/usr/bin/env node
const assert = require('assert');
const fs = require('fs');
const release = require('./firefox-github-release');
const version = '2.0.2';
@@ -28,4 +29,11 @@ assert.equal(
'https://github.com/mirivlad/verstak-browser-extension/releases/latest/download/updates.json',
);
const publisher = fs.readFileSync('scripts/publish-firefox-github-release.sh', 'utf8');
assert.match(publisher, /gh auth status/);
assert.match(publisher, /gh release create/);
assert.match(publisher, /gh release upload/);
assert.match(publisher, /--clobber/);
assert.match(publisher, /--latest/);
console.log('Firefox GitHub release metadata tests passed');