-
Notifications
You must be signed in to change notification settings - Fork 0
129 lines (111 loc) · 4.31 KB
/
extension.yaml
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
name: 'extension'
on:
push:
branches: [main]
jobs:
build:
runs-on: ubuntu-latest
environment:
name: Extension
steps:
- uses: actions/checkout@v4
- name: Setup Node.js environment
uses: actions/setup-node@v4
- name: Install pnpm
run: npm install -g pnpm
- name: Install webextension-store-meta
run: pnpm add -D webextension-store-meta -w
- name: Check version against latest release in Chrome Web Store
id: check_version
uses: actions/github-script@v7
with:
script: |
const fs = require('fs/promises');
const { ChromeWebStore } = require('webextension-store-meta/lib/chrome-web-store');
const getManifestVersion = async (filePath) => {
const data = await fs.readFile(filePath, 'utf8');
const manifest = JSON.parse(data);
return manifest.version;
};
const checkVersion = async (chromeId) => {
const chromeWebStore = await ChromeWebStore.load({ id: chromeId, qs: { hl: 'en' } });
return chromeWebStore.meta().version;
};
const fetchVersionInfo = async () => {
try {
const currentVersion = await getManifestVersion('./holo-key-manager-extension/static/manifest.json');
const latestVersion = await checkVersion('${{ vars.CHROME_ID }}');
core.setOutput('abort', currentVersion === latestVersion ? 'true' : 'false');
} catch (error) {
core.setFailed(error.message);
}
};
fetchVersionInfo();
- name: Abort build if version matches
if: steps.check_version.outputs.abort == 'true'
run: |
echo "Version in manifest matches the latest release version in Chrome Web Store. Aborting build."
exit 1
- name: Install dependencies
run: pnpm install --no-frozen-lockfile
- name: Build extension
run: pnpm build
working-directory: holo-key-manager-extension
- name: Zip the build
run: |
cd build
zip -r ../build.zip .
cd ..
working-directory: holo-key-manager-extension
- name: Chrome upload & release
uses: mobilefirstllc/cws-publish@latest
continue-on-error: true
with:
action: publish
client_id: ${{ secrets.CHROME_CLIENT_ID }}
client_secret: ${{ secrets.CHROME_CLIENT_SECRET }}
refresh_token: ${{ secrets.CHROME_REFRESH_TOKEN }}
extension_id: ${{ vars.CHROME_ID }}
zip_file: holo-key-manager-extension/build.zip
- name: Unzip build for Edge
run: |
unzip build.zip -d buildEdge
working-directory: holo-key-manager-extension
- name: Remove key field from manifest for Edge
run: |
jq 'del(.key)' buildEdge/manifest.json > temp.json && mv temp.json buildEdge/manifest.json
working-directory: holo-key-manager-extension
- name: Zip the build for Edge
run: |
cd buildEdge
zip -r ../buildEdge.zip .
cd ..
working-directory: holo-key-manager-extension
- name: Edge upload & release
uses: wdzeng/edge-addon@v1
continue-on-error: true
with:
product-id: ${{ vars.EDGE_ID }}
zip-path: holo-key-manager-extension/buildEdge.zip
client-id: ${{ secrets.EDGE_CLIENT_ID }}
client-secret: ${{ secrets.EDGE_CLIENT_SECRET }}
access-token-url: ${{ secrets.EDGE_ACCESS_TOKEN_URL }}
- name: Replace manifest
run: pnpm build:replaceForFirefox ${{ vars.FF_ID }}
working-directory: holo-key-manager-extension
- name: Build extension
run: pnpm build
working-directory: holo-key-manager-extension
- name: Zip the build
run: |
cd build
zip -r ../buildFF.zip .
cd ..
working-directory: holo-key-manager-extension
- name: Firefox upload & release
uses: cardinalby/webext-buildtools-firefox-addons-action@v1
with:
zipFilePath: holo-key-manager-extension/buildFF.zip
extensionId: ${{ vars.FF_ID }}
jwtIssuer: ${{ secrets.FF_JWT_ISSUER }}
jwtSecret: ${{ secrets.FF_JWT_SECRET }}