From c841aa2c1ad68cd97988262c37175f96f26b76a0 Mon Sep 17 00:00:00 2001 From: Perry Mitchell Date: Thu, 21 Mar 2024 22:26:03 +0200 Subject: [PATCH] Setup release commands --- .github/workflows/test.yml | 13 +++++++++++++ package.json | 11 ++++++----- webpack.config.js | 3 ++- 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 2612e32e..59157ff0 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -16,3 +16,16 @@ jobs: node-version: ${{ matrix.node-version }} - run: npm ci - run: npm run test:format + release: + runs-on: ubuntu-latest + strategy: + matrix: + node-version: [20.x] + steps: + - uses: actions/checkout@v2 + - name: Node.js specs ${{ matrix.node-version }} + uses: actions/setup-node@v1 + with: + node-version: ${{ matrix.node-version }} + - run: npm ci + - run: npm run release diff --git a/package.json b/package.json index afa5971c..3596c010 100644 --- a/package.json +++ b/package.json @@ -6,8 +6,9 @@ "type": "module", "types": "./dist/background/index.d.ts", "scripts": { - "build": "run-s clean set-version build:production", + "build": "run-s set-version build:production", "build:chrome": "BROWSER=chrome npm run build", + "build:edge": "BROWSER=edge npm run build", "build:firefox": "BROWSER=firefox npm run build", "build:production": "webpack --mode production --progress --config webpack.config.js", "clean": "rimraf dist/* release/*", @@ -15,10 +16,10 @@ "dev:chrome": "BROWSER=chrome npm run dev", "dev:firefox": "concurrently -k \"BROWSER=firefox npm run dev\" \"cd dist && web-ext run\" --restart-tries 20 --restart-after 5000", "format": "prettier --write '{{source,test}/**/*.{ts,js},webpack.config.js}'", - "release": "npm run build && mkdirp release release/chrome release/firefox release/edge && run-s release:chrome release:firefox release:edge", - "release:chrome": "zip -r release/chrome/extension.zip ./dist", - "release:edge": "zip -r release/edge/extension.zip ./dist", - "release:firefox": "run-s release:firefox:extension release:firefox:source", + "release": "run-s clean release:chrome release:firefox release:edge", + "release:chrome": "npm run build:chrome && mkdirp release/chrome && zip -r release/chrome/extension.zip ./dist", + "release:edge": "npm run build:edge && mkdirp release/edge && zip -r release/edge/extension.zip ./dist", + "release:firefox": "npm run build:firefox && mkdirp release/firefox && run-s release:firefox:extension release:firefox:source", "release:firefox:extension": "cd dist && web-ext build --overwrite-dest && cd .. && mv ./dist/web-ext-artifacts/*.zip ./release/firefox/", "release:firefox:source": "zip -r release/firefox/source.zip . --exclude=/.git* --exclude=/node_modules* --exclude=/.history* --exclude=/dist* --exclude=/release* --exclude=*.DS_Store*", "set-version": "node scripts/version.js", diff --git a/webpack.config.js b/webpack.config.js index 94a517dc..90f8db94 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -15,6 +15,7 @@ import manifestV3 from "./resources/manifest.v3.json" assert { type: "json" }; const { BannerPlugin } = webpack; const { BROWSER } = process.env; +const V3_BROWSERS = ["chrome", "edge"]; const require = createRequire(import.meta.url); const __dirname = fileURLToPath(new URL(".", import.meta.url)); const DIST = path.resolve(__dirname, "dist"); @@ -157,7 +158,7 @@ export default [ compiler.hooks.afterEmit.tap("AfterEmitPlugin", (compilation) => { buildManifest( Object.keys(compilation.getStats().compilation.assets), - BROWSER === "chrome" ? manifestV3 : manifestV2 + V3_BROWSERS.includes(BROWSER) ? manifestV3 : manifestV2 ); }); }