-
Notifications
You must be signed in to change notification settings - Fork 61
91 lines (76 loc) · 2.93 KB
/
deploy.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# 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 }}