Pop-up dictionary browser extension for language learning. Successor to Yomichan. (PERSONAL FORK)
1name: publish-chrome-development
2on:
3 workflow_dispatch:
4 inputs:
5 attemptNumber:
6 description: "Attempt number"
7 required: false
8 default: "1"
9 maxAttempts:
10 description: "Max attempts"
11 required: false
12 default: "10"
13 upload_url:
14 description: "The upload_url from the release created by create-prerelease-on-tag.yml"
15 required: true
16permissions:
17 contents: read
18jobs:
19 upload-on-webstore:
20 runs-on: ubuntu-latest
21 environment: cd
22 outputs:
23 result: ${{ steps.webStorePublish.outcome }}
24 permissions:
25 actions: write
26 contents: write
27 steps:
28 - name: Get the next attempt number
29 id: getNextAttemptNumber
30 uses: cardinalby/js-eval-action@e905fd3681d757e992c976f61c2784dcb4060e13 # pin@v1.0.9
31 env:
32 attemptNumber: ${{ github.event.inputs.attemptNumber }}
33 maxAttempts: ${{ github.event.inputs.maxAttempts }}
34 with:
35 expression: |
36 {
37 const
38 attempt = parseInt(env.attemptNumber),
39 max = parseInt(env.maxAttempts);
40 assert(attempt && max && max >= attempt);
41 return attempt < max ? attempt + 1 : '';
42 }
43
44 - uses: robinraju/release-downloader@daf26c55d821e836577a15f77d86ddc078948b05 # pin@v1.12
45 with:
46 tag: ${{ github.ref_name }}
47 fileName: "*"
48
49 - name: Fetch Google API access token
50 id: fetchAccessToken
51 uses: cardinalby/google-api-fetch-token-action@f455422472a558d48d939e77a65cdcec38e707b5 # pin@v1.0.4
52 with:
53 clientId: ${{ secrets.G_CLIENT_ID }}
54 clientSecret: ${{ secrets.G_CLIENT_SECRET }}
55 refreshToken: ${{ secrets.G_REFRESH_TOKEN }}
56
57 - name: Upload to Google Web Store
58 id: webStoreUpload
59 continue-on-error: true
60 uses: cardinalby/webext-buildtools-chrome-webstore-upload-action@3d829e042b559c35f7fb71676cbaf6031892a313 # v1.0.11
61 with:
62 zipFilePath: yomitan-chrome-dev.zip
63 extensionId: ${{ secrets.G_DEVELOPMENT_EXTENSION_ID }}
64 apiAccessToken: ${{ steps.fetchAccessToken.outputs.accessToken }}
65 waitForUploadCheckCount: 10
66 waitForUploadCheckIntervalMs: 180000 # 3 minutes
67
68 # Schedule a next attempt if store refused to accept new version because it
69 # still has a previous one in review
70 - name: Start the next attempt with the delay
71 uses: aurelien-baudet/workflow-dispatch@3133c5d135c7dbe4be4f9793872b6ef331b53bc7 # pin@v2
72 if: |
73 steps.getNextAttemptNumber.outputs.result &&
74 steps.webStoreUpload.outputs.inReviewError == 'true'
75 with:
76 workflow: delay
77 token: ${{ secrets.GITHUB_TOKEN }}
78 wait-for-completion: false
79 inputs: |
80 {
81 "attemptNumber": "${{ steps.getNextAttemptNumber.outputs.result }}",
82 "maxAttempts": "${{ github.event.inputs.maxAttempts }}",
83 "workflow": "${{ github.workflow }}"
84 }
85
86 - name: Abort on unrecoverable upload error
87 if: |
88 !steps.webStoreUpload.outputs.newVersion &&
89 steps.webStoreUpload.outputs.sameVersionAlreadyUploadedError != 'true'
90 run: exit 1
91
92 - name: Publish on Google Web Store
93 id: webStorePublish
94 if: |
95 steps.webStoreUpload.outputs.newVersion ||
96 steps.webStoreUpload.outputs.sameVersionAlreadyUploadedError == 'true'
97 uses: cardinalby/webext-buildtools-chrome-webstore-publish-action@d39ebd4ab4ea4b44498bf5fc34d4b3db7706f1ed # pin@v1.0.7
98 with:
99 extensionId: ${{ secrets.G_DEVELOPMENT_EXTENSION_ID }}
100 apiAccessToken: ${{ steps.fetchAccessToken.outputs.accessToken }}
101
102 release-crx:
103 runs-on: ubuntu-latest
104 environment: cd
105 permissions:
106 actions: write
107 contents: write
108
109 steps:
110 - uses: robinraju/release-downloader@daf26c55d821e836577a15f77d86ddc078948b05 # pin@v1.12
111 with:
112 tag: ${{ github.ref_name }}
113 fileName: "*"
114
115 - name: Sign Chrome crx for offline distribution
116 uses: cardinalby/webext-buildtools-chrome-crx-action@v2
117 with:
118 zipFilePath: 'yomitan-chrome-dev.zip'
119 crxFilePath: 'yomitan-chrome-dev.crx'
120 privateKey: ${{ secrets.CHROME_CRX_PRIVATE_KEY }}
121
122 - name: Upload offline crx release asset
123 id: uploadReleaseAsset
124 uses: actions/upload-release-asset@v1
125 env:
126 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
127 with:
128 upload_url: ${{ inputs.upload_url }}
129 asset_path: yomitan-chrome-dev.crx
130 asset_name: yomitan-chrome-dev.crx
131 asset_content_type: application/x-chrome-extension