Skip to content

Commit 29cd0e4

Browse files
committed
refactor: update workflow for browser extension deployment and simplify input parameters
1 parent cd88499 commit 29cd0e4

1 file changed

Lines changed: 29 additions & 81 deletions

File tree

.github/workflows/distribute.yml

Lines changed: 29 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,19 @@
1-
name: '🚀 Deploy to Chrome 🌐 & Firefox 🦊'
1+
name: '🚀 Deploy browser extension'
22

33
on:
44
workflow_dispatch:
55
inputs:
6-
targetStore:
7-
description: 'Store target'
6+
target:
7+
description: 'Which store to deploy to?'
88
required: true
99
default: 'all'
1010
type: choice
1111
options:
1212
- chrome
1313
- firefox
1414
- all
15-
autoTag:
16-
description: 'Auto Create a new tag'
17-
required: true
18-
default: true
19-
type: boolean
2015
testMode:
21-
description: 'Test Mode'
16+
description: 'Run in test mode without publishing?'
2217
required: true
2318
default: false
2419
type: boolean
@@ -32,90 +27,43 @@ env:
3227
VITE_SENTRY_TOKEN: ${{ secrets.VITE_SENTRY_TOKEN }}
3328

3429
jobs:
35-
tag_version:
30+
build-and-deploy:
3631
runs-on: ubuntu-latest
37-
steps:
38-
- uses: actions/checkout@v4
39-
with:
40-
fetch-depth: 0
4132

42-
- name: Bump version and push tag
43-
id: tag_version
44-
uses: anothrNick/github-tag-action@1.67.0
45-
env:
46-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
47-
WITH_V: true
48-
DRY_RUN: ${{ github.event.inputs.autoTag == 'false' }}
33+
strategy:
34+
fail-fast: false
35+
matrix:
36+
browser: [chrome, firefox]
4937

50-
- name: Update manifest.json
51-
if: github.event.inputs.autoTag == 'true'
52-
run: |
53-
new_version=$(echo "${{ steps.tag_version.outputs.new_tag }}" | sed 's/^v//')
54-
jq --arg version "$new_version" '.version = $version' public/base.manifest.json > public/base.manifest.json.tmp && mv public/base.manifest.json.tmp public/base.manifest.json
55-
56-
- name: Commit changes
57-
if: github.event.inputs.autoTag == 'true'
58-
uses: EndBug/add-and-commit@v5
59-
with:
60-
branch: ${{ github.ref_name }}
61-
author_name: Github bot
62-
author_email: elmehdi.sakout@gmail.com
63-
message: 'Bump manifest version'
64-
65-
chrome-deploy:
66-
if: ${{ (github.event.inputs.targetStore == 'chrome') || (github.event.inputs.targetStore == 'all') }}
67-
needs: tag_version
68-
runs-on: ubuntu-latest
6938
steps:
7039
- uses: actions/checkout@v4
71-
with:
72-
ref: ${{ github.ref_name }}
73-
- uses: actions/cache@v4
74-
with:
75-
path: '**/node_modules'
76-
key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }}
77-
- name: Set up Node.js
78-
uses: actions/setup-node@v4
40+
41+
- uses: actions/setup-node@v4
7942
with:
8043
node-version: 18
81-
- name: Install yarn dependencies
82-
run: yarn
44+
cache: 'yarn'
45+
46+
- run: yarn install --frozen-lockfile
8347

84-
- name: Build and zip the extension
85-
run: yarn build:chrome
48+
- name: 'Build Extension'
49+
if: ${{ github.event.inputs.target == 'all' || github.event.inputs.target == matrix.browser }}
50+
run: yarn build:${{ matrix.browser }}
8651

87-
- name: Upload the package to Chrome web store
88-
if: ${{ github.event.inputs.testMode == 'false' }}
89-
run: npx chrome-webstore-upload-cli@3 upload --source chrome_extension.zip --extension-id $EXTENSION_ID --auto-publish
52+
- name: '⬆️ Upload to Chrome Web Store'
53+
if: ${{ (github.event.inputs.target == 'all' || github.event.inputs.target == 'chrome') && matrix.browser == 'chrome' && github.event.inputs.testMode == 'false' }}
54+
run: >
55+
npx chrome-webstore-upload-cli@3 upload
56+
--source chrome_extension.zip
57+
--extension-id ${{ secrets.CHROME_EXTENSION_ID }}
58+
--auto-publish
9059
env:
9160
EXTENSION_ID: ${{ secrets.CHROME_EXTENSION_ID }}
92-
CLIENT_ID: ${{secrets.CHROME_EXTENSION_CLIENT_ID}}
93-
REFRESH_TOKEN: ${{secrets.CHROME_EXTENSION_REFRESH_TOKEN}}
94-
CLIENT_SECRET: ${{secrets.CHROME_EXTENSION_CLIENT_SECRET}}
95-
96-
firefox-deploy:
97-
if: ${{ (github.event.inputs.targetStore == 'firefox') || (github.event.inputs.targetStore == 'all') }}
98-
needs: tag_version
99-
runs-on: ubuntu-latest
100-
steps:
101-
- uses: actions/checkout@v4
102-
with:
103-
ref: ${{ github.ref_name }}
104-
- uses: actions/cache@v4
105-
with:
106-
path: '**/node_modules'
107-
key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }}
108-
- name: Set up Node.js
109-
uses: actions/setup-node@v4
110-
with:
111-
node-version: 18
112-
- name: Install yarn dependencies
113-
run: yarn
61+
CLIENT_ID: ${{ secrets.CHROME_EXTENSION_CLIENT_ID }}
62+
CLIENT_SECRET: ${{ secrets.CHROME_EXTENSION_CLIENT_SECRET }}
63+
REFRESH_TOKEN: ${{ secrets.CHROME_EXTENSION_REFRESH_TOKEN }}
11464

115-
- name: Build and zip the extension
116-
run: yarn build:firefox
117-
- name: Upload the package to Firefox web store
118-
if: ${{ github.event.inputs.testMode == 'false' }}
65+
- name: '⬆️ Upload to Firefox Add-on Store'
66+
if: ${{ (github.event.inputs.target == 'all' || github.event.inputs.target == 'firefox') && matrix.browser == 'firefox' && github.event.inputs.testMode == 'false' }}
11967
uses: wdzeng/firefox-addon@v1
12068
with:
12169
jwt-issuer: ${{ secrets.WEB_EXT_API_KEY }}

0 commit comments

Comments
 (0)