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
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ jobs:
- run: pnpm format:check
- run: pnpm test
- run: pnpm test:release
- run: pnpm test:package
- run: pnpm test:store
- name: Check project versions
shell: bash
Expand Down
62 changes: 62 additions & 0 deletions .github/workflows/package.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: Package

on:
workflow_dispatch:

permissions:
contents: read

concurrency:
group: package-${{ github.ref }}
cancel-in-progress: false

jobs:
checks:
name: Package quality gate
uses: ./.github/workflows/ci.yml
with:
ref: ${{ github.ref }}

prepare:
name: Resolve native platform matrix
needs: checks
runs-on: ubuntu-22.04
outputs:
matrix: ${{ steps.platforms.outputs.matrix }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: "22"
- id: platforms
shell: bash
run: node scripts/package.mjs matrix >> "$GITHUB_OUTPUT"

build:
name: Package (${{ matrix.platform }})
needs: prepare
strategy:
fail-fast: false
matrix: ${{ fromJSON(needs.prepare.outputs.matrix) }}
runs-on: ${{ matrix.os }}
timeout-minutes: 90
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup
with:
targets: ${{ matrix.rustTargets }}
- run: pnpm install --frozen-lockfile
- name: Build unsigned test installer
run: node scripts/package.mjs build ${{ matrix.platform }}
env:
CI: "true"
- name: Collect installer and SHA-256
run: node scripts/package.mjs collect ${{ matrix.platform }}
env:
PACKAGE_OUTPUT_DIR: package-assets/${{ matrix.platform }}
- uses: actions/upload-artifact@v4
with:
name: package-${{ matrix.platform }}
path: package-assets/${{ matrix.platform }}/
if-no-files-found: error
retention-days: 14
17 changes: 17 additions & 0 deletions Justfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ check:
test:
pnpm test
pnpm test:release
pnpm test:package
pnpm test:store
cargo test --locked --manifest-path src-tauri/Cargo.toml

Expand All @@ -35,6 +36,22 @@ format:
build:
pnpm build

# 在当前系统生成测试安装包:macOS 为 Intel/Apple Silicon 通用 DMG。
package-local:
node scripts/package.mjs package-local

# 在对应原生系统打包 macos-universal、windows-x64、windows-arm64、linux-x64 或 linux-arm64。
package platform:
node scripts/package.mjs package {{quote(platform)}}

# 从已推送、无本地修改的当前分支触发五平台云端测试打包;不会创建 Release。
package-all branch="":
node scripts/package.mjs dispatch {{quote(branch)}}

# 下载指定 Actions 运行的五平台测试包并校验 SHA-256。
package-download run_id:
node scripts/package.mjs download {{quote(run_id)}}

# 从生成的图标母版导出平台图标。
icons:
pnpm tauri icon assets/power-switch-master.png --output src-tauri/icons
Expand Down
17 changes: 17 additions & 0 deletions docs/releasing.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,22 @@
# 发布说明

## 测试安装包(不发布版本)

`just package-local` 在当前系统打包并收集测试安装包;macOS 始终生成 Intel 与 Apple Silicon 通用 DMG。也可用 `just package macos-universal`、`just package windows-x64`、`just package windows-arm64`、`just package linux-x64` 或 `just package linux-arm64` 明确指定平台。Windows 与 Linux 命令须在对应架构的原生系统执行。命令会检查 Rust 目标库、使用锁定依赖,并把安装包和 `SHA256SUMS` 放在 `artifacts/packages/v<版本>-<提交前 12 位>[-dirty]/<平台>/`。

本地需要 Node.js、pnpm、just 和对应系统的 Tauri 原生依赖。macOS 通用包还需要同时安装 `aarch64-apple-darwin` 与 `x86_64-apple-darwin` Rust 目标;缺少时可使用 rustup 管理工具链并执行 `rustup target add aarch64-apple-darwin x86_64-apple-darwin`。

从 Mac 触发全部五个平台的原生构建:

```sh
just package-all
# 或在已检出该分支时显式指定:just package-all my-branch
gh run list --repo winwin-inc/power-switch --workflow package.yml
just package-download <成功运行的 ID>
```

云端命令要求当前分支工作区干净,且 GitHub 上该分支的提交与本地 `HEAD` 相同。`Package` 工作流只上传保留 14 天的 Actions 工件;下载命令把它们放在 `artifacts/packages/cloud/<运行 ID>/` 并逐平台验证 SHA-256。测试包关闭更新器产物与签名,不创建 GitHub Release,也不能充当正式更新资产。正式版本仍使用下文的标签发布流程;Microsoft Store MSIX 使用独立工作流。

## 分支与版本策略

本项目使用 GitHub Actions 执行持续集成与桌面应用发布,采用以下策略:
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"typecheck": "tsc --noEmit",
"test": "vitest run",
"test:release": "node --test scripts/release.test.mjs",
"test:package": "node --test scripts/package.test.mjs",
"test:store": "node --test scripts/store-msix.test.mjs",
"release:check": "node scripts/release.mjs check",
"format": "prettier --write src scripts docs *.json *.ts *.html *.md .github",
Expand Down
Loading
Loading