Release 2.24.0.1 #24
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: Publish extension | ||
| on: | ||
| workflow_dispatch: | ||
| inputs: | ||
| environment: | ||
| description: 'Environment' | ||
| type: choice | ||
| options: | ||
| - development | ||
| - production | ||
| default: production | ||
| permissions: | ||
| # for updating tag/release | ||
| contents: write | ||
| jobs: | ||
| main: | ||
| name: Build and create tag | ||
| runs-on: ubuntu-latest | ||
| environment: ${{ github.event.inputs.environment }} | ||
| outputs: | ||
| version: ${{ steps.config.outputs.version }} | ||
| tag_name: ${{ steps.config.outputs.tag_name }} | ||
| ext_path_zip: ${{ steps.config.outputs.ext_path_zip }} | ||
| ext_path_xpi: ${{ steps.config.outputs.ext_path_xpi }} | ||
| artifact_dir: ${{ steps.config.outputs.artifact_dir }} | ||
| artifact_zip: ${{ steps.config.outputs.artifact_zip }} | ||
| artifact_xpi: ${{ steps.config.outputs.artifact_xpi }} | ||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v4 | ||
| - name: Configure and verify | ||
| id: config | ||
| env: | ||
| TIMEZONE: ${{ vars.TIMEZONE || 'UTC' }} | ||
| run: | | ||
| VERSION=$(jq -r '.version' './src/manifest.chromium.json') | ||
| VERSION_FX=$(jq -r '.version' './src/manifest.firefox.json') | ||
| if [ "$VERSION" != "$VERSION_FX" ]; then | ||
| echo "❌ Mismatching manifest versions" | ||
| exit 1 | ||
| fi | ||
| if [ '${{ github.event.inputs.environment }}' = 'production' ]; then | ||
| EXPECTED_LINE="## [$VERSION] - $(TZ="$TIMEZONE" date +%Y-%m-%d)" | ||
| if ! grep -Fxq "$EXPECTED_LINE" CHANGELOG.md; then | ||
| echo "❌ Missing expected changelog line: $EXPECTED_LINE" | ||
| exit 1 | ||
| fi | ||
| fi | ||
| echo "version=$VERSION" >> $GITHUB_OUTPUT | ||
| echo "tag_name=$VERSION" >> $GITHUB_OUTPUT | ||
| echo "ext_path_zip=dist/webscrapbook.zip" >> $GITHUB_OUTPUT | ||
| echo "ext_path_xpi=dist/webscrapbook.xpi" >> $GITHUB_OUTPUT | ||
| echo "artifact_dir=dist" >> $GITHUB_OUTPUT | ||
| echo "artifact_zip=webscrapbook-zip" >> $GITHUB_OUTPUT | ||
| echo "artifact_xpi=webscrapbook-xpi" >> $GITHUB_OUTPUT | ||
| - name: Set Firefox extension ID | ||
| if: vars.FIREFOX_EXTENSION_ID | ||
| run: | | ||
| for file in src/manifest.firefox*.json; do | ||
| echo "Updating '$file'..." | ||
| jq '.browser_specific_settings.gecko.id = "${{ vars.FIREFOX_EXTENSION_ID }}"' "$file" > manifest.tmp.json | ||
| mv manifest.tmp.json "$file" | ||
| done | ||
| - 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: Create Git tag | ||
| if: github.event.inputs.environment == 'production' | ||
| run: | | ||
| git tag --force ${{ steps.config.outputs.tag_name }} | ||
| git push origin ${{ steps.config.outputs.tag_name }} | ||
| - name: Upload artifact (ZIP) | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: ${{ steps.config.outputs.artifact_zip }} | ||
| path: ${{ steps.config.outputs.ext_path_zip }} | ||
| - name: Upload artifact (XPI) | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: ${{ steps.config.outputs.artifact_xpi }} | ||
| path: ${{ steps.config.outputs.ext_path_xpi }} | ||
| 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 }} | ||
| # 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 }} | ||
| upload_edge: | ||
| name: Upload to Microsoft Edge Add-ons | ||
| 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 Microsoft Edge Add-ons | ||
| uses: wdzeng/edge-addon@v2 | ||
| with: | ||
| zip-path: ${{ needs.main.outputs.ext_path_zip }} | ||
| product-id: ${{ vars.EDGE_PRODUCT_ID }} | ||
| client-id: ${{ secrets.EDGE_CLIENT_ID }} | ||
| api-key: ${{ secrets.EDGE_API_KEY }} | ||
| upload_firefox: | ||
| name: Upload to Firefox Add-ons | ||
| 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_xpi }} | ||
| path: ${{ needs.main.outputs.artifact_dir }} | ||
| - name: Upload to Firefox Add-ons | ||
| uses: kewisch/action-web-ext@v1 | ||
| with: | ||
| cmd: sign | ||
| channel: listed | ||
| source: ${{ needs.main.outputs.ext_path_xpi }} | ||
| artifacts: dist | ||
| apiKey: ${{ secrets.FIREFOX_API_KEY }} | ||
| apiSecret: ${{ secrets.FIREFOX_API_SECRET }} | ||
| channel: ${{ github.event.inputs.environment == 'production' && 'listed' || 'unlisted' }} | ||