From baa744f0b4020316b2aac8742f8f4ae6fbcc1b32 Mon Sep 17 00:00:00 2001 From: Erwan Leboucher Date: Thu, 20 Aug 2026 11:18:24 +0200 Subject: [PATCH] fix(ci): publish nightly releases safely --- .github/scripts/build-updater-manifest.mjs | 31 +++++++++++------- .github/scripts/release-meta.mjs | 10 +++++- .github/scripts/set-tauri-version.mjs | 7 ++-- .../templates/altstore-source-nightly.json | 6 ++-- .github/workflows/tauri-build.yml | 32 ++++++++----------- scripts/obtainium-generate.js | 5 +-- 6 files changed, 53 insertions(+), 38 deletions(-) diff --git a/.github/scripts/build-updater-manifest.mjs b/.github/scripts/build-updater-manifest.mjs index de1245c13..eecf2f1b2 100644 --- a/.github/scripts/build-updater-manifest.mjs +++ b/.github/scripts/build-updater-manifest.mjs @@ -6,7 +6,6 @@ import { execSync } from 'node:child_process'; import { readFileSync, readdirSync, writeFileSync, mkdtempSync } from 'node:fs'; import { tmpdir } from 'node:os'; import { join } from 'node:path'; -import { resolveReleaseMeta } from './release-meta.mjs'; const TAG = process.env.TAG; const VERSION = process.env.VERSION; @@ -21,18 +20,28 @@ if (!/^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/.test(VERSION)) { } const version = VERSION; -const { isNightly } = resolveReleaseMeta({ - eventName: process.env.EVENT_NAME, - inputTag: process.env.INPUT_TAG, - gitRef: process.env.GIT_REF, - gitRefName: process.env.GIT_REF_NAME, - gitSha: process.env.GIT_SHA, -}); +const isNightly = process.env.IS_NIGHTLY === 'true'; const dir = mkdtempSync(join(tmpdir(), 'sable-sigs-')); -execSync(`gh release download "${TAG}" --repo "${REPO}" --pattern '*.sig' --dir "${dir}"`, { - stdio: 'inherit', -}); +const signaturePattern = `Sable-${VERSION}-*.sig`; +const signatures = execSync( + `gh release view "${TAG}" --repo "${REPO}" --json assets --jq '.assets[].name'`, + { encoding: 'utf8' } +) + .split('\n') + .filter((name) => name.startsWith(`Sable-${VERSION}-`) && name.endsWith('.sig')); + +if (signatures.length === 0) { + console.warn('No signed artifacts found for this version; skipping updater manifest.'); + process.exit(0); +} + +execSync( + `gh release download "${TAG}" --repo "${REPO}" --pattern "${signaturePattern}" --dir "${dir}"`, + { + stdio: 'inherit', + } +); const urlFor = (name) => `https://github.com/${REPO}/releases/download/${TAG}/${encodeURIComponent(name)}`; diff --git a/.github/scripts/release-meta.mjs b/.github/scripts/release-meta.mjs index 3cd91e089..b835d9af1 100644 --- a/.github/scripts/release-meta.mjs +++ b/.github/scripts/release-meta.mjs @@ -38,7 +38,15 @@ export function nightlyVersion() { } } catch {} - return computeNightlyVersion(version, timestamp); + let sha = 'local'; + try { + sha = execSync('git rev-parse --short=12 HEAD', { + encoding: 'utf8', + stdio: ['ignore', 'pipe', 'ignore'], + }).trim(); + } catch {} + + return `${computeNightlyVersion(version, timestamp)}.${sha}`; } export async function writeOutputs(outputPath, entries) { diff --git a/.github/scripts/set-tauri-version.mjs b/.github/scripts/set-tauri-version.mjs index 79d7ab02e..3fb5a0ba3 100644 --- a/.github/scripts/set-tauri-version.mjs +++ b/.github/scripts/set-tauri-version.mjs @@ -38,9 +38,10 @@ const sanitizedVersion = version.replace(/^(\d+\.\d+\.\d+-nightly)\.(.+)$/, (_, // overflows the u32 Tauri parses each version part into. let stampedVersion = sanitizedVersion; if (foldNightlyIntoPatch) { - const nightly = /^(\d+\.\d+)\.\d+-nightly\.(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})$/.exec( - sanitizedVersion - ); + const nightly = + /^(\d+\.\d+)\.\d+-nightly\.(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})(?:\.[0-9A-Za-z-]+)?$/.exec( + sanitizedVersion + ); if (!nightly) { console.error(`--apple-short-version needs a nightly version (got: ${sanitizedVersion})`); process.exit(1); diff --git a/.github/templates/altstore-source-nightly.json b/.github/templates/altstore-source-nightly.json index 9a159046a..2eca6db7a 100644 --- a/.github/templates/altstore-source-nightly.json +++ b/.github/templates/altstore-source-nightly.json @@ -6,11 +6,11 @@ "iconURL": "https://raw.githubusercontent.com/SableClient/Sable/dev/src-tauri/icons/icon.png", "website": "https://github.com/SableClient/Sable", "tintColor": "#5CA399", - "featuredApps": ["moe.sable.client"], + "featuredApps": ["moe.sable.client.nightly"], "apps": [ { - "name": "Sable", - "bundleIdentifier": "moe.sable.client", + "name": "Sable Nightly", + "bundleIdentifier": "moe.sable.client.nightly", "developerName": "SableClient", "subtitle": "Sable iOS (nightly)", "localizedDescription": "Sable for iOS. Nightly builds from dev; unsigned, resigned at install by AltStore/SideStore.", diff --git a/.github/workflows/tauri-build.yml b/.github/workflows/tauri-build.yml index 221282f42..7c677f31d 100644 --- a/.github/workflows/tauri-build.yml +++ b/.github/workflows/tauri-build.yml @@ -558,18 +558,8 @@ jobs: shell: bash env: GH_TOKEN: ${{ github.token }} - NEEDS_SETUP_RELEASE_OUTPUTS_NIGHTLY: ${{ needs.setup-release.outputs.nightly }} + IS_NIGHTLY: ${{ needs.setup-release.outputs.nightly }} run: | - if [ "${NEEDS_SETUP_RELEASE_OUTPUTS_NIGHTLY}" = "true" ]; then - gh release view "$TAG" --json assets \ - | jq -r --arg cutoff "$STARTED_AT" \ - '.assets[] | select(.updatedAt <= $cutoff and (.name | endswith(".sig"))) | .name' \ - | while read -r name; do - [ -n "$name" ] || continue - echo "Removing superseded nightly signature: $name" - gh release delete-asset "$TAG" "$name" --yes - done - fi node .github/scripts/build-updater-manifest.mjs if [ -f latest.json ]; then echo "produced=true" >> "$GITHUB_OUTPUT" @@ -584,13 +574,6 @@ jobs: with: subject-path: latest.json - - name: Upload updater manifest - if: steps.manifest.outputs.produced == 'true' - shell: bash - env: - GH_TOKEN: ${{ github.token }} - run: gh release upload "$TAG" latest.json --clobber - - name: Finalize nightly release if: ${{ needs.setup-release.outputs.nightly == 'true' && steps.manifest.outputs.produced == 'true' }} shell: bash @@ -606,6 +589,19 @@ jobs: --title "Nightly (dev)" \ --notes "Rolling nightly build $VERSION from dev — $GIT_SHA" + - name: Upload updater manifest + if: steps.manifest.outputs.produced == 'true' + shell: bash + env: + GH_TOKEN: ${{ github.token }} + run: gh release upload "$TAG" latest.json --clobber + + - name: Remove superseded nightly assets + if: ${{ needs.setup-release.outputs.nightly == 'true' && steps.manifest.outputs.produced == 'true' }} + shell: bash + env: + GH_TOKEN: ${{ github.token }} + run: | # .json manifests are overwritten in place, not accumulated. gh release view nightly --json assets \ | jq -r --arg cutoff "$STARTED_AT" \ diff --git a/scripts/obtainium-generate.js b/scripts/obtainium-generate.js index dd669a7c0..d887c6f1d 100644 --- a/scripts/obtainium-generate.js +++ b/scripts/obtainium-generate.js @@ -20,6 +20,7 @@ const GITHUB_REPO = 'SableClient/Sable'; const APK_NAME = `Sable-${version}-android-universal.apk`; const APK_URL = `https://github.com/${GITHUB_REPO}/releases/download/${tag}/${APK_NAME}`; const isNightly = tag === 'nightly'; +const appId = isNightly ? 'moe.sable.client.nightly' : 'moe.sable.client'; // Obtainium fills in every other setting from its own defaults on import. const additionalSettings = { @@ -36,10 +37,10 @@ const additionalSettings = { const config = { apps: [ { - id: 'moe.sable.client', + id: appId, url: `https://github.com/${GITHUB_REPO}`, author: 'SableClient', - name: 'Sable', + name: isNightly ? 'Sable Nightly' : 'Sable', installedVersion: null, latestVersion: version, apkUrls: JSON.stringify([[APK_NAME, APK_URL]]),