Skip to content

Commit 466c411

Browse files
committed
ci: reuse tauri config prep and relax updater mismatch strictness
1 parent 41324a5 commit 466c411

4 files changed

Lines changed: 83 additions & 54 deletions

File tree

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Prepare Tauri Build Config
2+
description: Render temporary Tauri build config and export ASTRBOT_TAURI_CONFIG_PATH.
3+
4+
inputs:
5+
updater-endpoint:
6+
description: Updater latest.json endpoint URL override.
7+
required: false
8+
default: ''
9+
updater-pubkey:
10+
description: Updater public key override.
11+
required: false
12+
default: ''
13+
output-path:
14+
description: Generated Tauri build config path.
15+
required: false
16+
default: src-tauri/tauri.build.config.json
17+
18+
runs:
19+
using: composite
20+
steps:
21+
- name: Render config
22+
shell: bash
23+
run: |
24+
set -euo pipefail
25+
python3 scripts/ci/render-tauri-build-config.py \
26+
--output "${{ inputs.output-path }}" \
27+
--updater-endpoint "${{ inputs.updater-endpoint }}" \
28+
--updater-pubkey "${{ inputs.updater-pubkey }}"
29+
echo "ASTRBOT_TAURI_CONFIG_PATH=${{ inputs.output-path }}" >> "${GITHUB_ENV}"

.github/workflows/build-desktop-tauri.yml

Lines changed: 32 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ env:
5050
# Optional override. When empty, scripts/ci/render-tauri-build-config.py applies the centralized default endpoint.
5151
ASTRBOT_UPDATER_ENDPOINT: ${{ vars.ASTRBOT_UPDATER_ENDPOINT || '' }}
5252
ASTRBOT_UPDATER_PUBKEY: ${{ vars.ASTRBOT_UPDATER_PUBKEY || '' }}
53+
# Strict mode for updater manifest generation on version mismatches.
54+
ASTRBOT_UPDATER_MANIFEST_STRICT_VERSION_MATCH: ${{ vars.ASTRBOT_UPDATER_MANIFEST_STRICT_VERSION_MATCH || '0' }}
5355

5456
jobs:
5557
resolve_build_context:
@@ -203,19 +205,11 @@ jobs:
203205
with:
204206
astrbot_version: ${{ steps.desktop_version.outputs.normalized }}
205207

206-
- name: Prepare Tauri build config (Linux)
207-
env:
208-
ASTRBOT_UPDATER_ENDPOINT: ${{ env.ASTRBOT_UPDATER_ENDPOINT }}
209-
ASTRBOT_UPDATER_PUBKEY: ${{ env.ASTRBOT_UPDATER_PUBKEY }}
210-
shell: bash
211-
run: |
212-
set -euo pipefail
213-
config_path="src-tauri/tauri.build.config.json"
214-
python3 scripts/ci/render-tauri-build-config.py \
215-
--output "${config_path}" \
216-
--updater-endpoint "${ASTRBOT_UPDATER_ENDPOINT}" \
217-
--updater-pubkey "${ASTRBOT_UPDATER_PUBKEY}"
218-
echo "ASTRBOT_TAURI_CONFIG_PATH=${config_path}" >> "${GITHUB_ENV}"
208+
- name: Prepare Tauri build config
209+
uses: ./.github/actions/prepare-tauri-build-config
210+
with:
211+
updater-endpoint: ${{ env.ASTRBOT_UPDATER_ENDPOINT }}
212+
updater-pubkey: ${{ env.ASTRBOT_UPDATER_PUBKEY }}
219213

