-
-
Notifications
You must be signed in to change notification settings - Fork 333
331 lines (292 loc) · 11.1 KB
/
node-release.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
name: node-release
on:
push:
branches: [main]
workflow_dispatch:
jobs:
release-check:
name: Check if version is published
runs-on: ubuntu-latest
defaults:
run:
shell: bash
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Use Node.js from nvmrc
uses: actions/setup-node@v4
with:
node-version-file: 'platform/node/.nvmrc'
- name: Check if version is published
id: check
working-directory: platform/node
run: |
currentVersion="$( node -e "console.log(require('./package.json').version)" )"
isPublished="$( npm view @maplibre/maplibre-gl-native versions --json | jq -c --arg cv "$currentVersion" 'any(. == $cv)' )"
echo "published=$isPublished" >> "$GITHUB_OUTPUT"
echo "currentVersion: $currentVersion"
echo "isPublished: $isPublished"
outputs:
published: ${{ steps.check.outputs.published }}
publish_binaries:
needs: release-check
if: ${{ needs.release-check.outputs.published == 'false' }}
runs-on: ${{ matrix.runs-on }}
permissions:
contents: write
strategy:
fail-fast: false
matrix:
include:
- runs-on: ubuntu-22.04
arch: x86_64
- runs-on: MapLibre_Native_Ubuntu_22_04_ARM_8_core
arch: arm64
- runs-on: macos-14
arch: arm64
- runs-on: macos-14-large
arch: x86_64
- runs-on: windows-2022
arch: x86_64
continue-on-error: true
env:
BUILDTYPE: "Release"
defaults:
run:
working-directory: ./
shell: bash
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup submodules
shell: bash
run: |
auth_header="$(git config --local --get http.https://github.com/.extraheader)"
git submodule sync --recursive
git -c core.longpaths=true -c "http.extraheader=$auth_header" -c protocol.version=2 submodule update --init --force --recursive || true
- name: Get OS Architecture
if: runner.os == 'MacOS' || runner.os == 'Linux'
run: uname -m
- name: Install dependencies (MacOS)
if: runner.os == 'MacOS'
env:
HOMEBREW_NO_AUTO_UPDATE: 1
HOMEBREW_NO_INSTALL_CLEANUP: 1
run: |
brew list ccache || brew install ccache
brew list ninja || brew install ninja
brew list pkg-config || brew install pkg-config
brew list glfw || brew install glfw
brew list libuv || brew install libuv
- name: Install dependencies (Linux)
if: runner.os == 'Linux'
env:
DEBIAN_FRONTEND: noninteractive
run: |
sudo apt-get update
sudo apt-get install -y \
ccache \
ninja-build \
pkg-config \
xvfb \
libcurl4-openssl-dev \
libglfw3-dev \
libuv1-dev \
g++-12 \
libjpeg-dev \
libpng-dev \
libwebp-dev
/usr/sbin/update-ccache-symlinks
- name: Use Node.js from nvmrc
uses: actions/setup-node@v4
with:
node-version-file: 'platform/node/.nvmrc'
- name: npm ci
working-directory: platform/node
run: npm ci --ignore-scripts
- name: Set up msvc dev cmd (Windows)
if: runner.os == 'Windows'
uses: ilammy/msvc-dev-cmd@v1
# Fixes an issue with the image causing builds to fail - https://github.com/actions/runner-images/issues/8598
- name: Remove Strawberry Perl from PATH (Windows)
if: runner.os == 'Windows'
shell: pwsh
run: |
$env:PATH = $env:PATH -replace "C:\\Strawberry\\c\\bin;", ""
"PATH=$env:PATH" | Out-File -FilePath $env:GITHUB_ENV -Append
- name: Setup cmake
if: ${{contains(runner.name, 'GitHub Actions')}}
uses: jwlawson/actions-setup-cmake@v2
with:
cmake-version: '3.29.2'
- name: cmake version
run: |
cmake --version
- name: Set up ccache (MacOS/Linux)
if: runner.os == 'MacOS' || runner.os == 'Linux'
uses: hendrikmuhs/ccache-action@v1
with:
key: ${{ matrix.runs-on }}-${{ env.BUILDTYPE }}-${{ github.job }}-${{ github.ref }}-${{ github.sha }}-${{ github.head_ref }}
restore-keys: |
${{ matrix.runs-on }}-${{ env.BUILDTYPE }}-${{ github.job }}-${{ github.ref }}-${{ github.sha }}
${{ matrix.runs-on }}-${{ env.BUILDTYPE }}-${{ github.job }}-${{ github.ref }}
${{ matrix.runs-on }}-${{ env.BUILDTYPE }}-${{ github.job }}
- name: Set up ccache (Windows)
if: runner.os == 'Windows'
uses: hendrikmuhs/ccache-action@v1
with:
variant: "sccache"
key: ${{ matrix.runs-on }}-${{ env.BUILDTYPE }}-${{ github.job }}-${{ github.ref }}-${{ github.sha }}-${{ github.head_ref }}
restore-keys: |
${{ matrix.runs-on }}-${{ env.BUILDTYPE }}-${{ github.job }}-${{ github.ref }}-${{ github.sha }}
${{ matrix.runs-on }}-${{ env.BUILDTYPE }}-${{ github.job }}-${{ github.ref }}
${{ matrix.runs-on }}-${{ env.BUILDTYPE }}-${{ github.job }}
- name: Cache cmake-node-module deps
uses: actions/cache@v4
with:
# downloaded with platform/node/cmake/module.cmake
path: build/headers
key: ${{ runner.os }}-${{ runner.arch }}-cmake-node-module-deps
- name: Configure maplibre-native (MacOS)
if: runner.os == 'MacOS'
run: |
cmake . -B build \
-G Ninja \
-DCMAKE_BUILD_TYPE=${{ env.BUILDTYPE }} \
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
-DMLN_WITH_NODE=ON \
-DMLN_WITH_OPENGL=OFF \
-DMLN_WITH_METAL=ON \
-DMLN_LEGACY_RENDERER=OFF \
-DMLN_DRAWABLE_RENDERER=ON \
-DMLN_WITH_WERROR=OFF
- name: Configure maplibre-native (Linux)
if: runner.os == 'Linux'
run: |
cmake . -B build \
-G Ninja \
-DCMAKE_BUILD_TYPE=${{ env.BUILDTYPE }} \
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
-DCMAKE_C_COMPILER=gcc-12 \
-DCMAKE_CXX_COMPILER=g++-12 \
-DMLN_WITH_NODE=ON
- name: "Create directory '${{ github.workspace }}/platform/windows/vendor/vcpkg/bincache' (Windows)"
if: runner.os == 'Windows'
run: mkdir -p ${{ github.workspace }}/platform/windows/vendor/vcpkg/bincache
shell: bash
- name: Restore vcpkg cache (Windows)
if: runner.os == 'Windows'
uses: actions/cache@v4
with:
path: |
${{ github.workspace }}/platform/windows/vendor/vcpkg
!${{ github.workspace }}/platform/windows/vendor/vcpkg/buildtrees
!${{ github.workspace }}/platform/windows/vendor/vcpkg/packages
!${{ github.workspace }}/platform/windows/vendor/vcpkg/downloads
!${{ github.workspace }}/platform/windows/vendor/vcpkg/installed
key: |
${{ matrix.runs-on }}-${{ env.BUILDTYPE }}-${{ github.job }}-${{ hashFiles( '.git/modules/platform/windows/vendor/vcpkg/HEAD' ) }}-${{ hashFiles( 'platform/windows/Get-VendorPackages.ps1' ) }}
- name: Configure maplibre-native (Windows)
if: runner.os == 'Windows'
run: |
cmake . -B build \
-G Ninja \
-DCMAKE_BUILD_TYPE=${{ env.BUILDTYPE }} \
-DCMAKE_CXX_COMPILER_LAUNCHER=sccache \
-DMLN_WITH_NODE=ON
- name: Build maplibre-native (MacOS/Linux)
if: runner.os == 'MacOS' || runner.os == 'Linux'
run: |
cmake --build build -j "$(nproc 2>/dev/null || sysctl -n hw.ncpu 2>/dev/null)"
- name: Build maplibre-native (Windows)
if: runner.os == 'Windows'
run: |
cmake --build build
- name: Publish X64 Release to Github
if: matrix.arch == 'x86_64'
working-directory: platform/node
env:
PUBLISH: true
BUILDTYPE: RelWithDebInfo
NODE_PRE_GYP_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
./scripts/publish.sh
- name: Publish ARM Release to Github
if: matrix.arch == 'arm64'
working-directory: platform/node
env:
PUBLISH: true
BUILDTYPE: RelWithDebInfo
NODE_PRE_GYP_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
./scripts/publish.sh --target_arch=arm64
publish_npm:
runs-on: ubuntu-latest
needs: publish_binaries
permissions:
contents: write
defaults:
run:
shell: bash
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Use Node.js from nvmrc
uses: actions/setup-node@v4
with:
node-version-file: 'platform/node/.nvmrc'
- name: Get version
id: package-version
uses: martinbeentjes/[email protected]
with:
path: platform/node
- name: npm ci
working-directory: platform/node
run: npm ci --ignore-scripts
- name: Prepare release
id: prepare_release
working-directory: platform/node
run: |
RELEASE_TYPE="$(node -e "console.log(require('semver').prerelease('${{ steps.package-version.outputs.current-version }}') ? 'prerelease' : 'regular')")"
if [[ $RELEASE_TYPE == 'regular' ]]; then
echo "prerelease=false" >> "$GITHUB_OUTPUT"
else
echo "prerelease=true" >> "$GITHUB_OUTPUT"
fi
- name: Extract changelog for version
working-directory: platform/node
run: |
awk '/^##/ { p = 0 }; p == 1 { print }; $0 == "## ${{ steps.package-version.outputs.current-version }}" { p = 1 };' CHANGELOG.md > changelog_for_version.md
cat changelog_for_version.md
- name: Update Release Notes
id: update_release_notes
uses: ncipollo/release-action@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag: node-v${{ steps.package-version.outputs.current-version }}
name: node-v${{ steps.package-version.outputs.current-version }}
bodyFile: platform/node/changelog_for_version.md
allowUpdates: true
draft: false
prerelease: ${{ steps.prepare_release.outputs.prerelease }}
- name: Publish to NPM (release)
if: ${{ steps.prepare_release.outputs.prerelease == 'false' }}
working-directory: platform/node
run: |
npm config set //registry.npmjs.org/:_authToken "${NPM_TOKEN}"
npm publish --access public
env:
NPM_TOKEN: ${{ secrets.NPM_ORG_TOKEN }}
- name: Publish to NPM (prerelease)
if: ${{ steps.prepare_release.outputs.prerelease == 'true' }}
working-directory: platform/node
run: |
npm config set //registry.npmjs.org/:_authToken "${NPM_TOKEN}"
npm publish --tag next --access public
env:
NPM_TOKEN: ${{ secrets.NPM_ORG_TOKEN }}