|
1 | | -# Deploy the extension to Chrome and firefox web stores |
2 | | -# when creating a new release |
3 | | - |
4 | | -name: Deploy to web stores |
| 1 | +name: Publish extension to Chrome and Firefox |
5 | 2 |
|
6 | 3 | on: |
7 | | - release: |
8 | | - types: |
9 | | - - created |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + targetStore: |
| 7 | + description: 'Store target' |
| 8 | + required: true |
| 9 | + default: 'all' |
| 10 | + type: choice |
| 11 | + options: |
| 12 | + - chrome |
| 13 | + - firefox |
| 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' |
| 22 | + required: true |
| 23 | + default: false |
| 24 | + type: boolean |
10 | 25 | env: |
11 | | - REACT_APP_BUILD_TARGET: "extension" |
| 26 | + REACT_APP_BUILD_TARGET: 'extension' |
| 27 | + |
12 | 28 | jobs: |
13 | | - |
14 | | - bump-manifest-version: |
| 29 | + install-dependencies: |
| 30 | + needs: tag_version |
15 | 31 | runs-on: ubuntu-latest |
16 | | - |
17 | 32 | steps: |
18 | 33 | - uses: actions/checkout@v2 |
19 | 34 | with: |
20 | 35 | ref: master |
21 | | - |
22 | 36 | - uses: actions/cache@v2 |
23 | 37 | with: |
24 | 38 | path: '**/node_modules' |
25 | | - key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }} |
26 | | - |
27 | | - - name: Install json globaly |
28 | | - run: yarn global add json |
29 | | - |
30 | | - # clean release name (as used as version) |
31 | | - - name: Clean release name |
32 | | - id: clean |
33 | | - run: echo ::set-output name=version::$(echo ${{github.event.release.tag_name }} | sed 's/[^0-9.]//g') |
34 | | - |
35 | | - # Update manifest version |
36 | | - - name: Update manifest version |
37 | | - run: json -I -f public/manifest.json -e 'this.version="${{ steps.clean.outputs.version }}"' |
| 39 | + key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }} |
| 40 | + - name: Install yarn dependencies |
| 41 | + run: yarn |
| 42 | + - name: Build and zip the extension |
| 43 | + run: | |
| 44 | + echo version=${{ steps.tag_version.outputs.new_version }} |
| 45 | + if [ ${{github.event.inputs.targetStore}} == 'chrome' ] || [ ${{github.event.inputs.targetStore}} == 'all' ]; then |
| 46 | + yarn build-chrome |
| 47 | + fi |
| 48 | + if [ ${{github.event.inputs.targetStore}} == 'firefox' ] || [ ${{github.event.inputs.targetStore}} == 'all' ]; then |
| 49 | + yarn build-firefox |
| 50 | + fi |
38 | 51 | |
39 | | - # Commit changes |
| 52 | + tag_version: |
| 53 | + runs-on: ubuntu-latest |
| 54 | + steps: |
| 55 | + - uses: actions/checkout@v2 |
| 56 | + - name: Bump version and push tag |
| 57 | + id: tag_version |
| 58 | + uses: mathieudutour/github-tag-action@v6.1 |
| 59 | + with: |
| 60 | + github_token: ${{ secrets.GITHUB_TOKEN }} |
| 61 | + dry_run: ${{ github.event.inputs.testMode == 'true' }} |
| 62 | + |
| 63 | + - name: Update manifest.json |
| 64 | + if: github.event.inputs.autoTag == 'true' |
| 65 | + 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 |
| 66 | + |
40 | 67 | - name: Commit changes |
| 68 | + if: github.event.inputs.autoTag == 'true' |
41 | 69 | uses: EndBug/add-and-commit@v5 |
42 | 70 | with: |
43 | 71 | branch: master |
44 | | - author_name: Bot Driyaf |
| 72 | + author_name: Github bot |
45 | 73 | author_email: elmehdi.sakout@gmail.com |
46 | 74 | message: "Bump manifest version" |
47 | | - |
48 | | - build-extension: |
49 | | - needs: bump-manifest-version |
| 75 | + |
| 76 | + chrome-deploy: |
| 77 | + if: ${{ (github.event.inputs.targetStore == 'chrome') || (github.event.inputs.targetStore == 'all') }} |
| 78 | + needs: install-dependencies |
50 | 79 | runs-on: ubuntu-latest |
51 | | - steps: |
52 | | - - uses: actions/checkout@v2 |
53 | | - with: |
54 | | - ref: master |
55 | | - |
56 | | - - uses: actions/cache@v2 |
57 | | - with: |
58 | | - path: '**/node_modules' |
59 | | - key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }} |
60 | | - |
61 | | - - name: Install yarn dependencies |
62 | | - run: yarn |
63 | | - |
64 | | - - name: Build and zip the extension |
65 | | - run: yarn stores-build |
66 | | - |
67 | | - - name: Install chrome & FF web stores dependencies |
68 | | - run: yarn global add chrome-webstore-upload-cli web-ext web-ext-submit@6 |
| 80 | + steps: |
| 81 | + - name: Install chrome dependencies |
| 82 | + run: yarn global add chrome-webstore-upload-cli |
69 | 83 |
|
70 | 84 | - name: Upload the package to Chrome web store |
| 85 | + if: ${{ github.event.inputs.testMode == 'false' }} |
71 | 86 | env: |
72 | 87 | EXTENSION_ID: ${{ secrets.CHROME_EXTENSION_ID }} |
73 | 88 | CLIENT_ID: ${{secrets.CHROME_EXTENSION_CLIENT_ID}} |
74 | 89 | REFRESH_TOKEN: ${{secrets.CHROME_EXTENSION_REFRESH_TOKEN}} |
75 | 90 | run: chrome-webstore-upload upload --source dist/chrome_extension.zip --extension-id $EXTENSION_ID --auto-publish |
| 91 | + |
| 92 | + firefox-deploy: |
| 93 | + if: ${{ (github.event.inputs.targetStore == 'firefox') || (github.event.inputs.targetStore == 'all') }} |
| 94 | + needs: install-dependencies |
| 95 | + runs-on: ubuntu-latest |
| 96 | + steps: |
| 97 | + - name: Install Firefox dependencies |
| 98 | + run: yarn global add web-ext web-ext-submit@6 |
76 | 99 |
|
77 | 100 | - name: Upload the package to Firefox web store |
| 101 | + if: ${{ github.event.inputs.testMode == 'false' }} |
78 | 102 | env: |
79 | 103 | WEB_EXT_API_KEY: ${{ secrets.WEB_EXT_API_KEY }} |
80 | 104 | WEB_EXT_API_SECRET: ${{ secrets.WEB_EXT_API_SECRET }} |
|
0 commit comments