|
1 | | -name: '🚀 Deploy to Chrome 🌐 & Firefox 🦊' |
2 | | - |
| 1 | +name: '🚀 Distribute browser extension' |
| 2 | +run-name: Distribute Browser extension ${{ github.ref_name }} |
3 | 3 | on: |
4 | 4 | workflow_dispatch: |
5 | 5 | inputs: |
6 | | - targetStore: |
7 | | - description: 'Store target' |
| 6 | + target: |
| 7 | + description: 'Select the store to deploy to' |
8 | 8 | required: true |
9 | 9 | default: 'all' |
10 | 10 | type: choice |
11 | 11 | options: |
12 | 12 | - chrome |
13 | 13 | - firefox |
14 | 14 | - all |
15 | | - autoTag: |
16 | | - description: 'Auto Create a new tag' |
17 | | - required: true |
18 | | - default: true |
19 | | - type: boolean |
20 | | - testMode: |
21 | | - description: 'Test Mode' |
| 15 | + dryrun: |
| 16 | + description: 'Run in dry mode without publishing' |
22 | 17 | required: true |
23 | 18 | default: false |
24 | 19 | type: boolean |
|
32 | 27 | VITE_SENTRY_TOKEN: ${{ secrets.VITE_SENTRY_TOKEN }} |
33 | 28 |
|
34 | 29 | jobs: |
35 | | - tag_version: |
| 30 | + build-and-deploy: |
36 | 31 | runs-on: ubuntu-latest |
37 | | - steps: |
38 | | - - uses: actions/checkout@v4 |
39 | | - with: |
40 | | - fetch-depth: 0 |
| 32 | + if: ${{github.ref_type == 'tag' }} |
| 33 | + strategy: |
| 34 | + fail-fast: false |
| 35 | + matrix: |
| 36 | + browser: [chrome, firefox] |
41 | 37 |
|
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' }} |
49 | | - |
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 |
69 | 38 | steps: |
70 | | - - uses: actions/checkout@v4 |
| 39 | + - uses: actions/checkout@v6 |
71 | 40 | with: |
| 41 | + fetch-depth: 0 |
72 | 42 | 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 |
| 43 | + |
| 44 | + - uses: actions/setup-node@v4 |
79 | 45 | with: |
80 | 46 | node-version: 18 |
81 | | - - name: Install yarn dependencies |
82 | | - run: yarn |
| 47 | + cache: 'yarn' |
83 | 48 |
|
84 | | - - name: Build and zip the extension |
85 | | - run: yarn build:chrome |
| 49 | + - run: yarn install --frozen-lockfile |
86 | 50 |
|
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 |
| 51 | + - name: 'Build Extension' |
| 52 | + if: ${{ github.event.inputs.target == 'all' || github.event.inputs.target == matrix.browser }} |
| 53 | + run: yarn build:${{ matrix.browser }} |
| 54 | + |
| 55 | + - name: '⬆️ Upload to Chrome Web Store' |
| 56 | + if: ${{ (github.event.inputs.target == 'all' || github.event.inputs.target == 'chrome') && matrix.browser == 'chrome' && github.event.inputs.dryrun == 'false' }} |
| 57 | + run: > |
| 58 | + npx chrome-webstore-upload-cli@3 upload |
| 59 | + --source chrome_extension.zip |
| 60 | + --extension-id ${{ secrets.CHROME_EXTENSION_ID }} |
| 61 | + --auto-publish |
90 | 62 | env: |
91 | 63 | 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 |
| 64 | + CLIENT_ID: ${{ secrets.CHROME_EXTENSION_CLIENT_ID }} |
| 65 | + CLIENT_SECRET: ${{ secrets.CHROME_EXTENSION_CLIENT_SECRET }} |
| 66 | + REFRESH_TOKEN: ${{ secrets.CHROME_EXTENSION_REFRESH_TOKEN }} |
114 | 67 |
|
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' }} |
| 68 | + - name: '⬆️ Upload to Firefox Add-on Store' |
| 69 | + if: ${{ (github.event.inputs.target == 'all' || github.event.inputs.target == 'firefox') && matrix.browser == 'firefox' && github.event.inputs.dryrun == 'false' }} |
119 | 70 | uses: wdzeng/firefox-addon@v1 |
120 | 71 | with: |
121 | 72 | jwt-issuer: ${{ secrets.WEB_EXT_API_KEY }} |
|
0 commit comments