feat(desktop): allow repository branches for test packaging

This commit is contained in:
winewill committed 2026-10-15 13:39:28 +08:00
1 parent 755c52fd77
commit 61059baf61
14 files changed
+140 -35

No files matched your search

+2 -2
View File
@@ -6,11 +6,11 @@ on:
workflow_dispatch:
inputs:
package_run_id:
description: 'Successful Package Desktop run ID'
description: '打包运行 ID:填写成功的 Package Desktop run ID;发布环境和 release ID 沿用原包'
type: string
required: true
package_run_attempt:
description: 'Package attempt; blank selects latest, which must have succeeded'
description: '打包尝试次数:留空选择最新一次,且必须成功;失败时不会回退到旧包'
type: string
required: false
default: ''
+20 -9
View File
@@ -4,40 +4,40 @@ on:
workflow_dispatch:
inputs:
preset:
description: 'Machine preset (configured on the packaging runner)'
description: '打包环境:选择机器上的 test 或 production 配置;同时决定后续发布环境'
type: choice
options: [test, production]
default: test
required: true
skip_notarization:
description: 'Skip notarization/stapling: internal debugging only, not for distribution or updates'
description: '跳过公证和 stapling:仅限内部调试,不可用于发布或自动更新'
type: boolean
default: false
required: true
test_release_id:
description: '测试环境的前缀,用于隔离外部用户访问,留空使用默认配置;测试连续升级时需使用相同值;建议定期轮换默认值。'
description: '测试 release ID:32 位小写十六进制随机前缀(非鉴权);留空使用机器默认值,连续升级测试须保持相同值'
type: string
default: ''
required: false
source_ref:
description: 'Source: master or a dsh-v* tag containing the Desktop CI adapters'
description: '打包源码:test 支持仓库内分支或 dsh-v* tag;production 仅支持 master 或 dsh-v* tag;源码须包含 CI 适配脚本'
type: string
default: master
required: true
update_channel:
description: 'Installer update channel; automatic updates stay on this channel'
description: '升级通道:nightly 或 latest(须为稳定版本);自动更新不会切换通道'
type: choice
options: [nightly, latest]
default: nightly
required: true
version_mode:
description: 'default: production follows product, test auto; manual uses build_version'
description: '版本模式:default 为 test 自动编号、production 跟随产品;product 保留原版本,auto 自动编号,manual 手填'
type: choice
options: [default, product, auto, manual]
default: default
required: true
build_version:
description: 'Manual version only: product version or its supported prerelease suffix'
description: '手动版本号:仅 manual 时填写完整版本;须为产品原版本或受支持的预发布后缀'
type: string
default: ''
required: false
@@ -74,9 +74,20 @@ jobs:
- name: Validate selected source and adapter support
run: >-
node -e "const fs=require('node:fs'); const ref=process.env.PACKAGE_SOURCE_REF;
if(ref!=='master' && !/^dsh-v[0-9][0-9A-Za-z.-]*$/.test(ref)) throw Error('Select master or dsh-v*');
const cp=require('node:child_process'); const preset=process.env.DSH_PACKAGING_PRESET;
if(!['test','production'].includes(preset)) throw Error('Unknown packaging preset');
const tag=/^dsh-v[0-9][0-9A-Za-z.-]*$/.test(ref);
if(preset==='production' && ref!=='master' && !tag) throw Error('Production source must be master or dsh-v*');
if(tag) {
const v=JSON.parse(fs.readFileSync('package.json','utf8')).version;
if(ref!=='master' && ref!=='dsh-v'+v) throw Error('Source tag must match product version');
if(ref!=='dsh-v'+v) throw Error('Source tag must match product version');
const tagged=cp.execFileSync('git',['rev-parse','--verify','refs/tags/'+ref+'^{commit}'],{encoding:'utf8'}).trim();
const head=cp.execFileSync('git',['rev-parse','HEAD'],{encoding:'utf8'}).trim();
if(tagged!==head) throw Error('Checkout does not match source tag');
} else {
const branch=cp.execFileSync('git',['symbolic-ref','--short','HEAD'],{encoding:'utf8'}).trim();
if(branch!==ref || ref.startsWith('refs/')) throw Error('Select a branch in this repository, not a SHA or PR ref');
}
if(!fs.readFileSync('apps/desktop/scripts/desktop-ci-version.mjs','utf8').includes('PACKAGE_VERSION_MODE')) throw Error('Source lacks Desktop channel/version CI support; select a newer release');"
- uses: pnpm/[email protected]
with:
+20 -9
View File
@@ -4,41 +4,41 @@ on:
workflow_dispatch:
inputs:
preset:
description: 'Machine preset (configured on the packaging runner)'
description: '打包环境:选择机器上的 test 或 production 配置;同时决定后续发布环境'
type: choice
options: [test, production]
default: test
required: true
signing:
description: 'unsigned: test installer; signed: use the configured EV hardware token'
description: '签名方式:unsigned 仅供内部测试;signed 使用机器配置的 EV 硬件令牌'
type: choice
options: [unsigned, signed]
default: unsigned
required: true
test_release_id:
description: '测试环境的前缀,用于隔离外部用户访问,留空使用默认配置;测试连续升级时需使用相同值;建议定期轮换默认值。'
description: '测试 release ID:32 位小写十六进制随机前缀(非鉴权);留空使用机器默认值,连续升级测试须保持相同值'
type: string
default: ''
required: false
source_ref:
description: 'Source: master or a dsh-v* tag containing the Desktop CI adapters'
description: '打包源码:test 支持仓库内分支或 dsh-v* tag;production 仅支持 master 或 dsh-v* tag;源码须包含 CI 适配脚本'
type: string
default: master
required: true
update_channel:
description: 'Installer update channel; automatic updates stay on this channel'
description: '升级通道:nightly 或 latest(须为稳定版本);自动更新不会切换通道'
type: choice
options: [nightly, latest]
default: nightly
required: true
version_mode:
description: 'default: production follows product, test auto; manual uses build_version'
description: '版本模式:default 为 test 自动编号、production 跟随产品;product 保留原版本,auto 自动编号,manual 手填'
type: choice
options: [default, product, auto, manual]
default: default
required: true
build_version:
description: 'Manual version only: product version or its supported prerelease suffix'
description: '手动版本号:仅 manual 时填写完整版本;须为产品原版本或受支持的预发布后缀'
type: string
default: ''
required: false
@@ -86,9 +86,20 @@ jobs:
- name: Validate selected source and adapter support
run: >-
node -e "const fs=require('node:fs'); const ref=process.env.PACKAGE_SOURCE_REF;
if(ref!=='master' && !/^dsh-v[0-9][0-9A-Za-z.-]*$/.test(ref)) throw Error('Select master or dsh-v*');
const cp=require('node:child_process'); const preset=process.env.DSH_PACKAGING_PRESET;
if(!['test','production'].includes(preset)) throw Error('Unknown packaging preset');
const tag=/^dsh-v[0-9][0-9A-Za-z.-]*$/.test(ref);
if(preset==='production' && ref!=='master' && !tag) throw Error('Production source must be master or dsh-v*');
if(tag) {
const v=JSON.parse(fs.readFileSync('package.json','utf8')).version;
if(ref!=='master' && ref!=='dsh-v'+v) throw Error('Source tag must match product version');
if(ref!=='dsh-v'+v) throw Error('Source tag must match product version');
const tagged=cp.execFileSync('git',['rev-parse','--verify','refs/tags/'+ref+'^{commit}'],{encoding:'utf8'}).trim();
const head=cp.execFileSync('git',['rev-parse','HEAD'],{encoding:'utf8'}).trim();
if(tagged!==head) throw Error('Checkout does not match source tag');
} else {
const branch=cp.execFileSync('git',['symbolic-ref','--short','HEAD'],{encoding:'utf8'}).trim();
if(branch!==ref || ref.startsWith('refs/')) throw Error('Select a branch in this repository, not a SHA or PR ref');
}
if(!fs.readFileSync('apps/desktop/scripts/desktop-ci-version.mjs','utf8').includes('PACKAGE_VERSION_MODE')) throw Error('Source lacks Desktop channel/version CI support; select a newer release');"
- uses: pnpm/[email protected]
with: