Releases were built and signed in CI, which meant AMO credentials had to live on the runner. Move the whole flow local: builds and Firefox signing happen on the maintainer's machine and only the finished artifacts are published. Add `ext:pack:firefox` and `ext:pack:chrome` (production builds; the Firefox one is signed via `web-ext sign` unlisted with credentials read from the GNOME Keyring through `secret-tool`, the Chrome one is zipped) and wire them to the `version` lifecycle: - `preversion` runs lint and tests. - `version` builds and signs into `web-ext-artifacts/`. - `postversion` pushes the bump commit and tag, then uploads both artifacts to the Gitea release and publishes it if still a draft. Switch the plain `ext:build:*` scripts to production and add `ext:build:dev:*` for development builds; `ext:dev` is unchanged. The build manifest now takes its version from package.json and drops the "(dev)" name suffix when `DASHTAB_RELEASE=1`. Because packaging needs a production build, relax the AGENTS.md production-build restriction to allow it for packaging and releasing.
67 lines
2.0 KiB
JavaScript
67 lines
2.0 KiB
JavaScript
#!/usr/bin/env node
|
|
// Signs the built Firefox extension with addons.mozilla.org (unlisted, so it
|
|
// can be self-distributed). The AMO API credentials are read from the GNOME
|
|
// Keyring via `secret-tool`, so no secret ever lands in a file, an argument
|
|
// list, or the repository.
|
|
//
|
|
// Store the credentials once (Arch + GNOME):
|
|
// secret-tool store --label="Dashtab AMO API key" service dashtab kind amo-api-key
|
|
// secret-tool store --label="Dashtab AMO API secret" service dashtab kind amo-api-secret
|
|
import { execFileSync, spawnSync } from 'node:child_process';
|
|
import { dirname, join } from 'node:path';
|
|
import { fileURLToPath } from 'node:url';
|
|
|
|
const repoRoot = join(dirname(fileURLToPath(import.meta.url)), '..', '..');
|
|
const sourceDir = join(repoRoot, 'extension', 'build', 'firefox');
|
|
const artifactsDir = join(repoRoot, 'web-ext-artifacts');
|
|
const webExt = join(repoRoot, 'node_modules', '.bin', 'web-ext');
|
|
|
|
// The test suite is a dev-only artifact; keep it out of the packaged extension.
|
|
const ignoreFiles = ['tests/**', 'testem.js', 'assets/tests-*'];
|
|
|
|
function keyringSecret(kind, label) {
|
|
try {
|
|
return execFileSync(
|
|
'secret-tool',
|
|
['lookup', 'service', 'dashtab', 'kind', kind],
|
|
{ encoding: 'utf8' },
|
|
).replace(/\n+$/, '');
|
|
} catch {
|
|
console.error(
|
|
`Could not read the AMO credential from the keyring (${kind}).\n` +
|
|
`Store it with:\n` +
|
|
` secret-tool store --label="${label}" service dashtab kind ${kind}`,
|
|
);
|
|
process.exit(1);
|
|
}
|
|
}
|
|
|
|
const apiKey = keyringSecret('amo-api-key', 'Dashtab AMO API key');
|
|
const apiSecret = keyringSecret('amo-api-secret', 'Dashtab AMO API secret');
|
|
|
|
const result = spawnSync(
|
|
webExt,
|
|
[
|
|
'sign',
|
|
'--channel',
|
|
'unlisted',
|
|
'--source-dir',
|
|
sourceDir,
|
|
'--artifacts-dir',
|
|
artifactsDir,
|
|
'--overwrite-dest',
|
|
'--ignore-files',
|
|
...ignoreFiles,
|
|
],
|
|
{
|
|
stdio: 'inherit',
|
|
env: {
|
|
...process.env,
|
|
WEB_EXT_API_KEY: apiKey,
|
|
WEB_EXT_API_SECRET: apiSecret,
|
|
},
|
|
},
|
|
);
|
|
|
|
process.exit(result.status ?? 1);
|