feat(installer): self-select release download source (#176)

This commit is contained in:
Laodouuu
2026-08-04 18:44:30 +08:00
committed by GitHub
parent 747077cabb
commit 38df4e62ee
7 changed files with 347 additions and 50 deletions
+24 -2
View File
@@ -111,14 +111,36 @@ jobs:
run: pnpm install --frozen-lockfile
# Inject the release tag into core's VERSION constant (the source for CLI --version and the install-complete
# message); otherwise artifacts always carry the in-repo dev version and multiple installs can't be told apart.
# BUILD_DATE is stamped alongside it with this run's UTC date (the repo keeps null for dev builds).
# message) and both standalone installers. The stamped installers then select the same immutable OSS/GitHub
# release when run directly. BUILD_DATE is stamped alongside core with this run's UTC date.
- name: Stamp release version
run: |
TAG="${{ github.event_name == 'workflow_dispatch' && inputs.tag || github.ref_name }}"
V="${TAG#v}"
printf '%s\n' "$TAG" | grep -Eq '^v[0-9A-Za-z][0-9A-Za-z._-]*$'
grep -q 'export const VERSION = "' packages/core/src/index.ts
sed -i "s/export const VERSION = \"[^\"]*\"/export const VERSION = \"$V\"/" packages/core/src/index.ts
SH_MARKER='EMBEDDED_RELEASE_VERSION="__PENGUIN_RELEASE_VERSION__"'
PS_MARKER='$EmbeddedReleaseVersion = "__PENGUIN_RELEASE_VERSION__"'
if grep -Fq "$SH_MARKER" install.sh; then SH_HAS_MARKER=1; else SH_HAS_MARKER=0; fi
if grep -Fq "$PS_MARKER" install.ps1; then PS_HAS_MARKER=1; else PS_HAS_MARKER=0; fi
case "$SH_HAS_MARKER:$PS_HAS_MARKER" in
1:1)
sed -i "s/__PENGUIN_RELEASE_VERSION__/$TAG/g" install.sh
sed -i "s/__PENGUIN_RELEASE_VERSION__/$TAG/g" install.ps1
grep -Fq "EMBEDDED_RELEASE_VERSION=\"$TAG\"" install.sh
grep -Fq "\$EmbeddedReleaseVersion = \"$TAG\"" install.ps1
;;
0:0)
# Tags created before installer version stamping have neither marker. Preserve their
# historical installers so a missing Release can still be rebuilt from the tag source.
echo "Legacy tag without embedded installer versions; leaving installers unstamped."
;;
*)
echo "Installer release-version markers are inconsistent." >&2
exit 1
;;
esac
D="$(date -u +%Y-%m-%d)"
# BRE: the unescaped | in these patterns is literal (grep/sed default to POSIX BRE, where | is not alternation).
grep -q 'export const BUILD_DATE: string | null = ' packages/core/src/index.ts