Skip to content

Commit

Permalink
Fix built extension manifest for Chromium compatibility (#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
delucis authored Apr 3, 2023
1 parent fd94151 commit 38735bb
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 12 deletions.
5 changes: 5 additions & 0 deletions .changeset/happy-bikes-train.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'github-to-linear': patch
---

Fix built extension manifest for Chromium browsers.
11 changes: 4 additions & 7 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,20 +34,17 @@ jobs:
- name: Install Dependencies
run: pnpm i

- name: Build extension
run: pnpm build

- name: Submit to Mozilla
- name: Build and submit to Mozilla
if: matrix.command == 'Firefox'
run: npx web-ext-submit@7
run: pnpm build && npx web-ext-submit@7
env:
WEB_EXT_API_KEY: ${{ secrets.WEB_EXT_API_KEY }}
WEB_EXT_API_SECRET: ${{ secrets.WEB_EXT_API_SECRET }}

- name: Submit to Google
- name: Build and submit to Google
if: matrix.command == 'Chrome'
working-directory: ${{ env.WEB_EXT_SOURCE_DIR }}
run: npx chrome-webstore-upload-cli@2 upload --auto-publish
run: pnpm build:chrome && npx chrome-webstore-upload-cli@2 upload --auto-publish
env:
EXTENSION_ID: ${{ secrets.EXTENSION_ID }}
CLIENT_ID: ${{ secrets.CLIENT_ID }}
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"license": "GPL-3.0",
"scripts": {
"build": "node ./scripts/build.mjs",
"build:chrome": "node ./scripts/build.mjs --chromium",
"dev": "pnpm dlx web-ext@7 run",
"dev:chrome": "pnpm dlx web-ext@7 run --target=chromium"
},
Expand Down
21 changes: 16 additions & 5 deletions scripts/build.mjs
Original file line number Diff line number Diff line change
@@ -1,15 +1,26 @@
import fs from 'node:fs/promises';
import pkg from '../package.json' assert { type: 'json' };
import manifest from '../extension/manifest.json' assert { type: 'json' };

console.log('Copying source files to dist...');
await fs.cp('extension', 'dist', { recursive: true });

console.log('Updating version number in manifest.json...');
let manifest = await fs.readFile('dist/manifest.json', 'utf-8');
manifest = manifest.replace(
'"version": "0.0.0"',
`"version": "${pkg.version}"`
manifest.version = pkg.version;

if (process.argv.includes('--chromium')) {
console.log('Updating manifest.json for Chromium compatibility...');
manifest.manifest_version = 3;
const swSource = manifest.background.scripts[0];
manifest.background.service_worker = swSource;
delete manifest.background.scripts;
delete manifest.options_ui.chrome_style;
}

await fs.writeFile(
'dist/manifest.json',
JSON.stringify(manifest, null, 2),
'utf-8'
);
await fs.writeFile('dist/manifest.json', manifest, 'utf-8');

console.log('Done!');

0 comments on commit 38735bb

Please sign in to comment.