publish-chrome #34
Workflow file for this run
This file contains 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-chrome | |
on: | |
workflow_dispatch: | |
inputs: | |
attemptNumber: | |
description: "Attempt number" | |
required: false | |
default: "1" | |
maxAttempts: | |
description: "Max attempts" | |
required: false | |
default: "10" | |
permissions: | |
contents: read | |
jobs: | |
upload-on-webstore: | |
runs-on: ubuntu-latest | |
environment: cd | |
outputs: | |
result: ${{ steps.webStorePublish.outcome }} | |
releaseUploadUrl: ${{ steps.getZipAsset.outputs.releaseUploadUrl }} | |
permissions: | |
actions: write | |
steps: | |
- name: Get the next attempt number | |
id: getNextAttemptNumber | |
uses: cardinalby/js-eval-action@e905fd3681d757e992c976f61c2784dcb4060e13 # [email protected] | |
env: | |
attemptNumber: ${{ github.event.inputs.attemptNumber }} | |
maxAttempts: ${{ github.event.inputs.maxAttempts }} | |
with: | |
expression: | | |
{ | |
const | |
attempt = parseInt(env.attemptNumber), | |
max = parseInt(env.maxAttempts); | |
assert(attempt && max && max >= attempt); | |
return attempt < max ? attempt + 1 : ''; | |
} | |
- uses: robinraju/release-downloader@a96f54c1b5f5e09e47d9504526e96febd949d4c2 # [email protected] | |
with: | |
tag: ${{ github.ref_name }} | |
fileName: "*" | |
- name: Fetch Google API access token | |
id: fetchAccessToken | |
uses: cardinalby/google-api-fetch-token-action@f455422472a558d48d939e77a65cdcec38e707b5 # [email protected] | |
with: | |
clientId: ${{ secrets.G_CLIENT_ID }} | |
clientSecret: ${{ secrets.G_CLIENT_SECRET }} | |
refreshToken: ${{ secrets.G_REFRESH_TOKEN }} | |
- name: Upload to Google Web Store | |
id: webStoreUpload | |
continue-on-error: true | |
uses: cardinalby/webext-buildtools-chrome-webstore-upload-action@3d829e042b559c35f7fb71676cbaf6031892a313 # v1.0.11 | |
with: | |
zipFilePath: rikaitan-chrome.zip | |
extensionId: ${{ secrets.G_STABLE_EXTENSION_ID }} | |
apiAccessToken: ${{ steps.fetchAccessToken.outputs.accessToken }} | |
waitForUploadCheckCount: 10 | |
waitForUploadCheckIntervalMs: 180000 # 3 minutes | |
# Schedule a next attempt if store refused to accept new version because it | |
# still has a previous one in review | |
- name: Start the next attempt with the delay | |
uses: aurelien-baudet/workflow-dispatch@3133c5d135c7dbe4be4f9793872b6ef331b53bc7 # pin@v2 | |
if: | | |
steps.getNextAttemptNumber.outputs.result && | |
steps.webStoreUpload.outputs.inReviewError == 'true' | |
with: | |
workflow: delay | |
token: ${{ secrets.GITHUB_TOKEN }} | |
wait-for-completion: false | |
inputs: | | |
{ | |
"attemptNumber": "${{ steps.getNextAttemptNumber.outputs.result }}", | |
"maxAttempts": "${{ github.event.inputs.maxAttempts }}", | |
"workflow": "${{ github.workflow }}" | |
} | |
- name: Abort on unrecoverable upload error | |
if: | | |
!steps.webStoreUpload.outputs.newVersion && | |
steps.webStoreUpload.outputs.sameVersionAlreadyUploadedError != 'true' | |
run: exit 1 | |
- name: Publish on Google Web Store | |
id: webStorePublish | |
if: | | |
steps.webStoreUpload.outputs.newVersion || | |
steps.webStoreUpload.outputs.sameVersionAlreadyUploadedError == 'true' | |
uses: cardinalby/webext-buildtools-chrome-webstore-publish-action@d39ebd4ab4ea4b44498bf5fc34d4b3db7706f1ed # [email protected] | |
with: | |
extensionId: ${{ secrets.G_STABLE_EXTENSION_ID }} | |
apiAccessToken: ${{ steps.fetchAccessToken.outputs.accessToken }} |