-
Notifications
You must be signed in to change notification settings - Fork 67
348 lines (342 loc) · 11.7 KB
/
build.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
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
name: Build CI
on:
push:
branches: [ master ]
workflow_dispatch: {}
pull_request:
branches: [ master ]
schedule:
# Daily at 12pm UTC
- cron: '0 12 * * *'
jobs:
# Build the compiler jar file from the submodule
build-compiler:
name: Build Compiler
runs-on: ubuntu-latest
env:
COMPILER_NIGHTLY: ${{ github.event_name == 'schedule' }}
FORCE_COLOR: '1'
steps:
- name: Setup Java
uses: actions/setup-java@v3
with:
distribution: adopt-hotspot
java-version: 17
java-package: jdk
architecture: x64
- name: Setup Bazelisk
uses: bazelbuild/setup-bazelisk@v2
- uses: actions/checkout@v3
with:
submodules: recursive
- name: Fetch submodule tags
working-directory: compiler
run: git fetch --tags https://github.com/google/closure-compiler.git
- name: Update compiler submodule to master if nightly build
if: ${{ env.COMPILER_NIGHTLY == 'true' }}
working-directory: compiler
run: |
git checkout master
git pull https://github.com/google/closure-compiler.git master
git log -1 | cat
- name: Get yarn cache directory path
run: echo "yarn_cache_dir=$(yarn cache dir)" >> $GITHUB_ENV
- name: Yarn and maven cache
uses: actions/cache@v3
with:
path: |
${{ env.yarn_cache_dir }}
~/.m2/repository
key: ${{ runner.os }}-yarn-mvn-java11-${{ hashFiles('**/yarn.lock', '**/pom.xml') }}
- name: Install packages
run: yarn install --colors=always
- name: Build jar
run: ./build-scripts/build_compiler.js
- name: Tests
run: node_modules/.bin/mocha --colors
- name: Upload contrib folder
uses: actions/upload-artifact@v3
with:
name: Contrib folder
path: compiler/contrib
- name: Upload compiler jar
uses: actions/upload-artifact@v3
with:
name: Compiler.jar
path: packages/google-closure-compiler-java/compiler.jar
# Build the native image on Linux
# The runner image determines GLIBC compatibility and should not be changed without
# understanding the impact. See https://github.com/google/closure-compiler-npm/issues/280
build-linux:
name: Build Linux Native Image
needs: build-compiler
runs-on: ubuntu-20.04
env:
NODE_VERSION: '14.x'
FORCE_COLOR: '1'
steps:
- name: Setup Java
uses: actions/setup-java@v3
with:
distribution: adopt-hotspot
java-version: 17
java-package: jdk
architecture: x64
- uses: actions/checkout@v3
- name: Use Node.js ${{ env.NODE_VERSION }}
uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_VERSION }}
- uses: graalvm/setup-graalvm@v1
with:
version: '22.3.2'
java-version: '17'
components: 'native-image'
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Setup upx
run: |
UPX_VERSION=3.96
curl --fail --show-error --location --remote-name "https://github.com/upx/upx/releases/download/v$UPX_VERSION/upx-$UPX_VERSION-amd64_linux.tar.xz"
tar -xf upx-$UPX_VERSION-amd64_linux.tar.xz
mv ./upx-$UPX_VERSION-amd64_linux/upx /usr/local/bin/upx
- name: Download compiler jar
uses: actions/download-artifact@v3
with:
name: Compiler.jar
path: packages/google-closure-compiler-java/
- name: Download contrib folder
uses: actions/download-artifact@v3
with:
name: Contrib folder
path: packages/google-closure-compiler/contrib
- name: Get yarn cache directory path
run: echo "yarn_cache_dir=$(yarn cache dir)" >> $GITHUB_ENV
- name: Cache yarn
uses: actions/cache@v3
id: yarn-cache
with:
path: ${{ env.yarn_cache_dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Install packages
run: yarn install --colors=always
- name: Build image
working-directory: packages/google-closure-compiler-linux
run: |
cp ../google-closure-compiler-java/compiler.jar compiler.jar
yarn run build
upx compiler
- name: Tests
run: yarn workspaces run test --colors
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
name: Linux image
path: packages/google-closure-compiler-linux/compiler
# Build the native image on MacOS
build-macos:
name: Build MacOS Native Image
needs: build-compiler
runs-on: macos-latest
env:
NODE_VERSION: '16.x'
FORCE_COLOR: '1'
steps:
- name: Setup Java
uses: actions/setup-java@v3
with:
distribution: adopt-hotspot
java-version: 17
java-package: jdk
architecture: x64
- uses: actions/checkout@v3
- name: Use Node.js ${{ env.NODE_VERSION }}
uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_VERSION }}
- uses: graalvm/setup-graalvm@v1
with:
version: '22.3.2'
java-version: '17'
components: 'native-image'
github-token: ${{ secrets.GITHUB_TOKEN }}
# # See https://github.com/google/closure-compiler-npm/issues/265
# - name: Install upx
# run: brew install upx
- name: Download compiler jar
uses: actions/download-artifact@v3
with:
name: Compiler.jar
path: packages/google-closure-compiler-java/
- name: Download contrib folder
uses: actions/download-artifact@v3
with:
name: Contrib folder
path: packages/google-closure-compiler/contrib
- name: Get yarn cache directory path
run: echo "yarn_cache_dir=$(yarn cache dir)" >> $GITHUB_ENV
- name: Cache yarn
uses: actions/cache@v3
id: yarn-cache
with:
path: ${{ env.yarn_cache_dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Install packages
run: yarn install --colors=always
- name: Build image
working-directory: packages/google-closure-compiler-osx
run: |
cp ../google-closure-compiler-java/compiler.jar compiler.jar
yarn run build
# upx compiler
- name: Tests
run: yarn workspaces run test --colors
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
name: MacOS image
path: packages/google-closure-compiler-osx/compiler
# Build the native image on Windows
build-windows:
name: Build Windows Native Image
needs: build-compiler
runs-on: windows-latest
env:
NODE_VERSION: '18.x'
FORCE_COLOR: '1'
steps:
- name: Setup Java
uses: actions/setup-java@v3
with:
distribution: adopt-hotspot
java-version: 17
java-package: jdk
architecture: x64
- uses: actions/checkout@v3
- name: Use Node.js ${{ env.NODE_VERSION }}
uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_VERSION }}
- uses: graalvm/setup-graalvm@v1
with:
version: '22.3.2'
java-version: '17'
components: 'native-image'
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Download compiler jar
uses: actions/download-artifact@v3
with:
name: Compiler.jar
path: packages/google-closure-compiler-java/
- name: Download contrib folder
uses: actions/download-artifact@v3
with:
name: Contrib folder
path: packages/google-closure-compiler/contrib
- name: Get yarn cache directory path
# See https://stackoverflow.com/a/66737579/1211524
run: echo "yarn_cache_dir=$(yarn cache dir)" >> $env:GITHUB_ENV
- name: Cache yarn
uses: actions/cache@v3
id: yarn-cache
with:
path: ${{ env.yarn_cache_dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Install packages
run: yarn install --colors=always
- name: Build image
working-directory: packages/google-closure-compiler-windows
run: |
cp ../google-closure-compiler-java/compiler.jar compiler.jar
yarn run build
- name: Tests
shell: cmd
run: |
echo "Running Tests"
yarn workspaces run test --colors
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
name: Windows image
path: packages/google-closure-compiler-windows/compiler.exe
# Publish the packages if needed
publish-packages:
name: Publish Packages
runs-on: ubuntu-latest
if: ${{ github.event_name == 'schedule' || github.event_name == 'push' || github.event_name == 'workflow_dispatch' }}
env:
NODE_VERSION: '18.x'
COMPILER_NIGHTLY: ${{ github.event_name == 'schedule' }}
NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_AUTH_TOKEN }}
FORCE_COLOR: '1'
needs:
- build-linux
- build-macos
- build-windows
steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ env.NODE_VERSION }}
uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_VERSION }}
registry-url: https://registry.npmjs.org/
- name: Download compiler jar
uses: actions/download-artifact@v3
with:
name: Compiler.jar
path: packages/google-closure-compiler-java/
- name: Download Linux image
uses: actions/download-artifact@v3
with:
name: Linux image
path: packages/google-closure-compiler-linux/
- name: Download MacOS image
uses: actions/download-artifact@v3
with:
name: MacOS image
path: packages/google-closure-compiler-osx/
- name: Download Windows image
uses: actions/download-artifact@v3
with:
name: Windows image
path: packages/google-closure-compiler-windows/
- name: Download contrib folder
uses: actions/download-artifact@v3
with:
name: Contrib folder
path: packages/google-closure-compiler/contrib
- name: Mark binaries executable
run: |
chmod 755 packages/google-closure-compiler-linux/compiler
chmod 755 packages/google-closure-compiler-osx/compiler
chmod 755 packages/google-closure-compiler-windows/compiler.exe
- name: Get yarn cache directory path
run: echo "yarn_cache_dir=$(yarn cache dir)" >> $GITHUB_ENV
- name: Cache yarn
uses: actions/cache@v3
id: yarn-cache
with:
path: ${{ env.yarn_cache_dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Install packages
run: yarn install --colors=always
- name: Prepare for publish
run: ./build-scripts/add-os-restrictions.js
- name: Create the nightly version
if: ${{ env.COMPILER_NIGHTLY == 'true' }}
run: |
git config --global user.email "[email protected]"
git config --global user.name "Github Bot"
./build-scripts/create-nightly-version.js
- name: Configure yarn
run: yarn config set registry https://registry.npmjs.org/
- name: Publish packages to npm
#run: yarn publish-packages
run: echo "Skipping yarn publish-packages step"