Merge pull request #108 from Higurashi-kagome/fix-107 #29
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
# refs: | |
# https://jam.dev/blog/automating-chrome-extension-publishing/ | |
# https://github.com/notlmn/copy-as-markdown/blob/master/.github/workflows/deployment.yml | |
name: Upload Extension | |
on: | |
push: | |
tags: | |
- v*.*.* | |
env: | |
PACK_NAME: chrome-extension-${{ github.ref_name }} | |
jobs: | |
build-extension: | |
name: run build | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- name: Setup Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: "16.14" | |
- name: Install | |
run: npm ci || npm install | |
- name: Build | |
run: npm run build | |
- name: Sub version | |
uses: bhowell2/[email protected] | |
id: getVersion | |
with: | |
value: ${{ github.ref_name }} | |
index_of_str: "v" | |
output_name: version | |
- name: Update extension version | |
run: npx dot-json dist/manifest.json version ${{ steps.getVersion.outputs.version }} | |
- name: Zip | |
run: zip -r ${{ env.PACK_NAME }}.zip dist | |
- name: Archive chrome-extension artifact | |
uses: actions/upload-artifact@v2 | |
with: | |
name: ${{ env.PACK_NAME }} | |
path: ${{ env.PACK_NAME }}.zip | |
- name: Create release | |
uses: actions/github-script@v6 | |
with: | |
script: > | |
await github.request(`POST /repos/${{ github.repository | |
}}/releases`, { | |
tag_name: "${{ github.ref_name }}", | |
generate_release_notes: true | |
}); | |
# api usage reference: | |
# * <https://developer.chrome.com/docs/webstore/using_webstore_api/> | |
# * <https://github.com/fregante/chrome-webstore-upload/blob/main/How%20to%20generate%20Google%20API%20keys.md> | |
# https://learn.microsoft.com/en-us/microsoft-edge/extensions-chromium/publish/api/using-addons-api | |
# https://www.plasmo.com/blog/posts/edge-extension | |
upload-extension: | |
name: upload extension | |
runs-on: ubuntu-latest | |
needs: build-extension | |
steps: | |
- name: Download bundle artifact | |
uses: actions/download-artifact@v3 | |
with: | |
name: ${{ env.PACK_NAME }} | |
# https://github.com/fregante/chrome-webstore-upload-cli | |
- name: Upload to Chrome | |
run: npx chrome-webstore-upload-cli upload --auto-publish --source ${{ env.PACK_NAME }}.zip --extension-id ${{ secrets.CI_GOOGLE_EXTENSION_ID }} --client-id ${{ secrets.CI_GOOGLE_CLIENT_ID }} --client-secret ${{ secrets.CI_GOOGLE_CLIENT_SECRET }} --refresh-token ${{ secrets.CI_GOOGLE_REFRESH_TOKEN }} | |
# https://github.com/marketplace/actions/publish-edge-add-on | |
- name: Publish to Edge | |
uses: wdzeng/edge-addon@v1 | |
with: | |
product-id: ${{ secrets.CI_EDGE_PRODUCT_ID }} | |
zip-path: ${{ env.PACK_NAME }}.zip | |
client-id: ${{ secrets.CI_EDGE_CLIENT_ID }} | |
client-secret: ${{ secrets.CI_EDGE_CLIENT_SECRET }} | |
access-token-url: ${{ secrets.CI_EDGE_ACCESS_TOKEN_URL }} |