Desktop release pipeline: privacy scan of every artifact, path-free builds, macOS universal app + DMG (Developer ID + notarization or an ad-hoc -unsigned preview) with self-tests of the exact artifacts, signed latest.json, Forgejo workflow for Linux and Windows, root-owned publish step for storebound.dev
This commit is contained in:
parent
19909ff665
commit
edb07c7843
7 changed files with 1203 additions and 0 deletions
88
tests/desktop-release.test.ts
Normal file
88
tests/desktop-release.test.ts
Normal file
|
|
@ -0,0 +1,88 @@
|
|||
// tools/desktop-release.ts and tools/desktop-version.ts: the pure parts of the desktop release pipeline.
|
||||
import { describe, expect, test } from 'bun:test';
|
||||
import { cpSync, mkdirSync, mkdtempSync, readFileSync, writeFileSync } from 'node:fs';
|
||||
import { tmpdir } from 'node:os';
|
||||
import { join } from 'node:path';
|
||||
import { artifactName, developerIdIdentity, mergeManifest, pathFreeEnv, releaseUrl, remoteSessionReason, sumsText, uploadable } from '../tools/desktop-release';
|
||||
import { COPIES, setVersion, versions } from '../tools/desktop-version';
|
||||
|
||||
describe('desktop version authority', () => {
|
||||
test('the repository has one desktop version', () => {
|
||||
const { version, drift } = versions();
|
||||
expect(version).toMatch(/^\d+\.\d+\.\d+$/);
|
||||
expect(drift).toEqual([]);
|
||||
});
|
||||
test('drift is found and --set fixes every copy', () => {
|
||||
const root = mkdtempSync(join(tmpdir(), 'sb-ver-'));
|
||||
for (const c of COPIES) { mkdirSync(join(root, c.file, '..'), { recursive: true }); cpSync(join(import.meta.dir, '..', c.file), join(root, c.file)); }
|
||||
const conf = join(root, 'apps/desktop/src-tauri/tauri.conf.json');
|
||||
writeFileSync(conf, readFileSync(conf, 'utf8').replace(/"version": "[^"]+"/, '"version": "9.9.9"'));
|
||||
expect(versions(root).drift.map(d => d.file)).toEqual(['apps/desktop/src-tauri/tauri.conf.json']);
|
||||
setVersion('0.2.0-beta.1', root);
|
||||
expect(versions(root)).toEqual({ version: '0.2.0-beta.1', drift: [] });
|
||||
// only the package's own version line of Cargo.toml / Cargo.lock changes
|
||||
expect(readFileSync(join(root, 'apps/desktop/src-tauri/Cargo.toml'), 'utf8')).toContain('tauri = { version = "2.12"');
|
||||
expect(() => setVersion('latest', root)).toThrow();
|
||||
});
|
||||
});
|
||||
|
||||
describe('desktop release', () => {
|
||||
test('signing refuses SSH and non-GUI sessions', () => {
|
||||
expect(remoteSessionReason({}, 'Aqua')).toBeNull();
|
||||
expect(remoteSessionReason({ SSH_CONNECTION: '1 2 3 4' }, 'Aqua')).toMatch(/SSH/);
|
||||
expect(remoteSessionReason({ SSH_TTY: '/dev/ttys001' }, 'Aqua')).toMatch(/SSH/);
|
||||
expect(remoteSessionReason({}, 'Background')).toMatch(/GUI session/);
|
||||
});
|
||||
test('only a Developer ID Application identity signs a release', () => {
|
||||
const out = ` 1) ${'A'.repeat(40)} "Apple Distribution: Example Studio (TEAM000001)"
|
||||
2) ${'B'.repeat(40)} "Apple Development: Example Person (TEAM000002)"
|
||||
2 valid identities found`;
|
||||
expect(developerIdIdentity(out)).toBeNull();
|
||||
expect(developerIdIdentity(`${out}\n 3) ${'C'.repeat(40)} "Developer ID Application: Example Studio (TEAM000001)"`)).toBe('Developer ID Application: Example Studio (TEAM000001)');
|
||||
});
|
||||
test('artifact names say when a build is unsigned', () => {
|
||||
expect(artifactName('0.1.0', 'dmg', false)).toBe('storebound_0.1.0_universal-unsigned.dmg');
|
||||
expect(artifactName('0.1.0', 'updater', true)).toBe('storebound_0.1.0_universal.app.tar.gz');
|
||||
expect(artifactName('0.1.0', 'nsis', false)).toBe('storebound_0.1.0_x64-setup-unsigned.exe');
|
||||
expect(artifactName('0.1.0', 'appimage', false)).toBe('storebound_0.1.0_amd64.AppImage');
|
||||
expect(releaseUrl('0.1.0', 'a.dmg')).toBe('https://storebound.dev/desktop/dl/0.1.0/a.dmg');
|
||||
});
|
||||
test('path-free build: home, checkout, cargo, rustup and target dir are remapped, general first', () => {
|
||||
const env = pathFreeEnv('/Users/you/src/storebound', { CARGO_TARGET_DIR: '/tmp/t', RUSTFLAGS: '-Cforce-frame-pointers=yes', CFLAGS: '-O2' }, '/Users/you');
|
||||
const flags = env.CARGO_ENCODED_RUSTFLAGS!.split('\x1f');
|
||||
expect(flags).toEqual([
|
||||
'-Cforce-frame-pointers=yes',
|
||||
'--remap-path-prefix=/Users/you=~',
|
||||
'--remap-path-prefix=/Users/you/src/storebound=/src',
|
||||
'--remap-path-prefix=/tmp/t=/target',
|
||||
'--remap-path-prefix=/Users/you/.cargo=/cargo',
|
||||
'--remap-path-prefix=/Users/you/.rustup=/rustup',
|
||||
]);
|
||||
expect(env.CFLAGS).toStartWith('-O2 -ffile-prefix-map=/Users/you=~');
|
||||
expect(env.CXXFLAGS).toContain('-ffile-prefix-map=/Users/you/.rustup=/rustup');
|
||||
const w = pathFreeEnv('C:\\src\\storebound', { CARGO_TARGET_DIR: 'C:\\t' }, 'C:\\Users\\you', 'win32');
|
||||
const wf = w.CARGO_ENCODED_RUSTFLAGS!.split('\x1f');
|
||||
expect(wf).toContain('--remap-path-prefix=C:\\Users\\you=~');
|
||||
expect(wf).toContain('--remap-path-prefix=\\\\?\\C:\\Users\\you=~');
|
||||
expect(wf).toContain('-Clink-arg=/PDBALTPATH:%_PDB%');
|
||||
expect(w.CL).toContain('"/d1trimfile:C:\\Users\\you\\.rustup/"');
|
||||
expect(w.LINK).toBe('/PDBALTPATH:%_PDB%');
|
||||
expect(w.CFLAGS).toBeUndefined();
|
||||
});
|
||||
test('latest.json keeps the other platforms of the same version, a new version starts fresh', () => {
|
||||
const mac = { platforms: { 'darwin-aarch64': { signature: 's', url: 'https://storebound.dev/desktop/dl/0.1.0/m.app.tar.gz' } } };
|
||||
const win = { platforms: { 'windows-x86_64': { signature: 'w', url: 'https://storebound.dev/desktop/dl/0.1.0/w.exe' } } };
|
||||
const one = mergeManifest(null, '0.1.0', 'first', '2026-10-11T00:00:00Z', mac);
|
||||
const two = mergeManifest(one, '0.1.0', 'other notes', '2026-10-12T00:00:00Z', win);
|
||||
expect(Object.keys(two.platforms)).toEqual(['darwin-aarch64', 'windows-x86_64']);
|
||||
expect(two.notes).toBe('first');
|
||||
expect(two.pub_date).toBe('2026-10-12T00:00:00Z');
|
||||
expect(Object.keys(mergeManifest(two, '0.1.1', 'n', 'x', win).platforms)).toEqual(['windows-x86_64']);
|
||||
});
|
||||
test('SHA256SUMS and what is uploaded', () => {
|
||||
expect(sumsText([{ file: 'b', sha256: '2' }, { file: 'a', sha256: '1' }])).toBe('1 a\n2 b\n');
|
||||
expect(uploadable('storebound_0.1.0_universal-unsigned.dmg')).toBe(true);
|
||||
expect(uploadable('latest.json')).toBe(true);
|
||||
for (const n of ['evidence-macos-0.1.0.json', '.DS_Store', 'latest.json.part', 'a b.dmg']) expect(uploadable(n)).toBe(false);
|
||||
});
|
||||
});
|
||||
67
tests/privacy-scan.test.ts
Normal file
67
tests/privacy-scan.test.ts
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
// tools/privacy-scan.ts: the release gate over every desktop artifact. Made-up terms only (the real ones live in a
|
||||
// file outside the repository).
|
||||
import { describe, expect, test } from 'bun:test';
|
||||
import { spawnSync } from 'node:child_process';
|
||||
import { mkdirSync, mkdtempSync, writeFileSync } from 'node:fs';
|
||||
import { tmpdir } from 'node:os';
|
||||
import { join } from 'node:path';
|
||||
import { collectTerms, kindOf, mask, parseTerms, scan, scanBuffer, type Term } from '../tools/privacy-scan';
|
||||
|
||||
const T: Term[] = [{ text: 'Quillfeather', short: false }, { text: 'qz', short: true }];
|
||||
// home folders are put together at run time, so tools/scrub.ts (which forbids them in the repository) passes
|
||||
const home = (root: string, name: string): string => `${root}${name}`;
|
||||
|
||||
describe('privacy scan', () => {
|
||||
test('terms: comments and blanks skipped, never printed in full', () => {
|
||||
expect(parseTerms('# names\nQuillfeather\n\n qz \n')).toEqual(['Quillfeather', 'qz']);
|
||||
expect(mask('Quillfeather')).toBe('Q***');
|
||||
const dir = mkdtempSync(join(tmpdir(), 'sb-terms-'));
|
||||
writeFileSync(join(dir, 't.txt'), `Quillfeather\nCRT\n${['hi', 'crt.fyi'].join('@')}\n`);
|
||||
// the release identity is never a forbidden term
|
||||
expect(collectTerms(join(dir, 't.txt'), false).map(t => t.text)).toEqual(['Quillfeather']);
|
||||
});
|
||||
|
||||
test('finds a term in any case, in UTF-8 and UTF-16LE', () => {
|
||||
const hits = scanBuffer('bin', Buffer.concat([Buffer.from('xx QUILLFEATHER yy'), Buffer.from('built by quillFeather', 'utf16le')]), T);
|
||||
expect(hits.map(h => h.encoding)).toEqual(['utf8', 'utf16le']);
|
||||
expect(hits.every(h => h.what === 'term Q***')).toBe(true);
|
||||
expect(scanBuffer('bin', Buffer.from('nothing to see'), T)).toEqual([]);
|
||||
});
|
||||
|
||||
test('a short term counts only in a path', () => {
|
||||
expect(scanBuffer('bin', Buffer.from('jazz quiz qz-mode'), T)).toEqual([]);
|
||||
expect(scanBuffer('bin', Buffer.from('/opt/qz/src'), T).some(h => h.what === 'term q***')).toBe(true);
|
||||
});
|
||||
|
||||
test('home folders of any account, generic ones allowed', () => {
|
||||
const hits = scanBuffer('bin', Buffer.from(`${home('/Users/', 'someone')}/work /home/runner/work ${home('C:\\Users\\', 'other')}\\x /Users/you/app /home/$USER`), []);
|
||||
expect(hits.map(h => h.what)).toEqual(['home folder of an account (s***)', 'home folder of an account (o***)']);
|
||||
});
|
||||
|
||||
test('folders, archives and debug files', () => {
|
||||
const dir = mkdtempSync(join(tmpdir(), 'sb-scan-'));
|
||||
mkdirSync(join(dir, 'pkg/My.app/Contents'), { recursive: true });
|
||||
writeFileSync(join(dir, 'pkg/My.app/Contents/clean.txt'), 'all good');
|
||||
writeFileSync(join(dir, 'pkg/My.app/Contents/leak.bin'), Buffer.from(`panic at ${home('/Users/', 'quillfeather')}/src/main.rs`, 'utf8'));
|
||||
mkdirSync(join(dir, 'pkg/My.app.dSYM'));
|
||||
expect(spawnSync('tar', ['-czf', join(dir, 'bundle.tar.gz'), '-C', join(dir, 'pkg'), '.']).status).toBe(0);
|
||||
const r = scan([join(dir, 'bundle.tar.gz')], null, false);
|
||||
expect(r.errors).toEqual([]);
|
||||
const shown = r.hits.map(h => `${h.file}: ${h.what}`);
|
||||
expect(shown.some(s => s.startsWith('bundle.tar.gz!/') && s.includes('leak.bin') && s.includes('home folder'))).toBe(true);
|
||||
expect(shown.some(s => s.includes('My.app.dSYM: debug file'))).toBe(true);
|
||||
expect(r.files).toBeGreaterThanOrEqual(3);
|
||||
const clean = scan([join(dir, 'pkg/My.app/Contents/clean.txt')], null, false);
|
||||
expect(clean.hits).toEqual([]);
|
||||
expect(scan([join(dir, 'missing.dmg')], null, false).errors).toHaveLength(1);
|
||||
});
|
||||
|
||||
test('container kinds', () => {
|
||||
expect(kindOf('a/storebound_0.1.0_universal.dmg', new Uint8Array())).toBe('dmg');
|
||||
expect(kindOf('storebound_0.1.0_universal.app.tar.gz', new Uint8Array())).toBe('tar');
|
||||
expect(kindOf('storebound_0.1.0_amd64.deb', new Uint8Array())).toBe('deb');
|
||||
expect(kindOf('storebound_0.1.0_amd64.AppImage', new Uint8Array())).toBe('appimage');
|
||||
expect(kindOf('storebound_0.1.0_x64-setup.exe', Buffer.from('MZ....Nullsoft Install System'))).toBe('nsis');
|
||||
expect(kindOf('storebound-desktop.exe', Buffer.from('MZ'))).toBe('file');
|
||||
});
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue