-
Notifications
You must be signed in to change notification settings - Fork 44
169 lines (162 loc) · 5 KB
/
CI.yml
File metadata and controls
169 lines (162 loc) · 5 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
name: CI
on:
push:
branches:
- v0.5
tags:
- 'v*'
permissions:
contents: write
id-token: write
jobs:
test:
name: Integration tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup node
uses: actions/setup-node@v4
with:
node-version: 20
cache: npm
- run: npm ci
- run: npm run build
- run: cd integration-tests && npm ci && npm run test
build:
strategy:
fail-fast: false
matrix:
settings:
- host: macos-14-xlarge
target: aarch64-apple-darwin
- host: macos-14-large
target: x86_64-apple-darwin
- host: windows-latest
target: x86_64-pc-windows-msvc
- host: ubuntu-latest
target: x86_64-unknown-linux-gnu
use-cross: true
- host: ubuntu-latest
target: x86_64-unknown-linux-musl
use-cross: true
- host: ubuntu-latest
target: aarch64-unknown-linux-gnu
use-cross: true
- host: ubuntu-latest
target: aarch64-unknown-linux-musl
use-cross: true
- host: ubuntu-latest
target: arm-unknown-linux-gnueabihf
use-cross: true
- host: ubuntu-latest
target: arm-unknown-linux-musleabihf
use-cross: true
name: Build - ${{ matrix.settings.target }}
runs-on: ${{ matrix.settings.host }}
steps:
- uses: actions/checkout@v4
- name: Setup node
uses: actions/setup-node@v4
with:
node-version: 20
cache: npm
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.settings.target }}
- name: Cache cargo
uses: actions/cache@v4
with:
path: |
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
.cargo-cache
target/
key: ${{ matrix.settings.target }}-cargo-${{ matrix.settings.host }}
- name: Setup cmake
if: ${{ matrix.settings.use-cross }}
uses: jwlawson/actions-setup-cmake@v1.14
with:
cmake-version: '3.18.x'
- name: Install cross
if: ${{ matrix.settings.use-cross }}
run: cargo install cross --locked
- name: Add msbuild to PATH
if: ${{ matrix.settings.target == 'x86_64-pc-windows-msvc' }}
uses: microsoft/setup-msbuild@v2
- name: Install dependencies
run: npm ci
- name: Build (native)
if: ${{ !matrix.settings.use-cross }}
run: cargo build --message-format=json --release --target ${{ matrix.settings.target }} | npx neon dist --name libsql-js
shell: bash
- name: Build (cross)
if: ${{ matrix.settings.use-cross }}
run: cross build --message-format=json --release --target ${{ matrix.settings.target }} | npx neon dist --name libsql-js -m /target
shell: bash
- name: Pack platform package
run: npx neon pack-build -t ${{ matrix.settings.target }} -o dist
shell: bash
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: bindings-${{ matrix.settings.target }}
path: dist/*.tgz
if-no-files-found: error
publish:
name: Publish
runs-on: ubuntu-latest
needs: [build]
permissions:
contents: write
id-token: write
steps:
- uses: actions/checkout@v4
- name: Setup node
uses: actions/setup-node@v4
with:
node-version: 20
cache: npm
registry-url: 'https://registry.npmjs.org'
- name: Update npm
run: npm install -g npm@11
- name: Install dependencies
run: npm ci
- name: Compile TypeScript
run: npx tsc
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: List packages
run: ls -R artifacts/
shell: bash
- name: Publish
run: |
TAG_ARGS=""
if git log -1 --pretty=%B | grep "^[0-9]\+\.[0-9]\+\.[0-9]\+$";
then
echo "Publishing stable release"
elif git log -1 --pretty=%B | grep "^[0-9]\+\.[0-9]\+\.[0-9]\+";
then
echo "Publishing pre-release"
TAG_ARGS="--tag next"
else
echo "Not a release, skipping publish"
exit 0
fi
# Publish platform packages first
for dir in artifacts/bindings-*; do
for tgz in "$dir"/*.tgz; do
if [ -f "$tgz" ]; then
echo "Publishing $tgz..."
npm publish "$tgz" --access public --provenance $TAG_ARGS
fi
done
done
# Publish main package
npm publish --access public --provenance $TAG_ARGS
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}