-
Notifications
You must be signed in to change notification settings - Fork 3
244 lines (207 loc) · 7.79 KB
/
ci.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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
name: WebExtension Lint, Build, Release, Publish
on:
push:
branches:
- master
- dev
pull_request:
types:
- opened
- synchronize
- reopened
- labeled
workflow_dispatch:
inputs:
nightly:
type: boolean
description: "Nightly Release"
default: true
release:
type: boolean
description: "Stable Release"
default: false
store-upload:
type: boolean
default: false
description: "Upload to CWS/AMO"
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
ARTIFACT_NAME: 7tv-webextension
NIGHTLY_EXTENSION_ID_CWS: fphegifdehlodcepfkgofelcenelpedj
NIGHTLY_EXTENSION_ID_AMO: "{7cc17731-b734-4c98-a154-51d2bf266ef4}"
jobs:
ci:
name: WebExtension Lint, Build, Test
runs-on: aws-runner
concurrency:
group: ${{ github.workflow }}-ci-${{ github.ref }}
cancel-in-progress: true
steps:
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.18.3
- uses: actions/setup-node@v3
with:
node-version: "18"
- name: Install Yarn
run: npm install -g yarn
- name: Checkout code
uses: actions/checkout@v3
- name: Node Modules Cache
uses: actions/cache@v3
with:
path: node_modules
key: ${{ runner.os }}-node_modules-${{ hashFiles('yarn.lock') }}
- name: Install Dependencies
run: |
yarn
- name: Run Linter
run: yarn lint
- name: Build App
env:
BRANCH: ${{ inputs.nightly && 'nightly' || '' }}
run: |
OUT_DIR=mv3 yarn build:prod
OUT_DIR=mv2 MV2=true yarn build:prod
- name: Create Build Archives
run: |
apt-get update && apt-get install -y zip
cd dist/mv3 && zip -r ../mv3.zip . && cd ../../
cd dist/mv2 && zip -r ../mv2.zip .
# CRX is Chromium installer
- name: Create CRX (Chromium)
uses: cardinalby/webext-buildtools-chrome-crx-action@v2
with:
zipFilePath: dist/mv3.zip
crxFilePath: dist/ext.crx
privateKey: ${{ secrets.WEB_EXTENSION_CRX }}
# XPI is Firefox installer
- name: Create XPI (Firefox)
id: web-ext-build
uses: kewisch/action-web-ext@v1
with:
cmd: build
source: dist/mv2
filename: ext.xpi
- name: Structure Files
run: |
mv ${{ steps.web-ext-build.outputs.target }} dist/ext.xpi
mkdir -p dist/manifest
cp dist/mv2/manifest.json dist/manifest/manifest.mv2.json
cp dist/mv3/manifest.json dist/manifest/manifest.mv3.json
- name: Upload Build Artifact
uses: actions/upload-artifact@v3
with:
name: build
retention-days: 60
path: |
dist/ext.crx
dist/ext.xpi
dist/mv3.zip
dist/mv2.zip
- name: Upload Manifest
uses: actions/upload-artifact@v3
with:
name: manifest
path: dist/manifest
release:
name: Create Release
runs-on: aws-runner
needs: [ci]
if: ${{ (inputs.nightly) || (inputs.release) || (github.event_name == 'push' && github.ref_type == 'branch' && github.ref_name == 'master') }}
steps:
- uses: actions/checkout@v3
- name: Download Artifact
uses: actions/download-artifact@v3
with:
name: build
path: ext
- name: File Names
run: |
cd ext/
for file in *; do
mv "$file" "7tv-webextension-$file"
done
- run: |
echo 'PACKAGE_JSON<<EOF' >> $GITHUB_ENV
cat ./package.json >> $GITHUB_ENV
echo 'EOF' >> $GITHUB_ENV
- name: Create Nightly Release
if: ${{ inputs.nightly || (github.event_name == 'push' && github.ref_type == 'branch' && github.ref_name == 'master') }}
id: create_nightly_release
uses: ncipollo/[email protected]
with:
removeArtifacts: true
allowUpdates: true
artifactErrorsFailBuild: true
artifacts: "ext/*"
body: ${{ github.event.head_commit.message }}
prerelease: true
name: Nightly Release
tag: nightly-release
- name: Update Nightly Tag
if: ${{ inputs.nightly || (github.event_name == 'push' && github.ref_type == 'branch' && github.ref_name == 'master') }}
run: |
git tag -f nightly-release
git push -f origin nightly-release
- name: Create Release
if: ${{ inputs.release }}
id: create_release
uses: ncipollo/[email protected]
with:
artifactErrorsFailBuild: true
artifacts: "ext/*"
body: ${{ github.event.head_commit.message }}
prerelease: false
draft: true
name: v${{ fromJson(env.PACKAGE_JSON).version }}
tag: v${{ fromJson(env.PACKAGE_JSON).version }}
push:
name: Submit to CWS/AMO
runs-on: aws-runner
needs: [ci, release]
if: ${{ inputs.store-upload && inputs.nightly }}
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: "18"
# Retrieve the non-CRX MV3 zip to be uploaded to CWS
- name: Download Artifact (Chromium)
uses: actions/download-artifact@v3
with:
name: build
path: ext
# Get the XPI File for Firefox
# It will be uploaded to AMO
- name: Download Manifest
uses: actions/download-artifact@v3
with:
name: manifest
path: manifest
- name: CLI Setup
run: |
npm install -g chrome-webstore-upload-cli
- name: Upload to CWS
env:
CREDENTIALS: ${{ secrets.CWS }}
EXTENSION_ID: ${{ env.NIGHTLY_EXTENSION_ID_CWS }}
run: |
echo "${{ env.CREDENTIALS }}" >> c
chrome-webstore-upload upload \
--source ext/mv3.zip \
--extension-id $EXTENSION_ID \
--client-id "$(sed '1q;d' c)" \
--client-secret "$(sed '2q;d' c)" \
--refresh-token "$(sed '3q;d' c)"
- name: Upload to AMO
uses: trmcnvn/firefox-addon@v1
with:
uuid: ${{ env.NIGHTLY_EXTENSION_ID_AMO }}
xpi: ext/ext.xpi
manifest: manifest/manifest.mv2.json
api-key: ${{ secrets.AMO_API_KEY }}
api-secret: ${{ secrets.AMO_API_SECRET }}