@@ -21,11 +21,78 @@ on: workflow_dispatch
2121# UPLOAD_TO: "v0.0.1"
2222
2323jobs :
24+ Linux :
25+ strategy :
26+ matrix :
27+ node : [18.12.0, 20.9.0]
28+ canvas_tag : [] # e.g. "v2.6.1"
29+ name : ${{ matrix.canvas_tag}}, Node.js ${{ matrix.node }}, Linux
30+ runs-on : ubuntu-latest
31+ container :
32+ image : chearon/canvas-prebuilt:7
33+ env :
34+ CANVAS_VERSION_TO_BUILD : ${{ matrix.canvas_tag }}
35+ steps :
36+ - uses : actions/checkout@v4
37+ with :
38+ ref : ${{ matrix.canvas_tag }}
39+
40+ - uses : actions/setup-node@v4
41+ with :
42+ node-version : ${{ matrix.node }}
43+
44+ - name : Build
45+ run : |
46+ npm install -g node-gyp
47+ npm install --ignore-scripts
48+ . prebuild/Linux/preinstall.sh
49+ cp prebuild/Linux/binding.gyp binding.gyp
50+ node-gyp rebuild -j 2
51+ . prebuild/Linux/bundle.sh
52+ - name : Test binary
53+ run : |
54+ cd /root/harfbuzz-* && make uninstall
55+ cd /root/cairo-* && make uninstall
56+ cd /root/pango-* && make uninstall
57+ cd /root/libpng-* && make uninstall
58+ cd /root/libjpeg-* && make uninstall
59+ cd /root/giflib-* && make uninstall
60+ cd $GITHUB_WORKSPACE && npm test
61+ - name : Make bundle
62+ id : make_bundle
63+ run : . prebuild/tarball.sh
64+
65+ - name : Upload
66+ uses : actions/github-script@0.9.0
67+ with :
68+ script : |
69+ const fs = require("fs");
70+ const assetName = "${{ steps.make_bundle.outputs.asset_name }}";
71+ const tagName = process.env.UPLOAD_TO || process.env.CANVAS_VERSION_TO_BUILD;
72+ const [owner, repo] = process.env.GITHUB_REPOSITORY.split("/");
73+ const releases = await github.repos.listReleases({owner, repo});
74+ const release = releases.data.find(r => r.tag_name === tagName);
75+ if (!release)
76+ throw new Error(`Tag ${tagName} not found. Did you make the GitHub release?`);
77+ const oldAsset = release.assets.find(a => a.name === assetName);
78+ if (oldAsset)
79+ await github.repos.deleteReleaseAsset({owner, repo, asset_id: oldAsset.id});
80+ // (This is equivalent to actions/upload-release-asset. We're
81+ // already in a script, so might as well do it here.)
82+ const r = await github.repos.uploadReleaseAsset({
83+ url: release.upload_url,
84+ headers: {
85+ "content-type": "application/x-gzip",
86+ "content-length": `${fs.statSync(assetName).size}`
87+ },
88+ name: assetName,
89+ data: fs.readFileSync(assetName)
90+ });
2491 macOS :
2592 strategy :
2693 matrix :
2794 node : [18.12.0, 20.9.0]
28- canvas_tag : ["m1-testing" ] # e.g. "v2.6.1"
95+ canvas_tag : [] # e.g. "v2.6.1"
2996 os :
3097 - runner : macos-latest
3198 arch : x64
@@ -92,3 +159,74 @@ jobs:
92159 name: assetName,
93160 data: fs.readFileSync(assetName)
94161 });
162+
163+ Win :
164+ strategy :
165+ matrix :
166+ node : [18.12.0, 20.9.0]
167+ canvas_tag : [] # e.g. "v2.6.1"
168+ name : ${{ matrix.canvas_tag}}, Node.js ${{ matrix.node }}, Windows
169+ runs-on : windows-latest
170+ env :
171+ CANVAS_VERSION_TO_BUILD : ${{ matrix.canvas_tag }}
172+ steps :
173+ # TODO drop when https://github.com/actions/virtual-environments/pull/632 lands
174+ - uses : numworks/setup-msys2@v1
175+ with :
176+ update : true
177+ path-type : inherit
178+
179+ - uses : actions/setup-node@v4
180+ with :
181+ node-version : ${{ matrix.node }}
182+
183+ - uses : actions/checkout@v4
184+ with :
185+ ref : ${{ matrix.canvas_tag }}
186+
187+ - name : Build
188+ run : |
189+ npm install -g node-gyp
190+ npm install --ignore-scripts
191+ msys2do . prebuild/Windows/preinstall.sh
192+ msys2do cp prebuild/Windows/binding.gyp binding.gyp
193+ msys2do node-gyp configure
194+ msys2do node-gyp rebuild -j 2
195+ - name : Bundle
196+ run : msys2do . prebuild/Windows/bundle.sh
197+
198+ - name : Test binary
199+ # By not running in msys2, this doesn't have access to the msys2 libs
200+ run : npm test
201+
202+ - name : Make asset
203+ id : make_bundle
204+ # I can't figure out why this isn't an env var already. It shows up with `env`.
205+ run : msys2do UPLOAD_TO=${{ env.UPLOAD_TO }} CANVAS_VERSION_TO_BUILD=${{ env.CANVAS_VERSION_TO_BUILD}} . prebuild/tarball.sh
206+
207+ - name : Upload
208+ uses : actions/github-script@0.9.0
209+ with :
210+ script : |
211+ const fs = require("fs");
212+ const assetName = "${{ steps.make_bundle.outputs.asset_name }}";
213+ const tagName = process.env.UPLOAD_TO || process.env.CANVAS_VERSION_TO_BUILD;
214+ const [owner, repo] = process.env.GITHUB_REPOSITORY.split("/");
215+ const releases = await github.repos.listReleases({owner, repo});
216+ const release = releases.data.find(r => r.tag_name === tagName);
217+ if (!release)
218+ throw new Error(`Tag ${tagName} not found. Did you make the GitHub release?`);
219+ const oldAsset = release.assets.find(a => a.name === assetName);
220+ if (oldAsset)
221+ await github.repos.deleteReleaseAsset({owner, repo, asset_id: oldAsset.id});
222+ // (This is equivalent to actions/upload-release-asset. We're
223+ // already in a script, so might as well do it here.)
224+ const r = await github.repos.uploadReleaseAsset({
225+ url: release.upload_url,
226+ headers: {
227+ "content-type": "application/x-gzip",
228+ "content-length": `${fs.statSync(assetName).size}`
229+ },
230+ name: assetName,
231+ data: fs.readFileSync(assetName)
232+ });
0 commit comments