220214
- name: Build desktop installers (Linux)
221215
env:
@@ -315,19 +309,11 @@ jobs:
315309
--override-source "env:ASTRBOT_MACOS_APP_BUNDLE_NAME" \
316310
--github-output "${GITHUB_OUTPUT}"
317311
318-
- name: Prepare Tauri build config (macOS)
319-
env:
320-
ASTRBOT_UPDATER_ENDPOINT: ${{ env.ASTRBOT_UPDATER_ENDPOINT }}
321-
ASTRBOT_UPDATER_PUBKEY: ${{ env.ASTRBOT_UPDATER_PUBKEY }}
322-
shell: bash
323-
run: |
324-
set -euo pipefail
325-
config_path="src-tauri/tauri.build.config.json"
326-
python3 scripts/ci/render-tauri-build-config.py \
327-
--output "${config_path}" \
328-
--updater-endpoint "${ASTRBOT_UPDATER_ENDPOINT}" \
329-
--updater-pubkey "${ASTRBOT_UPDATER_PUBKEY}"
330-
echo "ASTRBOT_TAURI_CONFIG_PATH=${config_path}" >> "${GITHUB_ENV}"
312+
- name: Prepare Tauri build config
313+
uses: ./.github/actions/prepare-tauri-build-config
314+
with:
315+
updater-endpoint: ${{ env.ASTRBOT_UPDATER_ENDPOINT }}
316+
updater-pubkey: ${{ env.ASTRBOT_UPDATER_PUBKEY }}
331317

332318
- name: Build desktop app bundle (macOS)
333319
env:
@@ -491,19 +477,11 @@ jobs:
491477
with:
492478
astrbot_version: ${{ steps.desktop_version.outputs.normalized }}
493479

494-
- name: Prepare Tauri build config (Windows)
495-
env:
496-
ASTRBOT_UPDATER_ENDPOINT: ${{ env.ASTRBOT_UPDATER_ENDPOINT }}
497-
ASTRBOT_UPDATER_PUBKEY: ${{ env.ASTRBOT_UPDATER_PUBKEY }}
498-
shell: bash
499-
run: |
500-
set -euo pipefail
501-
config_path="src-tauri/tauri.build.config.json"
502-
python3 scripts/ci/render-tauri-build-config.py \
503-
--output "${config_path}" \
504-
--updater-endpoint "${ASTRBOT_UPDATER_ENDPOINT}" \
505-
--updater-pubkey "${ASTRBOT_UPDATER_PUBKEY}"
506-
echo "ASTRBOT_TAURI_CONFIG_PATH=${config_path}" >> "${GITHUB_ENV}"
480+
- name: Prepare Tauri build config
481+
uses: ./.github/actions/prepare-tauri-build-config
482+
with:
483+
updater-endpoint: ${{ env.ASTRBOT_UPDATER_ENDPOINT }}
484+
updater-pubkey: ${{ env.ASTRBOT_UPDATER_PUBKEY }}
507485

508486
- name: Build desktop installers (Windows)
509487
env:
@@ -615,15 +593,25 @@ jobs:
615593
env:
616594
RELEASE_TAG: ${{ needs.resolve_build_context.outputs.release_tag }}
617595
RELEASE_VERSION: ${{ needs.resolve_build_context.outputs.astrbot_version }}
596+
ASTRBOT_UPDATER_MANIFEST_STRICT_VERSION_MATCH: ${{ env.ASTRBOT_UPDATER_MANIFEST_STRICT_VERSION_MATCH }}
618597
shell: bash
619598
run: |
620599
set -euo pipefail
621-
python3 scripts/ci/generate-updater-manifest.py \
622-
--root release-artifacts \
623-
--repository "${GITHUB_REPOSITORY}" \
624-
--release-tag "${RELEASE_TAG}" \
625-
--version "${RELEASE_VERSION}" \
600+
manifest_args=(
601+
--root release-artifacts
602+
--repository "${GITHUB_REPOSITORY}"
603+
--release-tag "${RELEASE_TAG}"
604+
--version "${RELEASE_VERSION}"
626605
--output release-artifacts/latest.json
606+
)
607+
strict_flag="$(printf '%s' "${ASTRBOT_UPDATER_MANIFEST_STRICT_VERSION_MATCH}" | tr '[:upper:]' '[:lower:]')"
608+
case "${strict_flag}" in
609+
1|true|yes|on)
610+
manifest_args+=(--strict-version-match)
611+
;;
612+
esac
613+
python3 scripts/ci/generate-updater-manifest.py \
614+
"${manifest_args[@]}"
627615
628616
- name: Remove existing assets from target release
629617
env:

README.md

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -121,25 +121,30 @@ make signing-key
121121

