Skip to content

Publish extension MV3 #12

Publish extension MV3

Publish extension MV3 #12

Workflow file for this run

name: Publish extension MV3
on:
workflow_dispatch:
inputs:
environment:
description: 'Environment'
type: choice
options:
- development
- production
default: production
jobs:
main:
name: Build
runs-on: ubuntu-latest
environment: ${{ github.event.inputs.environment }}
outputs:
ext_path_zip: ${{ steps.config.outputs.ext_path_zip }}
artifact_dir: ${{ steps.config.outputs.artifact_dir }}
artifact_zip: ${{ steps.config.outputs.artifact_zip }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Configure and verify
id: config
run: |
MANIFEST_VERSION=$(jq -r '.manifest_version' './src/manifest.chromium.json')
if [ "$MANIFEST_VERSION" != 3 ]; then
echo "❌ Unexpected \`manifest_version\`: $MANIFEST_VERSION"
exit 1
fi
echo "ext_path_zip=dist/webscrapbook.zip" >> $GITHUB_OUTPUT
echo "artifact_dir=dist" >> $GITHUB_OUTPUT
echo "artifact_zip=webscrapbook-zip" >> $GITHUB_OUTPUT
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '22'
- name: Install dependencies
run: npm install
- name: Verify no code issue
run: npm run lint
- name: Build extension
run: npm run pack
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ steps.config.outputs.artifact_zip }}
path: ${{ steps.config.outputs.ext_path_zip }}
upload_cws:
name: Upload to Chrome Web Store
runs-on: ubuntu-latest
needs: main
environment: ${{ github.event.inputs.environment }}
steps:
- name: Download artifact
uses: actions/download-artifact@v4
with:
name: ${{ needs.main.outputs.artifact_zip }}
path: ${{ needs.main.outputs.artifact_dir }}
- name: Upload to Chrome Web Store
uses: mnao305/[email protected]
with:
file-path: ${{ needs.main.outputs.ext_path_zip }}
extension-id: ${{ vars.CHROME_EXTENSION_ID_MV3 }}
# https://github.com/fregante/chrome-webstore-upload-keys
client-id: ${{ secrets.CHROME_CLIENT_ID }}
client-secret: ${{ secrets.CHROME_CLIENT_SECRET }}
refresh-token: ${{ secrets.CHROME_REFRESH_TOKEN }}