fix(ci): publish nightly releases safely

This commit is contained in:
Erwan Leboucher committed 2026-08-20 11:18:24 +02:00
1 parent f5ac580d03
commit baa744f0b4
6 files changed
+53 -38

No files matched your search

+20 -11
View File
@@ -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)}`;
+9 -1
View File
@@ -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) {
+4 -3
View File
@@ -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);