122122
export TAURI_SIGNING_PRIVATE_KEY_PATH="$HOME/.tauri/astrbot.key"
123123
export TAURI_SIGNING_PRIVATE_KEY_PASSWORD='你的密码'
124+
export ASTRBOT_UPDATER_PUBKEY_FILE="$HOME/.tauri/astrbot.key.pub"
125+
export ASTRBOT_TAURI_BUNDLES="deb,rpm,appimage"
124126

125-
make build-signed \
126-
ASTRBOT_UPDATER_PUBKEY_FILE="$HOME/.tauri/astrbot.key.pub" \
127-
ASTRBOT_TAURI_BUNDLES="deb,rpm,appimage"
127+
make build-signed
128128
```
129129

130130
说明:
131131

132+
- 私钥可用路径变量 `TAURI_SIGNING_PRIVATE_KEY_PATH`,公钥可用路径变量 `ASTRBOT_UPDATER_PUBKEY_FILE`
133+
- 也支持直接传内容:`TAURI_SIGNING_PRIVATE_KEY`(私钥内容)和 `ASTRBOT_UPDATER_PUBKEY`(公钥内容)。
132134
- `make build-signed` 会自动生成临时覆盖配置 `src-tauri/tauri.build.config.json`,并用 `cargo tauri build --config ...` 构建。
133135
- 默认 updater endpoint 由 `scripts/ci/render-tauri-build-config.py` 统一定义(上游地址)。
134136
- 临时覆盖配置已在 `.gitignore` 中,不会误提交。
135137

136138
### 本地切换到 fork 更新源(测试用)
137139

138140
```bash
139-
make build-signed \
140-
ASTRBOT_UPDATER_PUBKEY_FILE="$HOME/.tauri/astrbot.key.pub" \
141-
ASTRBOT_UPDATER_ENDPOINT="https://github.com/<your-name>/AstrBot-desktop/releases/latest/download/latest.json" \
142-
ASTRBOT_TAURI_BUNDLES="deb,rpm,appimage"
141+
export TAURI_SIGNING_PRIVATE_KEY_PATH="$HOME/.tauri/astrbot.key"
142+
export TAURI_SIGNING_PRIVATE_KEY_PASSWORD='你的密码'
143+
export ASTRBOT_UPDATER_PUBKEY_FILE="$HOME/.tauri/astrbot.key.pub"
144+
export ASTRBOT_UPDATER_ENDPOINT="https://github.com/<your-name>/AstrBot-desktop/releases/latest/download/latest.json"
145+
export ASTRBOT_TAURI_BUNDLES="deb,rpm,appimage"
146+
147+
make build-signed
143148
```
144149

145150
注意:`ASTRBOT_UPDATER_ENDPOINT` 对应的发布资产,必须使用与 `ASTRBOT_UPDATER_PUBKEY` 匹配的私钥签名。

scripts/ci/generate-updater-manifest.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,11 @@ def parse_args() -> argparse.Namespace:
4949
required=True,
5050
help="Updater manifest version (SemVer or v-prefixed SemVer).",
5151
)
52+
parser.add_argument(
53+
"--strict-version-match",
54+
action="store_true",
55+
help="Fail when updater artifact version does not match --version.",
56+
)
5257
parser.add_argument("--output", required=True, help="Output latest.json path.")
5358
return parser.parse_args()
5459

@@ -118,12 +123,14 @@ def main() -> int:
118123

119124
if mismatched_versions:
120125
for asset_name, raw_version in mismatched_versions:
126+
level = "::error::" if args.strict_version_match else "::warning::"
121127
print(
122-
"::error::[updater-manifest] "
128+
f"{level}[updater-manifest] "
123129
f"artifact version mismatch: {asset_name} has version {raw_version!r}, "
124-
f"expected {args.version!r}"
130+
f"expected {args.version!r} (normalized: {expected_version!r})"
125131
)
126-
return 1
132+
if args.strict_version_match:
133+
return 1
127134

128135
if not platforms:
129136
print("[updater-manifest] no updater assets found; skip latest.json generation")

0 commit comments

Comments
 (0)