diff --git a/.github/workflows/release-action.yml b/.github/workflows/release-action.yml
new file mode 100644
index 0000000..e98391b
--- /dev/null
+++ b/.github/workflows/release-action.yml
@@ -0,0 +1,15 @@
+name: Build release
+on:
+ push:
+ tags:
+ - 'v*'
+jobs:
+ call-test-workflow:
+ uses: ./.github/workflows/test-workflow.yml
+ with:
+ node-version: ${{ vars.NODE_VERSION }}
+ call-release-workflow:
+ uses: ./.github/workflows/release-workflow.yml
+ needs: call-test-workflow
+ with:
+ node-version: ${{ vars.NODE_VERSION }}
diff --git a/.github/workflows/release-workflow.yml b/.github/workflows/release-workflow.yml
new file mode 100644
index 0000000..7c651c4
--- /dev/null
+++ b/.github/workflows/release-workflow.yml
@@ -0,0 +1,60 @@
+name: Build release
+on:
+ workflow_call:
+ inputs:
+ node-version:
+ required: true
+ type: string
+jobs:
+ release:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v2
+ - name: Setup Node.js
+ uses: actions/setup-node@v2
+ with:
+ node-version: ${{ inputs.node-version }}
+ - name: Cache dependencies
+ id: cache
+ uses: actions/cache@v2
+ with:
+ path: ./node_modules
+ key: modules-${{ hashFiles('package-lock.json') }}
+ - name: Install dependencies
+ if: steps.cache.outputs.cache-hit != 'true'
+ run: npm ci --ignore-scripts
+ - name: Build
+ run: npm run build:all
+ - name: Package
+ run: npm run package:all
+ - name: Create Release
+ id: create_release
+ uses: actions/create-release@v1
+ env:
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ with:
+ tag_name: ${{ github.ref }}
+ release_name: Release ${{ github.ref }}
+ draft: false
+ prerelease: false
+ - name: Get package version
+ id: package_version
+ run: echo "::set-output name=version::$(node -p "require('./package.json').version")"
+ - name: Upload Firefox release assets
+ uses: actions/upload-release-asset@v1
+ env:
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ with:
+ upload_url: ${{ steps.create_release.outputs.upload_url }}
+ asset_path: ./dist-package/open-multiple-urls-${{ steps.package_version.outputs.version }}-firefox.zip
+ asset_name: open-multiple-urls-${{ steps.package_version.outputs.version }}-firefox.zip
+ asset_content_type: application/zip
+ - name: Upload Chrome release assets
+ uses: actions/upload-release-asset@v1
+ env:
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ with:
+ upload_url: ${{ steps.create_release.outputs.upload_url }}
+ asset_path: ./dist-package/open-multiple-urls-${{ steps.package_version.outputs.version }}-chrome.zip
+ asset_name: open-multiple-urls-${{ steps.package_version.outputs.version }}-chrome.zip
+ asset_content_type: application/zip
\ No newline at end of file
diff --git a/.github/workflows/test-action.yml b/.github/workflows/test-action.yml
new file mode 100644
index 0000000..22d8764
--- /dev/null
+++ b/.github/workflows/test-action.yml
@@ -0,0 +1,7 @@
+name: Run tests
+on: [push, pull_request]
+jobs:
+ call-test-workflow:
+ uses: ./.github/workflows/test-workflow.yml
+ with:
+ node-version: ${{ vars.NODE_VERSION }}
diff --git a/.github/workflows/github-actions-test.yml b/.github/workflows/test-workflow.yml
similarity index 77%
rename from .github/workflows/github-actions-test.yml
rename to .github/workflows/test-workflow.yml
index 749f7b0..06fc319 100644
--- a/.github/workflows/github-actions-test.yml
+++ b/.github/workflows/test-workflow.yml
@@ -1,5 +1,10 @@
-name: Run tests
-on: [push, pull_request]
+name: Test Workflow
+on:
+ workflow_call:
+ inputs:
+ node-version:
+ required: true
+ type: string
jobs:
test:
runs-on: ubuntu-latest
@@ -8,7 +13,7 @@ jobs:
- name: Setup Node.js
uses: actions/setup-node@v2
with:
- node-version: '18'
+ node-version: ${{ inputs.node-version }}
- name: Cache dependencies
id: cache
uses: actions/cache@v2
@@ -25,4 +30,4 @@ jobs:
- name: Format-check
run: npm run format:check
- name: Run tests
- run: npm run test:unit
+ run: npm run test:unit
\ No newline at end of file
diff --git a/.gitignore b/.gitignore
index e57efb7..291e747 100644
--- a/.gitignore
+++ b/.gitignore
@@ -14,6 +14,7 @@ dist-ssr
dist-chrome
dist-firefox
dist-zip
+dist-package
coverage
*.local
diff --git a/README.md b/README.md
index 9b40830..a2f78f9 100644
--- a/README.md
+++ b/README.md
@@ -19,16 +19,16 @@ Due to incompatible manifest.json definitions, there are separate builds for Fir
First: Install packages via `npm install`.
Then use one of the following build commands:
-| Command | Description | Output dir |
-|:------------------------|:------------------------------------|:--------------------------------|
-| `npm run dev:firefox` | live build (watch-mode) for Firefox | `dist-firefox` |
-| `npm run dev:chrome` | live build (watch-mode) for Chrome | `dist-chrome` |
-| `npm run build:firefox` | production build for Firefox | `dist-firefox` |
-| `npm run build:chrome` | production build for Chrome | `dist-chrome` |
-| `npm run build:all` | production build for all browsers | `dist-firefox`
`dist-chrome` |
-| `npm run zip:firefox` | build and package for Firefox | `dist-zip` |
-| `npm run zip:chrome` | build and package for Chrome | `dist-zip` |
-| `npm run zip:all` | build and package for all browsers | `dist-zip` |
+| Command | Description | Output dir |
+|:--------------------------|:------------------------------------|:--------------------------------|
+| `npm run dev:firefox` | live build (watch-mode) for Firefox | `dist-firefox` |
+| `npm run dev:chrome` | live build (watch-mode) for Chrome | `dist-chrome` |
+| `npm run build:firefox` | production build for Firefox | `dist-firefox` |
+| `npm run build:chrome` | production build for Chrome | `dist-chrome` |
+| `npm run build:all` | production build for all browsers | `dist-firefox`
`dist-chrome` |
+| `npm run package:firefox` | package for Firefox | `dist-package` |
+| `npm run package:chrome` | package for Chrome | `dist-package` |
+| `npm run package:all` | package for all browsers | `dist-package` |
See [instructions for Chrome](https://developer.chrome.com/docs/extensions/mv3/getstarted/development-basics/#load-unpacked) and [instructions for Firefox](https://extensionworkshop.com/documentation/develop/temporary-installation-in-firefox/) on how to load an unpacked extension.
diff --git a/package.json b/package.json
index 187727c..47cd747 100644
--- a/package.json
+++ b/package.json
@@ -6,9 +6,9 @@
"build:chrome": "export TARGET=chrome && run-p type-check \"build {@}\" --",
"build:firefox": "export TARGET=firefox && run-p type-check \"build {@}\" --",
"build:all": "npm run build:chrome && npm run build:firefox",
- "zip:chrome": "npm run build:chrome && mkdir -p dist-zip && zip -FSrj dist-zip/open-multiple-urls-$npm_package_version-chrome.zip dist-chrome",
- "zip:firefox": "npm run build:firefox && mkdir -p dist-zip && zip -FSrj dist-zip/open-multiple-urls-$npm_package_version-firefox.zip dist-firefox",
- "zip:all": "npm run zip:chrome && npm run zip:firefox",
+ "package:chrome": "mkdir -p dist-package && zip -FSrj dist-package/open-multiple-urls-$npm_package_version-chrome.zip dist-chrome",
+ "package:firefox": "mkdir -p dist-package && zip -FSrj dist-package/open-multiple-urls-$npm_package_version-firefox.zip dist-firefox",
+ "package:all": "npm run package:chrome && npm run package:firefox",
"dev:chrome": "export TARGET=chrome && run-p type-check \"watch {@}\" --",
"dev:firefox": "export TARGET=firefox && run-p type-check \"watch {@}\" --",
"test:unit": "export TARGET=firefox && vitest --coverage",