Skip to content

Commit

Permalink
add release workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
htrinter authored Nov 26, 2023
1 parent 6568e92 commit 0313e22
Show file tree
Hide file tree
Showing 7 changed files with 105 additions and 17 deletions.
15 changes: 15 additions & 0 deletions .github/workflows/release-action.yml
Original file line number Diff line number Diff line change
@@ -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 }}
60 changes: 60 additions & 0 deletions .github/workflows/release-workflow.yml
Original file line number Diff line number Diff line change
@@ -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
7 changes: 7 additions & 0 deletions .github/workflows/test-action.yml
Original file line number Diff line number Diff line change
@@ -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 }}
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand All @@ -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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ dist-ssr
dist-chrome
dist-firefox
dist-zip
dist-package
coverage
*.local

Expand Down
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,16 @@ Due to incompatible manifest.json definitions, there are separate builds for Fir
First: Install packages via `npm install`.<br>
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`<br>`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`<br>`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.

Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 0313e22

Please sign in to comment.