chore(build): move commit to release step and cleanup scripts\n\n- remove build:commit scripts and delete build-and-commit.js\n- add final release commit in release:push\n- update README to reflect new flow\n- document icon emphasis colors in icons/README
This commit is contained in:
parent
99bee995ce
commit
11c0f38526
7 changed files with 68 additions and 108 deletions
|
|
@ -164,7 +164,7 @@ This project is not affiliated with archive.org or aria2. Use responsibly and re
|
|||
- Set environment secrets locally (do not commit): `AMO_JWT_ISSUER=... AMO_JWT_SECRET=...`
|
||||
- Run: `npm run release:sign`
|
||||
- Artifacts land in `releases/<version>/`
|
||||
- Push (self-hosted): `npm run release:push` uploads the signed artifacts in `releases/<version>/` and prepares/uploads `releases/updates.json` automatically (deriving the `update_link` from the manifest’s `applications.gecko.update_url`). It also uploads a stable alias `archive-org-link-grabber-latest.xpi` that always points to the most recent XPI.
|
||||
- Push (self-hosted): `npm run release:push` uploads the signed artifacts in `releases/<version>/` and prepares/uploads `releases/updates.json` automatically (deriving the `update_link` from the manifest’s `applications.gecko.update_url`). It also uploads a stable alias `archive-org-link-grabber-latest.xpi` that always points to the most recent XPI. After upload, it commits `releases/<version>/`, `releases/updates.json`, and updated `icons/` (if changed). Set `GIT_PUSH=true` to push that commit.
|
||||
- Ensure FTP env vars are set (see `.env.example`).
|
||||
|
||||
Notes: Keep AMO secrets local (see `.env.example`). CI is optional. You can tag releases with `git tag vX.Y.Z` and push tags if desired.
|
||||
|
|
|
|||
|
|
@ -16,8 +16,11 @@ Notes
|
|||
-----
|
||||
- Source: `icons/file-search.svg` uses `stroke="currentColor"`.
|
||||
- The build script replaces `currentColor` with configured colors and rasterizes with a transparent background.
|
||||
- Customize colors via env vars:
|
||||
- `ICON_COLOR_ADDON` (48/96/128); default `#111827`.
|
||||
- `ICON_COLOR_TOOLBAR` (16/32); default `#111827`.
|
||||
- Default stroke colors use the project emphasis palette:
|
||||
- Add‑on icons (48/96/128): Primary 2 (deep) `#223544`.
|
||||
- Toolbar icons (16/32): Primary 1 (light) `#5AC3D6`.
|
||||
- Customize via env vars when building:
|
||||
- `ICON_COLOR_ADDON` (48/96/128); default `#223544`.
|
||||
- `ICON_COLOR_TOOLBAR` (16/32); default `#5AC3D6`.
|
||||
- Firefox does not require .ico; PNG is recommended.
|
||||
- Theme variants can be added later via `browser_action.theme_icons`.
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"manifest_version": 2,
|
||||
"name": "Archive.org Link Grabber",
|
||||
"version": "0.3.4",
|
||||
"version": "0.3.5",
|
||||
"description": "Filter and export archive.org /download links; copy or send to aria2 RPC.",
|
||||
"applications": {
|
||||
"gecko": {
|
||||
|
|
|
|||
|
|
@ -7,8 +7,6 @@
|
|||
"dev": "web-ext run --start-url https://archive.org --source-dir .",
|
||||
"build:icons": "node scripts/build-icons.js",
|
||||
"build": "npm run build:icons && web-ext build -o -a dist",
|
||||
"build:commit": "node scripts/build-and-commit.js",
|
||||
"build:commit:push": "PUSH=true node scripts/build-and-commit.js --push",
|
||||
"lint": "echo 'Add ESLint config to enable' && exit 0",
|
||||
"format": "echo 'Add Prettier config to enable' && exit 0",
|
||||
"test": "echo 'No tests yet' && exit 0",
|
||||
|
|
|
|||
|
|
@ -55,6 +55,15 @@
|
|||
"strict_min_version": "91.0"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"version": "0.3.5",
|
||||
"update_link": "https://add-ons.jordanwages.com/archive-org-link-grabber/abf5f9638af544919be4-0.3.5.xpi",
|
||||
"applications": {
|
||||
"gecko": {
|
||||
"strict_min_version": "91.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,101 +0,0 @@
|
|||
#!/usr/bin/env node
|
||||
/*
|
||||
Build + commit (+ optional push) helper.
|
||||
|
||||
- Runs the existing build (`npm run build`)
|
||||
- Stages generated assets (icons by default; optionally dist with INCLUDE_DIST=true)
|
||||
- Commits with a conventional message including the package version
|
||||
- If `--push` or `PUSH=true`, pushes to the current branch's upstream
|
||||
|
||||
Notes:
|
||||
- Respects .gitignore (dist is ignored unless INCLUDE_DIST=true)
|
||||
- Safe no-op when there is nothing to commit
|
||||
*/
|
||||
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const { spawnSync } = require('child_process');
|
||||
|
||||
const REPO = path.join(__dirname, '..');
|
||||
const PKG_PATH = path.join(REPO, 'package.json');
|
||||
|
||||
function run(cmd, args, opts = {}) {
|
||||
const res = spawnSync(cmd, args, { stdio: 'inherit', ...opts });
|
||||
if (res.error) throw res.error;
|
||||
return res.status || 0;
|
||||
}
|
||||
|
||||
function runOut(cmd, args, opts = {}) {
|
||||
const res = spawnSync(cmd, args, { encoding: 'utf8', stdio: ['ignore', 'pipe', 'pipe'], ...opts });
|
||||
if (res.error) throw res.error;
|
||||
return { code: res.status || 0, out: (res.stdout || '').trim(), err: (res.stderr || '').trim() };
|
||||
}
|
||||
|
||||
function ensureGit() {
|
||||
const { code } = runOut('git', ['--version']);
|
||||
if (code !== 0) {
|
||||
console.error('git not found in PATH');
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
function pkgVersion() {
|
||||
const pkg = JSON.parse(fs.readFileSync(PKG_PATH, 'utf8'));
|
||||
return pkg.version || '0.0.0';
|
||||
}
|
||||
|
||||
function main() {
|
||||
ensureGit();
|
||||
|
||||
// 1) Build (icons + xpi)
|
||||
console.log('• Running build…');
|
||||
const codeBuild = run('npm', ['run', 'build'], { cwd: REPO });
|
||||
if (codeBuild !== 0) process.exit(codeBuild);
|
||||
|
||||
// 2) Stage generated assets
|
||||
const includeDist = String(process.env.INCLUDE_DIST || '').toLowerCase() === 'true';
|
||||
console.log('• Staging generated assets…');
|
||||
// Always stage icons (tracked or untracked)
|
||||
run('git', ['add', 'icons/icon-*.png'], { cwd: REPO });
|
||||
if (includeDist) {
|
||||
// dist is ignored; force add if requested
|
||||
run('git', ['add', '-f', 'dist'], { cwd: REPO });
|
||||
}
|
||||
|
||||
// 3) Check if anything is staged
|
||||
const { out: staged } = runOut('git', ['diff', '--cached', '--name-only'], { cwd: REPO });
|
||||
if (!staged) {
|
||||
console.log('✓ Nothing to commit. Up to date.');
|
||||
return;
|
||||
}
|
||||
|
||||
// 4) Commit
|
||||
const version = pkgVersion();
|
||||
const msg = `chore(build): update generated assets (v${version})`;
|
||||
console.log(`• Committing: ${msg}`);
|
||||
const codeCommit = run('git', ['commit', '-m', msg], { cwd: REPO });
|
||||
if (codeCommit !== 0) process.exit(codeCommit);
|
||||
|
||||
// 5) Optional push
|
||||
const shouldPush = process.argv.includes('--push') || String(process.env.PUSH || '').toLowerCase() === 'true';
|
||||
if (!shouldPush) {
|
||||
console.log('✓ Commit created. Skipping push (enable with --push or PUSH=true).');
|
||||
return;
|
||||
}
|
||||
|
||||
console.log('• Pushing to upstream…');
|
||||
// If upstream exists, push; else set upstream to origin/<branch>
|
||||
const { code: upCode } = runOut('git', ['rev-parse', '--abbrev-ref', '--symbolic-full-name', '@{u}'], { cwd: REPO });
|
||||
if (upCode === 0) {
|
||||
const codePush = run('git', ['push'], { cwd: REPO });
|
||||
if (codePush !== 0) process.exit(codePush);
|
||||
} else {
|
||||
const { out: branch } = runOut('git', ['rev-parse', '--abbrev-ref', 'HEAD'], { cwd: REPO });
|
||||
const codePush = run('git', ['push', '-u', 'origin', branch], { cwd: REPO });
|
||||
if (codePush !== 0) process.exit(codePush);
|
||||
}
|
||||
console.log('✓ Pushed.');
|
||||
}
|
||||
|
||||
main();
|
||||
|
||||
|
|
@ -212,3 +212,54 @@ if (fs.existsSync(updatesPath)) {
|
|||
}
|
||||
|
||||
console.log('Upload complete.');
|
||||
|
||||
// After upload, commit generated artifacts to the repo so changes are tracked.
|
||||
try {
|
||||
const { spawnSync } = require('child_process');
|
||||
|
||||
function runGit(args, opts = {}) {
|
||||
const res = spawnSync('git', args, { stdio: 'inherit', cwd: root, ...opts });
|
||||
if (res.error) throw res.error;
|
||||
return res.status || 0;
|
||||
}
|
||||
function runGitOut(args, opts = {}) {
|
||||
const res = spawnSync('git', args, { stdio: ['ignore', 'pipe', 'pipe'], encoding: 'utf8', cwd: root, ...opts });
|
||||
if (res.error) throw res.error;
|
||||
return { code: res.status || 0, out: (res.stdout || '').trim(), err: (res.stderr || '').trim() };
|
||||
}
|
||||
|
||||
console.log('Staging release artifacts for commit…');
|
||||
// Stage updates.json and the current version folder; icons may have changed earlier, include them too.
|
||||
runGit(['add', 'releases/updates.json']);
|
||||
runGit(['add', '-f', path.join('releases', String(version))]);
|
||||
runGit(['add', 'icons/icon-*.png']);
|
||||
|
||||
const { out: staged } = runGitOut(['diff', '--cached', '--name-only']);
|
||||
if (!staged) {
|
||||
console.log('✓ Nothing to commit. Repository already up to date.');
|
||||
} else {
|
||||
const msg = `chore(release): publish v${version} artifacts`;
|
||||
console.log(`Committing: ${msg}`);
|
||||
const codeCommit = runGit(['commit', '-m', msg]);
|
||||
if (codeCommit !== 0) {
|
||||
console.warn('Warning: git commit exited with non-zero status.');
|
||||
} else {
|
||||
// Optional push if requested
|
||||
const doPush = String(process.env.GIT_PUSH || '').toLowerCase() === 'true';
|
||||
if (doPush) {
|
||||
console.log('Pushing commit to upstream…');
|
||||
const { code: upCode } = runGitOut(['rev-parse', '--abbrev-ref', '--symbolic-full-name', '@{u}']);
|
||||
if (upCode === 0) {
|
||||
runGit(['push']);
|
||||
} else {
|
||||
const { out: branch } = runGitOut(['rev-parse', '--abbrev-ref', 'HEAD']);
|
||||
runGit(['push', '-u', 'origin', branch]);
|
||||
}
|
||||
} else {
|
||||
console.log('✓ Commit created. Skipping git push (enable with GIT_PUSH=true).');
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
console.warn('Warning: Failed to create release commit:', e.message);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue