Skip to content

Commit 4fba61c

Browse files
committed
build: add PNG-enabled prebuilds.
1 parent 128543d commit 4fba61c

10 files changed

Lines changed: 1759 additions & 4524 deletions

File tree

.github/workflows/prebuilds.yml

Lines changed: 234 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,234 @@
1+
name: Prebuilds
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*"
7+
workflow_dispatch:
8+
9+
env:
10+
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: "true"
11+
LIBPNG_VERSION: "1.6.58"
12+
LIBPNG_URL: https://downloads.sourceforge.net/project/libpng/libpng16/1.6.58/libpng-1.6.58.tar.xz
13+
LIBPNG_SHA256: 28eb403f51f0f7405249132cecfe82ea5c0ef97f1b32c5a65828814ae0d34775
14+
15+
permissions:
16+
contents: read
17+
18+
jobs:
19+
build-linux:
20+
name: ${{ matrix.name }}
21+
runs-on: ${{ matrix.os }}
22+
container: node:24-bullseye
23+
timeout-minutes: 30
24+
env:
25+
ROBOTJS_ENABLE_PNG: "1"
26+
strategy:
27+
fail-fast: false
28+
matrix:
29+
include:
30+
- name: Linux x64
31+
artifact: linux-x64
32+
os: ubuntu-24.04
33+
architecture: x64
34+
- name: Linux arm64
35+
artifact: linux-arm64
36+
os: ubuntu-24.04-arm
37+
architecture: arm64
38+
39+
steps:
40+
- name: Check out repository
41+
uses: actions/checkout@v6
42+
43+
- name: Install build dependencies
44+
run: |
45+
apt-get update
46+
apt-get install -y curl xz-utils pkg-config python3 make g++ zlib1g-dev libx11-dev libxtst-dev
47+
48+
- name: Build static libpng
49+
shell: bash
50+
run: |
51+
archive="$RUNNER_TEMP/libpng-$LIBPNG_VERSION.tar.xz"
52+
prefix="$RUNNER_TEMP/libpng"
53+
curl --fail --location --retry 3 "$LIBPNG_URL" --output "$archive"
54+
echo "$LIBPNG_SHA256 $archive" | sha256sum --check -
55+
tar -xf "$archive" -C "$RUNNER_TEMP"
56+
cd "$RUNNER_TEMP/libpng-$LIBPNG_VERSION"
57+
CFLAGS="-O2 -fPIC" ./configure --prefix="$prefix" --disable-shared --enable-static
58+
make -j"$(nproc)"
59+
make install
60+
echo "PKG_CONFIG_PATH=$prefix/lib/pkgconfig" >> "$GITHUB_ENV"
61+
echo "ROBOTJS_PNG_STATIC=1" >> "$GITHUB_ENV"
62+
63+
- name: Install package dependencies
64+
run: npm ci --ignore-scripts
65+
66+
- name: Build glibc N-API prebuild
67+
run: npm run build:prebuild -- --tag-libc
68+
69+
- name: Test prebuild on Node.js 24
70+
env:
71+
PREBUILDS_ONLY: "1"
72+
run: npx jasmine test/image.js
73+
74+
- name: Set up Node.js 25
75+
uses: actions/setup-node@v6
76+
with:
77+
node-version: "25"
78+
architecture: ${{ matrix.architecture }}
79+
80+
- name: Load prebuild on Node.js 25
81+
env:
82+
PREBUILDS_ONLY: "1"
83+
run: node -e "const robot = require('.'); if (!robot.image.supportsPNG) throw new Error('PNG support is disabled')"
84+
85+
- name: Upload prebuild
86+
uses: actions/upload-artifact@v6
87+
with:
88+
name: ${{ matrix.artifact }}
89+
path: prebuilds/${{ matrix.artifact }}/
90+
if-no-files-found: error
91+
retention-days: 1
92+
93+
build-native:
94+
name: ${{ matrix.name }}
95+
runs-on: ${{ matrix.os }}
96+
timeout-minutes: 30
97+
env:
98+
ROBOTJS_ENABLE_PNG: "1"
99+
strategy:
100+
fail-fast: false
101+
matrix:
102+
include:
103+
- name: macOS x64
104+
artifact: darwin-x64
105+
os: macos-15-intel
106+
architecture: x64
107+
deployment-target: "10.15"
108+
- name: macOS arm64
109+
artifact: darwin-arm64
110+
os: macos-15
111+
architecture: arm64
112+
deployment-target: "11.0"
113+
- name: Windows x64
114+
artifact: win32-x64
115+
os: windows-2022
116+
architecture: x64
117+
- name: Windows arm64
118+
artifact: win32-arm64
119+
os: windows-11-arm
120+
architecture: arm64
121+
122+
steps:
123+
- name: Check out repository
124+
uses: actions/checkout@v6
125+
126+
- name: Set up Node.js
127+
uses: actions/setup-node@v6
128+
with:
129+
node-version: "24"
130+
architecture: ${{ matrix.architecture }}
131+
cache: npm
132+
133+
- name: Set up Python
134+
uses: actions/setup-python@v6
135+
with:
136+
python-version: "3.x"
137+
138+
- name: Install macOS build dependencies
139+
if: runner.os == 'macOS'
140+
run: brew install pkg-config
141+
142+
- name: Build static libpng on macOS
143+
if: runner.os == 'macOS'
144+
shell: bash
145+
run: |
146+
archive="$RUNNER_TEMP/libpng-$LIBPNG_VERSION.tar.xz"
147+
prefix="$RUNNER_TEMP/libpng"
148+
curl --fail --location --retry 3 "$LIBPNG_URL" --output "$archive"
149+
echo "$LIBPNG_SHA256 $archive" | shasum -a 256 --check -
150+
tar -xf "$archive" -C "$RUNNER_TEMP"
151+
cd "$RUNNER_TEMP/libpng-$LIBPNG_VERSION"
152+
export MACOSX_DEPLOYMENT_TARGET="${{ matrix.deployment-target }}"
153+
./configure --prefix="$prefix" --disable-shared --enable-static
154+
make -j"$(sysctl -n hw.ncpu)"
155+
make install
156+
echo "PKG_CONFIG_PATH=$prefix/lib/pkgconfig" >> "$GITHUB_ENV"
157+
echo "ROBOTJS_PNG_STATIC=1" >> "$GITHUB_ENV"
158+
159+
- name: Install package dependencies
160+
run: npm ci --ignore-scripts
161+
162+
- name: Build N-API prebuild
163+
run: npm run build:prebuild
164+
165+
- name: Test prebuild on Node.js 24
166+
env:
167+
PREBUILDS_ONLY: "1"
168+
run: npx jasmine test/image.js
169+
170+
- name: Set up Node.js 25
171+
uses: actions/setup-node@v6
172+
with:
173+
node-version: "25"
174+
architecture: ${{ matrix.architecture }}
175+
176+
- name: Load prebuild on Node.js 25
177+
env:
178+
PREBUILDS_ONLY: "1"
179+
run: node -e "const robot = require('.'); if (!robot.image.supportsPNG) throw new Error('PNG support is disabled')"
180+
181+
- name: Upload prebuild
182+
uses: actions/upload-artifact@v6
183+
with:
184+
name: ${{ matrix.artifact }}
185+
path: prebuilds/${{ matrix.artifact }}/
186+
if-no-files-found: error
187+
retention-days: 1
188+
189+
package:
190+
name: Package
191+
needs: [build-linux, build-native]
192+
runs-on: ubuntu-24.04
193+
timeout-minutes: 15
194+
195+
steps:
196+
- name: Check out repository
197+
uses: actions/checkout@v6
198+
199+
- name: Set up Node.js
200+
uses: actions/setup-node@v6
201+
with:
202+
node-version: "24"
203+
cache: npm
204+
205+
- name: Install package dependencies
206+
run: npm ci --ignore-scripts
207+
208+
- name: Download prebuilds
209+
uses: actions/download-artifact@v7
210+
with:
211+
path: prebuilds
212+
213+
- name: Verify release tag
214+
if: startsWith(github.ref, 'refs/tags/v')
215+
run: node -e "const pkg = require('./package.json'); if ('v' + pkg.version !== process.env.GITHUB_REF_NAME) throw new Error('Tag does not match package version')"
216+
217+
- name: Pack npm artifact
218+
run: npm pack
219+
220+
- name: Verify install without lifecycle scripts
221+
shell: bash
222+
run: |
223+
mkdir package-smoke
224+
cd package-smoke
225+
npm init --yes
226+
npm install --ignore-scripts ../robotjs-*.tgz
227+
PREBUILDS_ONLY=1 node -e "const robot = require('robotjs'); if (!robot.image.supportsPNG) throw new Error('PNG support is disabled')"
228+
229+
- name: Upload npm artifact
230+
uses: actions/upload-artifact@v6
231+
with:
232+
name: npm-package
233+
path: robotjs-*.tgz
234+
if-no-files-found: error

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
## 0.9.1 (2026-08-01)
2+
3+
* feat: Enable PNG image I/O on Windows.
4+
* build: Package PNG-enabled Node-API prebuilds with GitHub Actions.
5+
6+
17
## 0.9.0 (2026-08-01)
28

