Publish extension to Chrome and Firefox #59
This file contains 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: Publish extension to Chrome and 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: | |
REACT_APP_BUILD_TARGET: 'extension' | |
REACT_APP_AMPLITUDE_KEY: ${{ secrets.REACT_APP_AMPLITUDE_KEY }} | |
REACT_APP_AMPLITUDE_URL: ${{ secrets.REACT_APP_AMPLITUDE_URL }} | |
jobs: | |
tag_version: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Bump version and push tag | |
id: tag_version | |
uses: mathieudutour/[email protected] | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
dry_run: ${{ github.event.inputs.autoTag == 'false' }} | |
custom_release_rules: | | |
"fix:patch:Bug Fixes,hotfix:patch:Bug Fixes,minor:minor:Fixes,patch:patch:Quick fixes,refactor:minor:Refactoring,implement:minor:Features,change:minor:Changes,breaking:major:Changes,major:major:Changes" | |
- name: Update manifest.json | |
if: github.event.inputs.autoTag == 'true' | |
run: jq --arg version "${{ steps.tag_version.outputs.new_version }}" '.version=$version' public/base.manifest.json > tmp.json && mv tmp.json public/base.manifest.json | |
- name: Commit changes | |
if: github.event.inputs.autoTag == 'true' | |
uses: EndBug/add-and-commit@v5 | |
with: | |
branch: master | |
author_name: Github bot | |
author_email: [email protected] | |
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@v2 | |
with: | |
ref: master | |
- uses: actions/cache@v2 | |
with: | |
path: '**/node_modules' | |
key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }} | |
- name: Install yarn dependencies | |
run: yarn | |
- name: Build and zip the extension | |
env: | |
NODE_OPTIONS: --openssl-legacy-provider | |
run: yarn build-chrome | |
- name: Install chrome dependencies | |
run: yarn global add chrome-webstore-upload-cli | |
- name: Upload the package to Chrome web store | |
if: ${{ github.event.inputs.testMode == 'false' }} | |
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}} | |
run: chrome-webstore-upload upload --source chrome_extension.zip --extension-id $EXTENSION_ID --auto-publish | |
firefox-deploy: | |
if: ${{ (github.event.inputs.targetStore == 'firefox') || (github.event.inputs.targetStore == 'all') }} | |
needs: tag_version | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
with: | |
ref: master | |
- uses: actions/cache@v2 | |
with: | |
path: '**/node_modules' | |
key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }} | |
- name: Install yarn dependencies | |
run: yarn | |
- name: Build and zip the extension | |
env: | |
NODE_OPTIONS: --openssl-legacy-provider | |
run: yarn build-firefox | |
- name: Install Firefox dependencies | |
run: yarn global add web-ext web-ext-submit@6 | |
- name: Upload the package to Firefox web store | |
if: ${{ github.event.inputs.testMode == 'false' }} | |
env: | |
WEB_EXT_API_KEY: ${{ secrets.WEB_EXT_API_KEY }} | |
WEB_EXT_API_SECRET: ${{ secrets.WEB_EXT_API_SECRET }} | |
run: cd dist && web-ext-submit #--channel=unlisted |