-
Notifications
You must be signed in to change notification settings - Fork 214
303 lines (274 loc) · 9.66 KB
/
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
name: Release
on:
push:
branches:
- main
tags-ignore:
- '**'
paths-ignore:
- '**/*.md'
- LICENSE
- '**/*.gitignore'
- .editorconfig
- docs/**
pull_request:
permissions: write-all
env:
# RELEASE_COMMIT_MSG: 'chore(release): update monorepo packages versions'
DEBUG: napi:*
APP_NAME: graph-napi-utils
MACOSX_DEPLOYMENT_TARGET: '10.13'
jobs:
# napi-utils
build-napi-utils:
strategy:
fail-fast: false
matrix:
settings:
- host: macos-latest-large
target: x86_64-apple-darwin
architecture: x64
build: |
pnpm build --target x86_64-apple-darwin
- host: macos-latest
target: aarch64-apple-darwin
build: |
pnpm build --target aarch64-apple-darwin
strip -x *.node
# - host: windows-latest
# target: i686-pc-windows-msvc
# build: |
# rustup target add i686-pc-windows-msvc
# pnpm build --target i686-pc-windows-msvc
- host: ubuntu-latest
target: x86_64-unknown-linux-gnu
build: pnpm build --target x86_64-unknown-linux-gnu --use-napi-cross
name: stable - ${{ matrix.settings.target }} - node@20
runs-on: ${{ matrix.settings.host }}
defaults:
run:
working-directory: packages/napi-utils
steps:
- uses: actions/checkout@v4
- name: setup pnpm
uses: pnpm/action-setup@v4
with:
version: 9.5.0
- name: Setup node
uses: actions/setup-node@v4
with:
node-version: 20
cache: pnpm
- name: Install
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
targets: ${{ matrix.settings.target }}
- name: Cache cargo
uses: actions/cache@v4
with:
path: |
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
~/.napi-rs
.cargo-cache
target/
key: ${{ matrix.settings.target }}-cargo-${{ matrix.settings.host }}
- uses: goto-bus-stop/setup-zig@v2
if: ${{ contains(matrix.settings.target, 'musl') }}
with:
version: 0.13.0
- name: Setup toolchain
run: ${{ matrix.settings.setup }}
if: ${{ matrix.settings.setup }}
shell: bash
- name: Install dependencies
run: pnpm install
- name: Setup node x86
uses: actions/setup-node@v4
if: matrix.settings.target == 'i686-pc-windows-msvc'
with:
node-version: 20
cache: pnpm
architecture: x86
- name: Install Protobuf on macOS
if: matrix.settings.host == 'macos-latest-large' || matrix.settings.host == 'macos-latest'
run: brew install protobuf
- name: Install Protobuf on Windows
if: matrix.settings.host == 'windows-latest'
run: choco install protoc
- name: Set PROTOC environment variable on Windows
if: matrix.settings.host == 'windows-latest'
run: echo 'PROTOC=C:\Program Files\Google Protobuf\bin\protoc.exe' >> $GITHUB_ENV
- name: Install OpenSSL and Protobuf
if: matrix.settings.host == 'ubuntu-latest'
run: sudo apt-get update && sudo apt-get install -y libssl-dev protobuf-compiler
- name: Cache custom OpenSSL
if: matrix.settings.host == 'ubuntu-latest'
uses: actions/cache@v4
id: openssl-cache
with:
path: /usr/local/openssl-1.1.1o
key: openssl-1.1.1o
- name: Install custom OpenSSL
if:
matrix.settings.host == 'ubuntu-latest' && steps.openssl-cache.outputs.cache-hit != 'true'
run: |
wget https://www.openssl.org/source/openssl-1.1.1o.tar.gz
tar -xf openssl-1.1.1o.tar.gz
cd openssl-1.1.1o
./config --prefix=/usr/local/openssl-1.1.1o no-tests
make
sudo make install
echo 'OPENSSL_DIR=/usr/local/openssl-1.1.1o' >> $GITHUB_ENV
echo 'OPENSSL_INCLUDE_DIR=/usr/local/openssl-1.1.1o/include' >> $GITHUB_ENV
echo 'OPENSSL_LIB_DIR=/usr/local/openssl-1.1.1o/lib' >> $GITHUB_ENV
echo '/usr/local/openssl-1.1.1o/lib' | sudo tee -a /etc/ld.so.conf.d/openssl-1.1.1o.conf
sudo ldconfig
- name: Set PROTOC environment variable on macOS
if: matrix.settings.host == 'macos-latest-large' || matrix.settings.host == 'macos-latest'
run: echo 'export PROTOC=/usr/local/bin/protoc' >> $GITHUB_ENV
- name: Install OpenSSL on macOS
if: matrix.settings.host == 'macos-latest-large' || matrix.settings.host == 'macos-latest'
run: |
brew install openssl
echo 'export OPENSSL_DIR=$(brew --prefix [email protected])' >> $GITHUB_ENV
- name: Install PostgreSQL on macOS
if: matrix.settings.host == 'macos-latest-large' || matrix.settings.host == 'macos-latest'
run: |
brew install postgresql
echo 'export LDFLAGS="-L/usr/local/opt/postgresql/lib"' >> $GITHUB_ENV
echo 'export CPPFLAGS="-I/usr/local/opt/postgresql/include"' >> $GITHUB_ENV
echo 'export PKG_CONFIG_PATH="/usr/local/opt/postgresql/lib/pkgconfig"' >> $GITHUB_ENV
- name: Install OpenSSL on Windows
if: matrix.settings.host == 'windows-latest'
run: choco install openssl
- name: Build
run: ${{ matrix.settings.build }}
shell: bash
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: bindings-${{ matrix.settings.target }}
path: packages/napi-utils/${{ env.APP_NAME }}.*.node
if-no-files-found: error
build-napi-utils-universal-macOS:
name: Build universal macOS binary
needs:
- build-napi-utils
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
- name: setup pnpm
uses: pnpm/action-setup@v4
with:
version: 9.5.0
- name: Setup node
uses: actions/setup-node@v4
with:
node-version: 20
cache: pnpm
- name: Install dependencies
run: pnpm install
working-directory: packages/napi-utils
- name: Download macOS x64 artifact
uses: actions/download-artifact@v4
with:
name: bindings-x86_64-apple-darwin
path: packages/napi-utils/artifacts
- name: Download macOS arm64 artifact
uses: actions/download-artifact@v4
with:
name: bindings-aarch64-apple-darwin
path: packages/napi-utils/artifacts
- name: Combine binaries
working-directory: packages/napi-utils
run: pnpm universal
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: bindings-universal-apple-darwin
path: packages/napi-utils/${{ env.APP_NAME }}.*.node
if-no-files-found: error
publish-napi-utils:
name: publish to npm
runs-on: ubuntu-latest
needs:
- build-napi-utils
- build-napi-utils-universal-macOS
steps:
- uses: actions/checkout@v4
- name: setup pnpm
uses: pnpm/action-setup@v4
with:
version: 9.5.0
- name: Setup node
uses: actions/setup-node@v4
with:
node-version: 20
cache: pnpm
- name: Install dependencies
run: pnpm install
working-directory: packages/napi-utils
- name: Download all artifacts
uses: actions/download-artifact@v3
with:
path: packages/napi-utils/artifacts
- name: Move artifacts
run: pnpm artifacts
working-directory: packages/napi-utils
- name: List packages
run: ls -R ./npm
shell: bash
working-directory: packages/napi-utils
- name: publish lib
working-directory: packages/napi-utils
run: |
npm config set provenance true
echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc
npm publish --access public
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
# CLI
# stable:
# name: Stable
# runs-on: ubuntu-latest
# needs: publish-napi-utils
# steps:
# - name: Checkout
# uses: actions/checkout@v4
# with:
# fetch-depth: 0
# token: ${{ secrets.GITHUB_TOKEN }}
# - name: Setup environment
# uses: the-guild-org/shared-config/setup@main
# with:
# nodeVersion: 20
# packageManager: pnpm
# packageManagerVersion: 9.1.0
# - name: Set variables
# id: vars
# run: |
# echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
# echo "date=$(date +"%B %d, %Y")" >> $GITHUB_OUTPUT
# - name: Build
# if: ${{ startsWith(github.event.head_commit.message, env.RELEASE_COMMIT_MSG) }}
# run: pnpm --filter=@graphprotocol/graph-cli build
# - name: Pack binaries
# if: ${{ startsWith(github.event.head_commit.message, env.RELEASE_COMMIT_MSG) }}
# run: pnpm --filter=@graphprotocol/graph-cli oclif:pack
# - name: Release / pull_request
# uses: dotansimha/[email protected]
# with:
# publish: pnpm release
# version: pnpm changeset version
# commit: ${{ env.RELEASE_COMMIT_MSG }}
# title: Upcoming Release Changes
# createGithubReleases: true
# githubReleaseName: ${{ steps.vars.outputs.date }}
# githubReleaseAssets: packages/cli/dist/*.tar.gz
# env:
# NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}