-
Notifications
You must be signed in to change notification settings - Fork 3
287 lines (241 loc) · 9.44 KB
/
build-browser.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
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
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
# https://github.com/bitwarden/clients/blob/main/.github/workflows/build-browser.yml
---
name: Build Browser
on:
workflow_call:
inputs: {}
workflow_dispatch:
inputs: {}
push:
branches: [master, main]
schedule:
# On every Sunday 12:00
- cron: "0 12 * * 0"
permissions:
contents: write # To Release
defaults:
run:
shell: bash
jobs:
setup:
name: Setup
runs-on: ubuntu-22.04
outputs:
latest_browser_tag: ${{ steps.gen_vars.outputs.latest_browser_tag }}
node_version: ${{ steps.retrieve-node-version.outputs.node_version }}
steps:
- name: Checkout repo
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Clone real repo
run: |
git clone https://github.com/bitwarden/clients.git
- name: Get Latest Browser Tag
id: gen_vars
working-directory: clients
run: |
# Find all tags and sort by time
git fetch --tags
tags=$(git tag --sort=-creatordate)
# Find "browser" tag
latest_browser_tag=""
for tag in $tags; do
if [[ $tag == *"browser"* ]]; then
latest_browser_tag=$tag
break
fi
done
echo "latest_browser_tag=$latest_browser_tag" >> $GITHUB_OUTPUT
echo "latest_browser_tag=$latest_browser_tag"
- name: Get Node Version
id: retrieve-node-version
working-directory: clients
run: |
NODE_NVMRC=$(cat .nvmrc)
NODE_VERSION=${NODE_NVMRC/v/''}
echo "node_version=$NODE_VERSION" >> $GITHUB_OUTPUT
locales-test:
name: Locales Test
runs-on: ubuntu-22.04
needs:
- setup
env:
_LATEST_BROWSER_TAG: ${{ needs.setup.outputs.latest_browser_tag }}
_NODE_VERSION: ${{ needs.setup.outputs.node_version }}
defaults:
run:
working-directory: clients/apps/browser/
steps:
- name: Checkout repo
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Clone real repo
run: |
git clone https://github.com/bitwarden/clients.git
- name: Setup repo
working-directory: clients
run: |
git fetch --tags
echo "Checking out ${{ env._LATEST_BROWSER_TAG }}"
git checkout ${{ env._LATEST_BROWSER_TAG }}
- name: Testing locales - extName length
run: |
found_error=false
echo "Locales Test"
echo "============"
echo "extName string must be 40 characters or less"
echo
for locale in $(ls src/_locales/); do
string_length=$(jq '.extName.message | length' src/_locales/$locale/messages.json)
if [[ $string_length -gt 40 ]]; then
echo "$locale: $string_length"
found_error=true
fi
done
if $found_error; then
echo
echo "Please fix 'extName' for the locales listed above."
# exit 1
else
echo "Test passed!"
fi
build:
name: Build
runs-on: ubuntu-22.04
needs:
- setup
- locales-test
env:
_LATEST_BROWSER_TAG: ${{ needs.setup.outputs.latest_browser_tag }}
_NODE_VERSION: ${{ needs.setup.outputs.node_version }}
steps:
- name: Checkout repo
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Clone real repo
run: |
git clone https://github.com/bitwarden/clients.git
- name: Setup repo
working-directory: clients
run: |
git fetch --tags
echo "Checking out ${{ env._LATEST_BROWSER_TAG }}"
git checkout ${{ env._LATEST_BROWSER_TAG }}
- name: Set up Node
uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0
with:
cache: "npm"
cache-dependency-path: "**/package-lock.json"
node-version: ${{ env._NODE_VERSION }}
- name: Print environment
run: |
node --version
npm --version
- name: Apply internal patch
run: |
# To create a patch, git diff > mypatch.patch
repo_dir="clients"
patches_dir="patches"
cp -r $patches_dir/* .
cp fakePremium.patch "$repo_dir"
cp images/* "$repo_dir/apps/browser/src/images/"
# Python script before cd
python patchManifestV3.py
python patchManifestV2.py
cd "$repo_dir"
git apply fakePremium.patch -v
- name: Build sources for reviewers
working-directory: clients
run: |
# Include hidden files in glob copy
shopt -s dotglob
# Remove ".git" directory
rm -r .git
# Copy root level files to source directory
mkdir browser-source
FILES=$(find . -maxdepth 1 -type f)
for FILE in $FILES; do cp "$FILE" browser-source/; done
# Copy patches to the Browser source directory
mkdir -p browser-source/patches
cp -r patches/* browser-source/patches
# Copy apps/browser to the Browser source directory
mkdir -p browser-source/apps/browser
cp -r apps/browser/* browser-source/apps/browser
# Copy libs to Browser source directory
mkdir browser-source/libs
cp -r libs/* browser-source/libs
zip -r browser-source.zip browser-source
- name: NPM setup
run: npm ci
working-directory: clients/browser-source/
- name: Build
run: npm run dist
working-directory: clients/browser-source/apps/browser
- name: Build Manifest v3
run: npm run dist:mv3
working-directory: clients/browser-source/apps/browser
- name: Build Chrome Manifest v3 Beta
run: npm run dist:chrome:beta
working-directory: clients/browser-source/apps/browser
- name: Upload Opera artifact
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
with:
name: dist-opera-${{ env._LATEST_BROWSER_TAG }}.zip
path: clients/browser-source/apps/browser/dist/dist-opera.zip
if-no-files-found: error
- name: Upload Opera MV3 artifact (DO NOT USE FOR PROD)
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
with:
name: DO-NOT-USE-FOR-PROD-dist-opera-MV3-${{ env._LATEST_BROWSER_TAG }}.zip
path: clients/browser-source/apps/browser/dist/dist-opera-mv3.zip
if-no-files-found: error
- name: Upload Chrome MV3 artifact
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
with:
name: dist-chrome-MV3-${{ env._LATEST_BROWSER_TAG }}.zip
path: clients/browser-source/apps/browser/dist/dist-chrome-mv3.zip
if-no-files-found: error
- name: Upload Chrome MV3 Beta artifact (DO NOT USE FOR PROD)
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
with:
name: DO-NOT-USE-FOR-PROD-dist-chrome-MV3-beta-${{ env._LATEST_BROWSER_TAG }}.zip
path: clients/browser-source/apps/browser/dist/dist-chrome-mv3-beta.zip
if-no-files-found: error
- name: Upload Firefox artifact
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
with:
name: dist-firefox-${{ env._LATEST_BROWSER_TAG }}.zip
path: clients/browser-source/apps/browser/dist/dist-firefox.zip
if-no-files-found: error
- name: Upload Firefox MV3 artifact (DO NOT USE FOR PROD)
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
with:
name: DO-NOT-USE-FOR-PROD-dist-firefox-MV3-${{ env._LATEST_BROWSER_TAG }}.zip
path: clients/browser-source/apps/browser/dist/dist-firefox-mv3.zip
if-no-files-found: error
- name: Upload Edge artifact
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
with:
name: dist-edge-${{ env._LATEST_BROWSER_TAG }}.zip
path: clients/browser-source/apps/browser/dist/dist-edge.zip
if-no-files-found: error
- name: Upload Edge MV3 artifact (DO NOT USE FOR PROD)
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
with:
name: DO-NOT-USE-FOR-PROD-dist-edge-MV3-${{ env._LATEST_BROWSER_TAG }}.zip
path: clients/browser-source/apps/browser/dist/dist-edge-mv3.zip
if-no-files-found: error
- name: Upload browser source
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
with:
name: browser-source-${{ env._LATEST_BROWSER_TAG }}.zip
path: clients/browser-source.zip
if-no-files-found: error
- name: Create release
uses: ncipollo/release-action@2c591bcc8ecdcd2db72b97d6147f871fcd833ba5 # v1.14.0
with:
artifacts: "clients/browser-source/apps/browser/dist/*,clients/browser-source.zip"
tag: "${{ env._LATEST_BROWSER_TAG }}"
name: "${{ env._LATEST_BROWSER_TAG }}"
body: "${{ env._LATEST_BROWSER_TAG }} [Original Changelog](https://github.com/bitwarden/clients/releases/tag/${{ env._LATEST_BROWSER_TAG }})"
token: ${{ secrets.GITHUB_TOKEN }}
draft: false
allowUpdates: true
makeLatest: true