-
Notifications
You must be signed in to change notification settings - Fork 2
175 lines (149 loc) · 5.13 KB
/
prebuild.yml
File metadata and controls
175 lines (149 loc) · 5.13 KB
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
name: Build prebuilds
on:
workflow_dispatch: {}
jobs:
build-linux:
name: Build Linux prebuilds
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: '18'
- name: Install system deps
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends build-essential curl git autoconf automake libtool pkg-config python3
- name: Build libjpeg
run: |
curl -fsSL http://www.ijg.org/files/jpegsrc.v9d.tar.gz -o jpegsrc.v9d.tar.gz
tar xzf jpegsrc.v9d.tar.gz
cd jpeg-9d
./configure --with-pic --prefix=/usr/local
make -j"$(nproc)"
sudo make install
cd ..
- name: Build LibRaw
run: |
curl -fsSL https://www.libraw.org/data/LibRaw-0.21.2.tar.gz -o LibRaw-0.21.2.tar.gz
tar xzf LibRaw-0.21.2.tar.gz
cd LibRaw-0.21.2
./configure --with-pic --disable-openmp --prefix=/usr/local
make -j"$(nproc)"
sudo make install
cd ..
- name: Install npm deps
run: npm ci
- name: Build project
run: npm run build
- name: Run prebuildify
run: npx prebuildify --napi
- name: Upload Linux prebuilds
uses: actions/upload-artifact@v4
with:
name: prebuilds-linux
path: prebuilds
build-macos:
name: Build macOS prebuilds
runs-on: macos-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: '18'
- name: Install Homebrew deps
run: |
brew update
# Install bottles for jpeg and libraw to avoid building from source on macOS runners
brew install jpeg libraw pkg-config python3
- name: Export Homebrew environment
run: |
BREW_PREFIX=$(brew --prefix)
echo "PKG_CONFIG_PATH=${BREW_PREFIX}/lib/pkgconfig:$PKG_CONFIG_PATH" >> $GITHUB_ENV
echo "PATH=${BREW_PREFIX}/bin:$PATH" >> $GITHUB_ENV
echo "LDFLAGS=-L${BREW_PREFIX}/lib $LDFLAGS" >> $GITHUB_ENV
echo "CPPFLAGS=-I${BREW_PREFIX}/include $CPPFLAGS" >> $GITHUB_ENV
- name: Install npm deps
run: npm ci
- name: Build project
run: npm run build
- name: Run prebuildify
run: npx prebuildify --napi
- name: Upload macOS prebuilds
uses: actions/upload-artifact@v4
with:
name: prebuilds-macos
path: prebuilds
publish-release:
name: Create draft release with prebuilds
runs-on: ubuntu-latest
needs: [build-linux, build-macos]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Read package version
id: version
run: |
echo "VERSION=$(node -p \"require('./package.json').version\")" >> $GITHUB_OUTPUT
- name: Download Linux prebuilds artifact
uses: actions/download-artifact@v4
with:
name: prebuilds-linux
path: artifacts/linux
- name: Download macOS prebuilds artifact
uses: actions/download-artifact@v4
with:
name: prebuilds-macos
path: artifacts/macos
- name: Prepare release assets
run: |
mkdir -p release-assets
VERSION=${{ steps.version.outputs.VERSION }}
if [ -d artifacts/linux ]; then
cd artifacts/linux || exit 0
zip -r ../../release-assets/prebuilds-linux-v${VERSION}.zip . || true
cd ../..
fi
if [ -d artifacts/macos ]; then
cd artifacts/macos || exit 0
zip -r ../../release-assets/prebuilds-macos-v${VERSION}.zip . || true
cd ../..
fi
- name: Create draft release
id: create_release
uses: actions/create-release@v1
with:
tag_name: v${{ steps.version.outputs.VERSION }}
release_name: "prebuild-v${{ steps.version.outputs.VERSION }}"
body: |
Automated prebuilds for version ${{ steps.version.outputs.VERSION }}.
- Commit: ${{ github.sha }}
- Workflow: ${{ github.workflow }}
draft: true
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload prebuild assets to draft release
shell: bash
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
set -euo pipefail
UPLOAD_URL="${{ steps.create_release.outputs.upload_url }}"
if [ -z "$UPLOAD_URL" ]; then
echo "No upload_url from create_release step"
exit 1
fi
for f in release-assets/*; do
[ -f "$f" ] || continue
fname=$(basename "$f")
echo "Uploading $fname to $UPLOAD_URL"
curl -sS -X POST \
-H "Authorization: token ${GITHUB_TOKEN}" \
-H "Content-Type: application/zip" \
--data-binary @"$f" "${UPLOAD_URL}?name=$fname"
done