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
23 changes: 22 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,21 @@ jobs:
shell: bash
working-directory: src-tauri
# В пакет npm входит готовый CLI: никакого десятиминутного `cargo install`.
# Без ключа обновлений установщики всё равно собираются. Подписи нужны только
# для обновления из уже установленного приложения.
env:
TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY }}
TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY_PASSWORD }}
run: npx --yes @tauri-apps/cli@2 build --config '{"bundle":{"createUpdaterArtifacts":true}}' --bundles ${{ matrix.bundles }} ${{ matrix.target && format('--target {0}', matrix.target) || '' }}
run: |
set -euo pipefail
args=(npx --yes @tauri-apps/cli@2 build --bundles ${{ matrix.bundles }})
if [ -n "${{ matrix.target }}" ]; then args+=(--target "${{ matrix.target }}"); fi
if [ -n "${TAURI_SIGNING_PRIVATE_KEY}" ]; then
args+=(--config '{"bundle":{"createUpdaterArtifacts":true}}')
else
echo "::warning::TAURI_SIGNING_PRIVATE_KEY is not set. Installers will be published without in-app update signatures."
fi
"${args[@]}"

- name: Sign desktop updater packages (including DEB)
shell: bash
Expand All @@ -111,6 +122,10 @@ jobs:
VERSION: ${{ needs.version.outputs.version }}
run: |
set -euo pipefail
if [ -z "${TAURI_SIGNING_PRIVATE_KEY}" ]; then
echo "No updater key: skipping signatures."
exit 0
fi
find target -type f \( -name '*-setup.exe' -o -name '*.AppImage' -o -name '*.deb' -o -name '*.app.tar.gz' \) -path '*/release/bundle/*' -print0 | while IFS= read -r -d '' file; do
npx --yes @tauri-apps/cli@2 signer sign --app-version "$VERSION" "$file"
done
Expand Down Expand Up @@ -313,6 +328,12 @@ jobs:
cat >> "$notes" <<'EOF'

> **Подпись Android.** Секреты `ANDROID_KEYSTORE_BASE64`, `ANDROID_KEYSTORE_PASSWORD`, `ANDROID_KEY_ALIAS` и `ANDROID_KEY_PASSWORD` не заданы, поэтому APK подписан временным отладочным ключом этой сборки. Файл устанавливается, но не обновляет уже установленную копию, и следующий выпуск не встанет поверх него. Постоянный ключ нужен, чтобы обновления с GitHub Releases сохраняли данные; как его создать, написано в docs/android.md.
EOF
fi
if [ -f out/UPDATER_DISABLED ]; then
cat >> "$notes" <<'EOF'