39
* feat: Add macOS Accessibility and Screen Recording permission APIs.

LICENSES/libpng.txt

Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
COPYRIGHT NOTICE, DISCLAIMER, and LICENSE
2+
=========================================
3+
4+
PNG Reference Library License version 2
5+
---------------------------------------
6+
7+
* Copyright (c) 1995-2026 The PNG Reference Library Authors.
8+
* Copyright (c) 2018-2026 Cosmin Truta.
9+
* Copyright (c) 2000-2002, 2004, 2006-2018 Glenn Randers-Pehrson.
10+
* Copyright (c) 1996-1997 Andreas Dilger.
11+
* Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
12+
13+
The software is supplied "as is", without warranty of any kind,
14+
express or implied, including, without limitation, the warranties
15+
of merchantability, fitness for a particular purpose, title, and
16+
non-infringement. In no event shall the Copyright owners, or
17+
anyone distributing the software, be liable for any damages or
18+
other liability, whether in contract, tort or otherwise, arising
19+
from, out of, or in connection with the software, or the use or
20+
other dealings in the software, even if advised of the possibility
21+
of such damage.
22+
23+
Permission is hereby granted to use, copy, modify, and distribute
24+
this software, or portions hereof, for any purpose, without fee,
25+
subject to the following restrictions:
26+
27+
1. The origin of this software must not be misrepresented; you
28+
must not claim that you wrote the original software. If you
29+
use this software in a product, an acknowledgment in the product
30+
documentation would be appreciated, but is not required.
31+
32+
2. Altered source versions must be plainly marked as such, and must
33+
not be misrepresented as being the original software.
34+
35+
3. This Copyright notice may not be removed or altered from any
36+
source or altered source distribution.
37+
38+
39+
PNG Reference Library License version 1 (for libpng 0.5 through 1.6.35)
40+
-----------------------------------------------------------------------
41+
42+
libpng versions 1.0.7, July 1, 2000, through 1.6.35, July 15, 2018 are
43+
Copyright (c) 2000-2002, 2004, 2006-2018 Glenn Randers-Pehrson, are
44+
derived from libpng-1.0.6, and are distributed according to the same
45+
disclaimer and license as libpng-1.0.6 with the following individuals
46+
added to the list of Contributing Authors:
47+
48+
Simon-Pierre Cadieux
49+
Eric S. Raymond
50+
Mans Rullgard
51+
Cosmin Truta
52+
Gilles Vollant
53+
James Yu
54+
Mandar Sahastrabuddhe
55+
Google Inc.
56+
Vadim Barkov
57+
58+
and with the following additions to the disclaimer:
59+
60+
There is no warranty against interference with your enjoyment of
61+
the library or against infringement. There is no warranty that our
62+
efforts or the library will fulfill any of your particular purposes
63+
or needs. This library is provided with all faults, and the entire
64+
risk of satisfactory quality, performance, accuracy, and effort is
65+
with the user.
66+
67+
Some files in the "contrib" directory and some configure-generated
68+
files that are distributed with libpng have other copyright owners, and
69+
are released under other open source licenses.
70+
71+
libpng versions 0.97, January 1998, through 1.0.6, March 20, 2000, are
72+
Copyright (c) 1998-2000 Glenn Randers-Pehrson, are derived from
73+
libpng-0.96, and are distributed according to the same disclaimer and
74+
license as libpng-0.96, with the following individuals added to the
75+
list of Contributing Authors:
76+
77+
Tom Lane
78+
Glenn Randers-Pehrson
79+
Willem van Schaik
80+
81+
libpng versions 0.89, June 1996, through 0.96, May 1997, are
82+
Copyright (c) 1996-1997 Andreas Dilger, are derived from libpng-0.88,
83+
and are distributed according to the same disclaimer and license as
84+
libpng-0.88, with the following individuals added to the list of
85+
Contributing Authors:
86+
87+
John Bowler
88+
Kevin Bracey
89+
Sam Bushell
90+
Magnus Holmgren
91+
Greg Roelofs
92+
Tom Tanner
93+
94+
Some files in the "scripts" directory have other copyright owners,
95+
but are released under this license.
96+
97+
libpng versions 0.5, May 1995, through 0.88, January 1996, are
98+
Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
99+
100+
For the purposes of this copyright and license, "Contributing Authors"
101+
is defined as the following set of individuals:
102+
103+
Andreas Dilger
104+
Dave Martindale
105+
Guy Eric Schalnat
106+
Paul Schmidt
107+
Tim Wegner
108+
109+
The PNG Reference Library is supplied "AS IS". The Contributing
110+
Authors and Group 42, Inc. disclaim all warranties, expressed or
111+
implied, including, without limitation, the warranties of
112+
merchantability and of fitness for any purpose. The Contributing
113+
Authors and Group 42, Inc. assume no liability for direct, indirect,
114+
incidental, special, exemplary, or consequential damages, which may
115+
result from the use of the PNG Reference Library, even if advised of
116+
the possibility of such damage.
117+
118+
Permission is hereby granted to use, copy, modify, and distribute this
119+
source code, or portions hereof, for any purpose, without fee, subject
120+
to the following restrictions:
121+
122+
1. The origin of this source code must not be misrepresented.
123+
124+
2. Altered versions must be plainly marked as such and must not
125+
be misrepresented as being the original source.
126+
127+
3. This Copyright notice may not be removed or altered from any
128+
source or altered source distribution.
129+
130+
The Contributing Authors and Group 42, Inc. specifically permit,
131+
without fee, and encourage the use of this source code as a component
132+
to supporting the PNG file format in commercial products. If you use
133+
this source code in a product, acknowledgment is not required but would
134+
be appreciated.

0 commit comments

Comments
 (0)