-
Notifications
You must be signed in to change notification settings - Fork 0
128 lines (122 loc) · 4.78 KB
/
Copy pathnpm.yml
File metadata and controls
128 lines (122 loc) · 4.78 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
name: npm
# Publishes the per-platform binary packages (sqlite-predict-<platform>) and the
# main `sqlite-predict` package, so `npm install sqlite-predict` ships a working
# loadable. Each platform job builds the extension on a native runner, wraps it
# in an os/cpu-gated package that exports loadablePath, and publishes it; the
# main job then pins its optionalDependencies to the same version and publishes.
#
# NOTE: 0.0.1-alpha.1 was published as a name-claim (main package only, no
# binaries). npm versions are immutable, so the first *functional* release must
# use a fresh version (0.0.1-alpha.2+).
on:
push:
tags: ["v*"]
workflow_dispatch:
inputs:
version:
description: "Version to publish (without leading v)"
required: true
permissions:
contents: read
jobs:
platform:
name: ${{ matrix.pkg }}
runs-on: ${{ matrix.runner }}
strategy:
fail-fast: false
matrix:
include:
- { pkg: sqlite-predict-darwin-arm64, runner: macos-14, os: darwin, cpu: arm64, ext: dylib, apt: "", cc: "", macarch: "" }
# darwin-x64 cross-compiles on the arm64 runner: the Intel macos-13
# runners are scarce / being deprecated, and clang targets x86_64 fine.
- { pkg: sqlite-predict-darwin-x64, runner: macos-14, os: darwin, cpu: x64, ext: dylib, apt: "", cc: "", macarch: "x86_64" }
- { pkg: sqlite-predict-linux-x64, runner: ubuntu-latest, os: linux, cpu: x64, ext: so, apt: "", cc: "", macarch: "" }
# linux-arm64 cross-compiles on the x64 runner (the free arm64 runner
# is public-repo-only); the binary is built, not run, on CI.
- { pkg: sqlite-predict-linux-arm64, runner: ubuntu-latest, os: linux, cpu: arm64, ext: so, apt: "gcc-aarch64-linux-gnu", cc: "CC=aarch64-linux-gnu-gcc", macarch: "" }
steps:
- uses: actions/checkout@v7
- uses: actions/setup-node@v7
with:
node-version: "22"
registry-url: "https://registry.npmjs.org"
- name: Resolve version
id: v
shell: bash
run: |
V="${{ github.event.inputs.version }}"
[ -z "$V" ] && V="${GITHUB_REF_NAME#v}"
echo "version=$V" >> "$GITHUB_OUTPUT"
- name: Install cross toolchain
if: matrix.apt != ''
run: sudo apt-get update && sudo apt-get install -y ${{ matrix.apt }}
- name: Build loadable extension
run: |
if [ -n "${{ matrix.macarch }}" ]; then
make loadable CC="clang -arch ${{ matrix.macarch }}"
else
make loadable ${{ matrix.cc }}
fi
- name: Assemble platform package
run: node scripts/npm-pkg.mjs platform ${{ matrix.pkg }} ${{ matrix.os }} ${{ matrix.cpu }} ${{ matrix.ext }} ${{ steps.v.outputs.version }}
- name: Publish
working-directory: npm/${{ matrix.pkg }}
run: npm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
windows:
name: sqlite-predict-windows-x64
runs-on: windows-latest
steps:
- uses: actions/checkout@v7
- uses: msys2/setup-msys2@v2
with:
msystem: MINGW64
update: true
install: >-
mingw-w64-x86_64-gcc make curl unzip
- name: Build loadable DLL
shell: msys2 {0}
run: make loadable
- uses: actions/setup-node@v7
with:
node-version: "22"
registry-url: "https://registry.npmjs.org"
- name: Resolve version
id: v
shell: bash
run: |
V="${{ github.event.inputs.version }}"
[ -z "$V" ] && V="${GITHUB_REF_NAME#v}"
echo "version=$V" >> "$GITHUB_OUTPUT"
- name: Assemble platform package
run: node scripts/npm-pkg.mjs platform sqlite-predict-windows-x64 win32 x64 dll ${{ steps.v.outputs.version }}
- name: Publish
working-directory: npm/sqlite-predict-windows-x64
run: npm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
main:
name: sqlite-predict (main)
needs: [platform, windows]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: actions/setup-node@v7
with:
node-version: "22"
registry-url: "https://registry.npmjs.org"
- name: Resolve version
id: v
shell: bash
run: |
V="${{ github.event.inputs.version }}"
[ -z "$V" ] && V="${GITHUB_REF_NAME#v}"
echo "version=$V" >> "$GITHUB_OUTPUT"
- name: Sync main package version
run: node scripts/npm-pkg.mjs main ${{ steps.v.outputs.version }}
- name: Publish main package
working-directory: bindings/node
run: npm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}