aboutsummaryrefslogtreecommitdiff
path: root/.github/workflows/publish-chrome.yml
diff options
context:
space:
mode:
authorDarius Jahandarie <djahandarie@gmail.com>2023-03-18 11:29:45 +0900
committerGitHub <noreply@github.com>2023-03-18 11:29:45 +0900
commite7a6f0354b8c38046e449566a371e366ef6b6889 (patch)
treecd3b2b7d30b8dac0ecbd4ebc91b9d1da8da36819 /.github/workflows/publish-chrome.yml
parent0314a8620f952aa5b0129e93f2d0956b0e0cc7c2 (diff)
parent1dd47d0876833c1d61572577ae5b9d2215578c07 (diff)
Merge pull request #92 from themoeway/cd
Add CD to build and publish extension to Chrome & Firefox stores
Diffstat (limited to '.github/workflows/publish-chrome.yml')
-rw-r--r--.github/workflows/publish-chrome.yml100
1 files changed, 100 insertions, 0 deletions
diff --git a/.github/workflows/publish-chrome.yml b/.github/workflows/publish-chrome.yml
new file mode 100644
index 00000000..cb47d565
--- /dev/null
+++ b/.github/workflows/publish-chrome.yml
@@ -0,0 +1,100 @@
+name: publish-chrome
+on:
+ release:
+ types: [released]
+ workflow_dispatch:
+ inputs:
+ attemptNumber:
+ description: "Attempt number"
+ required: false
+ default: "1"
+ maxAttempts:
+ description: "Max attempts"
+ required: false
+ default: "10"
+permissions:
+ actions: write
+ contents: read
+jobs:
+ upload-on-webstore:
+ runs-on: ubuntu-latest
+ environment: cd
+ outputs:
+ result: ${{ steps.webStorePublish.outcome }}
+ releaseUploadUrl: ${{ steps.getZipAsset.outputs.releaseUploadUrl }}
+ steps:
+ - name: Get the next attempt number
+ id: getNextAttemptNumber
+ uses: cardinalby/js-eval-action@b34865f1d9cfdf35356013627474857cfe0d5091 # pin@v1.0.7
+ 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: actions/checkout@v3
+
+ - uses: robinraju/release-downloader@768b85c8d69164800db5fc00337ab917daf3ce68 # pin@v1.7
+ with:
+ tag: ${{ github.ref_name }}
+ fileName: "*"
+
+ - name: Fetch Google API access token
+ id: fetchAccessToken
+ uses: cardinalby/google-api-fetch-token-action@24c99245e2a2494cc4c4b1037203d319a184b15b # pin@v1.0.3
+ 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@8db7a005529498d95d3e2e0166f6f4050d2b96a5 # pin@v1.0.10
+ with:
+ zipFilePath: builds/yomitan-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@93e95b157d791ae7f42aef8f8a0d3d723eba1c31 # 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 # pin@v1.0.7
+ with:
+ extensionId: ${{ secrets.G_STABLE_EXTENSION_ID }}
+ apiAccessToken: ${{ steps.fetchAccessToken.outputs.accessToken }}