🚀 Deploy browser extension #98
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: '🚀 Deploy to Chrome 🌐 & Firefox 🦊' | |
on: | |
workflow_dispatch: | |
inputs: | |
targetStore: | |
description: 'Store target' | |
required: true | |
default: 'all' | |
type: choice | |
options: | |
- chrome | |
- firefox | |
- all | |
autoTag: | |
description: 'Auto Create a new tag' | |
required: true | |
default: true | |
type: boolean | |
testMode: | |
description: 'Test Mode' | |
required: true | |
default: false | |
type: boolean | |
env: | |
VITE_BUILD_TARGET: 'extension' | |
VITE_AMPLITUDE_KEY: ${{ secrets.REACT_APP_AMPLITUDE_KEY }} | |
VITE_AMPLITUDE_URL: ${{ secrets.REACT_APP_AMPLITUDE_URL }} | |
VITE_API_URL: ${{ secrets.API_URL }} | |
VITE_FIREBASE_API_KEY: ${{ secrets.FIREBASE_API_KEY }} | |
VITE_SENTRY_DSN: ${{ secrets.VITE_SENTRY_DSN }} | |
VITE_SENTRY_TOKEN: ${{ secrets.VITE_SENTRY_TOKEN }} | |
jobs: | |
tag_version: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Bump version and push tag | |
id: tag_version | |
uses: anothrNick/github-tag-action@1.67.0 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
WITH_V: true | |
DRY_RUN: ${{ github.event.inputs.autoTag == 'false' }} | |
- name: Update manifest.json | |
if: github.event.inputs.autoTag == 'true' | |
run: | | |
new_version=$(echo "${{ steps.tag_version.outputs.new_tag }}" | sed 's/^v//') | |
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 | |
- name: Commit changes | |
if: github.event.inputs.autoTag == 'true' | |
uses: EndBug/add-and-commit@v5 | |
with: | |
branch: ${{ github.ref_name }} | |
author_name: Github bot | |
author_email: elmehdi.sakout@gmail.com | |
message: 'Bump manifest version' | |
chrome-deploy: | |
if: ${{ (github.event.inputs.targetStore == 'chrome') || (github.event.inputs.targetStore == 'all') }} | |
needs: tag_version | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
ref: ${{ github.ref_name }} | |
- uses: actions/cache@v4 | |
with: | |
path: '**/node_modules' | |
key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }} | |
- name: Set up Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 18 | |
- name: Install yarn dependencies | |
run: yarn | |
- name: Build and zip the extension | |
run: yarn build:chrome | |
- name: Upload the package to Chrome web store | |
if: ${{ github.event.inputs.testMode == 'false' }} | |
run: npx chrome-webstore-upload-cli@3 upload --source chrome_extension.zip --extension-id $EXTENSION_ID --auto-publish | |
env: | |
EXTENSION_ID: ${{ secrets.CHROME_EXTENSION_ID }} | |
CLIENT_ID: ${{secrets.CHROME_EXTENSION_CLIENT_ID}} | |
REFRESH_TOKEN: ${{secrets.CHROME_EXTENSION_REFRESH_TOKEN}} | |
CLIENT_SECRET: ${{secrets.CHROME_EXTENSION_CLIENT_SECRET}} | |
firefox-deploy: | |
if: ${{ (github.event.inputs.targetStore == 'firefox') || (github.event.inputs.targetStore == 'all') }} | |
needs: tag_version | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
ref: ${{ github.ref_name }} | |
- uses: actions/cache@v4 | |
with: | |
path: '**/node_modules' | |
key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }} | |
- name: Set up Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 18 | |
- name: Install yarn dependencies | |
run: yarn | |
- name: Build and zip the extension | |
run: yarn build:firefox | |
- name: Upload the package to Firefox web store | |
if: ${{ github.event.inputs.testMode == 'false' }} | |
uses: wdzeng/firefox-addon@v1 | |
with: | |
jwt-issuer: ${{ secrets.WEB_EXT_API_KEY }} | |
jwt-secret: ${{ secrets.WEB_EXT_API_SECRET }} | |
addon-guid: '{f8793186-e9da-4332-aa1e-dc3d9f7bb04c}' | |
xpi-path: firefox_extension.zip | |
source-file-path: source_code.zip |