-
Notifications
You must be signed in to change notification settings - Fork 1.2k
314 lines (276 loc) · 11.8 KB
/
prebuild.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
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
# Release procedure:
# 1. On the master branch, update the changelog and stage it in git.
# 2. Run `yarn version --[major|minor|patch]`. (This tags the commit.)
# 3. Push both the commit and tags to GitHub (`git push --tags Automattic` and
# `git push Automattic HEAD:master`, where "Automattic" is the remote name
# for [email protected]:Automattic/node-canvas.git).
# 4. Create a draft release manually using the GitHub UI for the new tag.
# 5. Switch to the prebuilds branch.
# 6. Set the `jobs.*.strategy.matrix.node` arrays to the set of Node.js versions
# to build for.
# 7. Set the `jobs.*.strategy.matrix.canvas_tag` arrays to the set of Canvas
# tags to build. (Usually this is a single tag, but can be an array when a
# new version of Node.js is released and older versions of Canvas need to be
# built.)
# 8. Commit this file and push.
# 9. In the Actions tab, navigate to the "Make Prebuilds" workflow and click
# "Run workflow". Select the `prebuilds` branch so that that branch's
# prebuild.yaml file is used.
# 10.Once the builds succeed, promote the draft release to a full release and
# run npm publish.
# Note that the files in the prebuild/ directory will be used from the commit
# that was used to trigger the prebuild workflow. They will not be from the
# commit/tag that you are building. Because of differences in the provided
# versions of git, this is achieved in a different way on Linux than on Mac and
# Win.
#
# Pay particular attention to changes to binding.gyp on master. That file is not
# used! The ones in prebuild/**/ are.
# Tip: If uploads are inexplicably failing, open the release in GitHub, click
# "edit" and delete any assets that are in purgatory (have a /!\ next to them).
name: Make Prebuilds
on: workflow_dispatch
# UPLOAD_TO can be specified to upload the release assets under a different tag
# name (e.g. for testing). If omitted, the assets are published under the same
# release tag as the canvas version being built.
# env:
# UPLOAD_TO: "v0.0.1"
# Node 19 requires a recent node-gyp
# Node 10, 11 require 8
# Node 8, 9 require 6.1
# Manually set this file depending on what you're building!!
jobs:
Linux:
strategy:
fail-fast: false
matrix:
node: [21]
canvas_tag: ["v3.0.0-rc1b"] # e.g. "v2.6.1"
name: ${{ matrix.canvas_tag }}, Node.js ${{ matrix.node }}, Linux
runs-on: ubuntu-latest
container:
image: ${{ matrix.node < 18 && 'chearon/canvas-prebuilt:9' || 'zbbjornson/canvas-prebuilt:10' }}
env:
CANVAS_VERSION_TO_BUILD: ${{ matrix.canvas_tag }}
steps:
- uses: actions/checkout@v2
with:
ref: ${{ matrix.canvas_tag }}
# Use the files in the prebuild/ directory from the commit that was used
# to trigger the prebuild workflow. The version of git that's installed on
# this Linux here doesn't support the method used on Mac and Win, so we
# checkout the prebuild branch and copy the files from the prebuild/
# directory in the Build step.
- uses: actions/checkout@v2
with:
ref: ${{ env.GITHUB_SHA }}
path: prebuild-branch
- uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node }}
- name: Build
run: |
set -ex
mkdir -p prebuild
cp -rfv ./prebuild-branch/prebuild/* ./prebuild/
npm install -g node-gyp
npm install --ignore-scripts
# . prebuild/Linux/preinstall.sh
cp prebuild/Linux/binding.gyp binding.gyp
node-gyp rebuild -j 2
. prebuild/Linux/bundle.sh
- name: Test binary
continue-on-error: true
run: |
set -ex
cd /root/harfbuzz-* && make uninstall
cd /root/cairo-* && make uninstall
cd /root/pango-* && cd _build && ninja uninstall
cd /root/libpng-* && make uninstall
cd /root/libjpeg-* && cd b && make uninstall
cd /root/giflib-* && make uninstall
cd $GITHUB_WORKSPACE
ls build/Release
ldd build/Release/canvas.node
npx mocha test/*.test.js
- name: Make bundle
id: make_bundle
run: . prebuild/tarball.sh
- name: Upload
uses: actions/github-script@v2
with:
script: |
const fs = require("fs");
const assetName = "${{ steps.make_bundle.outputs.asset_name }}";
const tagName = process.env.UPLOAD_TO || process.env.CANVAS_VERSION_TO_BUILD;
const [owner, repo] = process.env.GITHUB_REPOSITORY.split("/");
const releases = await github.repos.listReleases({owner, repo});
const release = releases.data.find(r => r.tag_name === tagName);
if (!release)
throw new Error(`Tag ${tagName} not found. Did you make the GitHub release?`);
const oldAsset = release.assets.find(a => a.name === assetName);
if (oldAsset)
await github.repos.deleteReleaseAsset({owner, repo, asset_id: oldAsset.id});
// (This is equivalent to actions/upload-release-asset. We're
// already in a script, so might as well do it here.)
const r = await github.repos.uploadReleaseAsset({
url: release.upload_url,
headers: {
"content-type": "application/x-gzip",
"content-length": `${fs.statSync(assetName).size}`
},
name: assetName,
data: fs.readFileSync(assetName)
});
macOS:
strategy:
fail-fast: false
matrix:
node: [21]
canvas_tag: ["v3.0.0-rc1b"] # e.g. "v2.6.1"
name: ${{ matrix.canvas_tag}}, Node.js ${{ matrix.node }}, macOS
runs-on: macos-latest
env:
CANVAS_VERSION_TO_BUILD: ${{ matrix.canvas_tag }}
steps:
- uses: actions/checkout@v2
with:
ref: ${{ matrix.canvas_tag }}
# Fetch all commits/all branches so we can checkout the prebuild
# branch's files
fetch-depth: 0
- uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node }}
- name: Build
run: |
set -Eeuxo pipefail
git checkout ${{ matrix.canvas_tag }}
git checkout $GITHUB_SHA -- prebuild/
npm install -g node-gyp
npm install --ignore-scripts
. prebuild/macOS/preinstall.sh
cp prebuild/macOS/binding.gyp binding.gyp
node-gyp rebuild -j 2
. prebuild/macOS/bundle.sh
- name: Test binary
run: |
brew uninstall --force --ignore-dependencies cairo pango librsvg giflib harfbuzz
npm test
- name: Make bundle
id: make_bundle
run: . prebuild/tarball.sh
- name: Upload
uses: actions/github-script@v2
with:
script: |
const fs = require("fs");
const assetName = "${{ steps.make_bundle.outputs.asset_name }}";
const tagName = process.env.UPLOAD_TO || process.env.CANVAS_VERSION_TO_BUILD;
const [owner, repo] = process.env.GITHUB_REPOSITORY.split("/");
const releases = await github.repos.listReleases({owner, repo});
const release = releases.data.find(r => r.tag_name === tagName);
if (!release)
throw new Error(`Tag ${tagName} not found. Did you make the GitHub release?`);
const oldAsset = release.assets.find(a => a.name === assetName);
if (oldAsset)
await github.repos.deleteReleaseAsset({owner, repo, asset_id: oldAsset.id});
// (This is equivalent to actions/upload-release-asset. We're
// already in a script, so might as well do it here.)
const r = await github.repos.uploadReleaseAsset({
url: release.upload_url,
headers: {
"content-type": "application/x-gzip",
"content-length": `${fs.statSync(assetName).size}`
},
name: assetName,
data: fs.readFileSync(assetName)
});
Win:
strategy:
fail-fast: false
matrix:
node: [21]
canvas_tag: ["v3.0.0-rc1b"] # e.g. "v2.6.1"
name: ${{ matrix.canvas_tag}}, Node.js ${{ matrix.node }}, Windows
runs-on: windows-2019
env:
CANVAS_VERSION_TO_BUILD: ${{ matrix.canvas_tag }}
steps:
# GitHub runners now have msys2 installed, but msys is not on the path and
# is apparently slow to start.
# https://github.com/msys2/setup-msys2#setup-msys2
# https://github.com/actions/virtual-environments/pull/632
- uses: msys2/setup-msys2@v2
with:
msystem: UCRT64
update: true
path-type: inherit
- uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}
- uses: actions/checkout@v3
with:
ref: ${{ matrix.canvas_tag }}
# Fetch all commits/all branches so we can checkout the prebuild
# branch's files
fetch-depth: 0
- name: Build
run: |
git checkout ${{ matrix.canvas_tag }}
git checkout $env:GITHUB_SHA -- prebuild/
npm install -g node-gyp
npm prefix -g | % {npm config set node_gyp "$_\node_modules\node-gyp\bin\node-gyp.js"}
npm install --ignore-scripts
msys2 -c ". prebuild/Windows/preinstall.sh"
msys2 -c "cp prebuild/Windows/binding.gyp binding.gyp"
npm install --build-from-source
- name: Install Depends
run: |
Invoke-WebRequest "http://www.dependencywalker.com/depends22_x64.zip" -OutFile depends22_x64.zip
7z e depends22_x64.zip
- name: Bundle pt 2
shell: msys2 {0}
run: |
./depends.exe -c -oc depends.csv build\\Release\\canvas.node || true
[ -f depends.csv ] || { echo "error invoking depends.exe"; exit 1; }
copies=$(comm -12 \
<(cat depends.csv | cut -d ',' -f2 | sed 's/"//g' | tr '[:upper:]' '[:lower:]' | sort) \
<(find /ucrt64/bin -name '*.dll' -printf "%f\n" | tr '[:upper:]' '[:lower:]' | sort) \
)
for dll in $copies; do
cp /ucrt64/bin/$dll build/Release
done;
- name: Test binary
# By not running in msys2, this doesn't have access to the msys2 libs
run: npm test
- name: Make asset
id: make_bundle
# I can't figure out why this isn't an env var already. It shows up with `env`.
run: msys2 -c "UPLOAD_TO=${{ env.UPLOAD_TO }} CANVAS_VERSION_TO_BUILD=${{ env.CANVAS_VERSION_TO_BUILD}} . prebuild/tarball.sh"
- name: Upload
uses: actions/github-script@v2
with:
script: |
const fs = require("fs");
const assetName = "${{ steps.make_bundle.outputs.asset_name }}";
const tagName = process.env.UPLOAD_TO || process.env.CANVAS_VERSION_TO_BUILD;
const [owner, repo] = process.env.GITHUB_REPOSITORY.split("/");
const releases = await github.repos.listReleases({owner, repo});
const release = releases.data.find(r => r.tag_name === tagName);
if (!release)
throw new Error(`Tag ${tagName} not found. Did you make the GitHub release?`);
const oldAsset = release.assets.find(a => a.name === assetName);
if (oldAsset)
await github.repos.deleteReleaseAsset({owner, repo, asset_id: oldAsset.id});
// (This is equivalent to actions/upload-release-asset. We're
// already in a script, so might as well do it here.)
const r = await github.repos.uploadReleaseAsset({
url: release.upload_url,
headers: {
"content-type": "application/x-gzip",
"content-length": `${fs.statSync(assetName).size}`
},
name: assetName,
data: fs.readFileSync(assetName)
});