> **Обновление на компьютере.** Секреты `TAURI_SIGNING_PRIVATE_KEY` и `TAURI_SIGNING_PRIVATE_KEY_PASSWORD` не заданы. Установщики Windows, macOS и Linux в этом выпуске ставятся вручную. Обновление из уже установленного приложения заработает после добавления ключа.
EOF
fi
gh release create "$TAG" out/* --repo "$REPO" --target "$GITHUB_SHA" --latest \
Expand Down
68 changes: 44 additions & 24 deletions scripts/prepare-release.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,39 @@ def prepare(parts, android, out, version, repo):
raise ValueError("expected a stable semantic version")
if not re.fullmatch(r"[A-Za-z0-9_.-]+/[A-Za-z0-9_.-]+", repo):
raise ValueError("invalid repository")
# Require each artifact exactly once. No partial release or ambiguous payload.
expected = {
# Installers are required. Updater signatures are required only when the
# desktop signing key was used (any signature or updater archive is present).
# A release with no signatures still publishes installable files.
installers = {
"*-setup.exe": f"PrivateMusic_{version}_windows-x64-setup.exe",
"*-setup.exe.sig": f"PrivateMusic_{version}_windows-x64-setup.exe.sig",
"*.dmg": f"PrivateMusic_{version}_macos-universal.dmg",
"*.deb": f"PrivateMusic_{version}_linux-amd64.deb",
"*.AppImage": f"PrivateMusic_{version}_linux-amd64.AppImage",
}
signatures = {
"*-setup.exe.sig": f"PrivateMusic_{version}_windows-x64-setup.exe.sig",
"*.app.tar.gz": f"PrivateMusic_{version}_macos-universal.app.tar.gz",
"*.app.tar.gz.sig": f"PrivateMusic_{version}_macos-universal.app.tar.gz.sig",
"*.deb": f"PrivateMusic_{version}_linux-amd64.deb",
"*.deb.sig": f"PrivateMusic_{version}_linux-amd64.deb.sig",
"*.AppImage": f"PrivateMusic_{version}_linux-amd64.AppImage",
"*.AppImage.sig": f"PrivateMusic_{version}_linux-amd64.AppImage.sig",
}
sources = {}
for pattern, name in expected.items():
def take(pattern):
found = [p for p in parts.rglob(pattern) if p.is_file() and p.stat().st_size]
if len(found) != 1:
if len(found) > 1:
raise ValueError(f"expected one {pattern}, found {len(found)}")
sources[name] = found[0]
return found[0] if found else None
sources = {}
for pattern, name in installers.items():
found = take(pattern)
if found is None:
raise ValueError(f"expected one {pattern}, found 0")
sources[name] = found
signed = {name: take(pattern) for pattern, name in signatures.items()}
updater = any(signed.values())
if updater and any(path is None for path in signed.values()):
raise ValueError("updater signatures are incomplete")
if updater:
sources.update({name: path for name, path in signed.items() if path is not None})
apk_name = f"PrivateMusic_{version}_android-arm64.apk"
apks = list(android.rglob("*.apk"))
if len(apks) != 1 or apks[0].name != apk_name or not apks[0].stat().st_size:
Expand All @@ -42,21 +57,26 @@ def prepare(parts, android, out, version, repo):
shutil.copyfile(source, out / name)
base = f"https://github.com/{repo}/releases/download/v{version}/"
platforms = {}
for target, suffix in {
"windows-x86_64-nsis": "windows-x64-setup.exe",
"darwin-aarch64-app": "macos-universal.app.tar.gz",
"darwin-x86_64-app": "macos-universal.app.tar.gz",
"linux-x86_64-appimage": "linux-amd64.AppImage",
"linux-x86_64-deb": "linux-amd64.deb",
}.items():
name = f"PrivateMusic_{version}_{suffix}"
signature = (out / (name + ".sig")).read_text().strip()
if not signature:
raise ValueError(f"missing signature for {name}")
platforms[target] = {"url": base + name, "signature": signature}
manifest = {"version": version, "notes": f"Private Music {version}",
"pub_date": datetime.datetime.now(datetime.timezone.utc).isoformat(), "platforms": platforms}
(out / "latest.json").write_text(json.dumps(manifest, ensure_ascii=False, indent=2) + "\n")
if updater:
for target, suffix in {
"windows-x86_64-nsis": "windows-x64-setup.exe",
"darwin-aarch64-app": "macos-universal.app.tar.gz",
"darwin-x86_64-app": "macos-universal.app.tar.gz",
"linux-x86_64-appimage": "linux-amd64.AppImage",
"linux-x86_64-deb": "linux-amd64.deb",
}.items():
name = f"PrivateMusic_{version}_{suffix}"
signature = (out / (name + ".sig")).read_text().strip()
if not signature:
raise ValueError(f"missing signature for {name}")
platforms[target] = {"url": base + name, "signature": signature}
if updater:
manifest = {"version": version, "notes": f"Private Music {version}",
"pub_date": datetime.datetime.now(datetime.timezone.utc).isoformat(), "platforms": platforms}
(out / "latest.json").write_text(json.dumps(manifest, ensure_ascii=False, indent=2) + "\n")
else:
(out / "UPDATER_DISABLED").write_text(
"Desktop updater signatures were not produced. Set TAURI_SIGNING_PRIVATE_KEY and TAURI_SIGNING_PRIVATE_KEY_PASSWORD.\n")
lines = []
for path in sorted(out.iterdir()):
with path.open("rb") as stream:
Expand Down
14 changes: 14 additions & 0 deletions scripts/test_prepare_release.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,20 @@ def test_duplicate_payload_blocks_the_entire_release(self):
with self.assertRaises(ValueError): self.run_prepare()
self.assertFalse(self.out.exists())

def test_installers_publish_when_the_updater_key_was_not_used(self):
for path in list(self.parts.iterdir()):
if path.name.endswith('.sig') or path.name.endswith('.tar.gz'):
path.unlink()
self.run_prepare()
names = sorted(path.name for path in self.out.iterdir())
self.assertIn('PrivateMusic_0.6.6_windows-x64-setup.exe', names)
self.assertIn('PrivateMusic_0.6.6_linux-amd64.deb', names)
self.assertIn('PrivateMusic_0.6.6_linux-amd64.AppImage', names)
self.assertIn('PrivateMusic_0.6.6_macos-universal.dmg', names)
self.assertIn('PrivateMusic_0.6.6_android-arm64.apk', names)
self.assertFalse((self.out / 'latest.json').exists())
self.assertTrue((self.out / 'UPDATER_DISABLED').is_file())

def test_unsigned_android_is_not_published_as_installable(self):
apk = next(self.android.iterdir())
apk.rename(apk.with_name('PrivateMusic_0.6.6_android-arm64-unsigned.apk'))
Expand Down
Loading