fix(desktop): stamp the release version into desktop builds (#206)

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Yaowei Zheng
2026-08-05 01:08:41 +08:00
committed by GitHub
parent f8bfee18d9
commit b33b3f43ac
2 changed files with 36 additions and 1 deletions
+34 -1
View File
@@ -11,7 +11,13 @@
name: Desktop packages
on:
workflow_call: {}
workflow_call:
inputs:
tag:
description: Release tag (vX.Y.Z) stamped into the app; empty keeps dev versions.
required: false
type: string
default: ""
workflow_dispatch: {}
env:
@@ -46,6 +52,33 @@ jobs:
node-version: 24
cache: pnpm
# Stamp the release version the same way release.yml stamps the CLI artifacts —
# core's VERSION/BUILD_DATE constants (what the app and server report) plus the
# desktop package.json electron-builder reads its installer metadata from;
# otherwise every installer carries the in-repo dev version (v0.2.1 shipped
# Windows metadata saying 0.2.0 this way). node instead of sed -i: this matrix
# includes macOS, whose BSD sed spells in-place editing differently. Dry runs
# (no tag) keep the dev versions.
- name: Stamp release version
if: inputs.tag != ''
shell: bash
env:
TAG: ${{ inputs.tag }}
run: |
V="${TAG#v}"
D="$(date -u +%Y-%m-%d)"
V="$V" D="$D" node -e '
const fs = require("fs");
const p = "packages/core/src/index.ts";
let s = fs.readFileSync(p, "utf8");
if (!/export const VERSION = "/.test(s)) throw new Error("VERSION const not found");
s = s.replace(/export const VERSION = "[^"]*"/, `export const VERSION = "${process.env.V}"`);
if (!/export const BUILD_DATE: string \| null = /.test(s)) throw new Error("BUILD_DATE const not found");
s = s.replace(/export const BUILD_DATE: string \| null = [^;]*/, `export const BUILD_DATE: string | null = "${process.env.D}"`);
fs.writeFileSync(p, s);
'
(cd packages/desktop && npm version --no-git-tag-version --allow-same-version "$V")
- run: pnpm install --frozen-lockfile
- run: pnpm -r build
+2
View File
@@ -84,6 +84,8 @@ jobs:
needs: check-release
if: needs.check-release.outputs.exists != 'true'
uses: ./.github/workflows/desktop-build.yml
with:
tag: ${{ github.event_name == 'workflow_dispatch' && inputs.tag || github.ref_name }}
release:
needs: [check-release, desktop]