-
Notifications
You must be signed in to change notification settings - Fork 3
206 lines (173 loc) · 6.12 KB
/
build.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
name: Build
on:
release:
types: [ published ]
push:
branches: [ main ]
paths-ignore:
- 'package.json'
- 'CHANGELOG.md'
pull_request:
branches: [ main ]
workflow_dispatch:
inputs:
tags:
required: false
description: 'Misc tags'
# cancel older, redundant runs of same workflow on same branch
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.ref_name }}
cancel-in-progress: true
jobs:
# -------------------------------------------------------------------------------
# Do a clean build, test, and publish
# -------------------------------------------------------------------------------
build:
name: Build for Node-${{ matrix.node_ver }} ${{ matrix.config.target }}/${{ matrix.config.arch }}
runs-on: ${{ matrix.config.os }}
# container: ${{ matrix.config.container }}
env:
BUILD_NUMBER: ${{ github.run_number }}
AWS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
strategy:
matrix:
config:
- { os: windows-latest, target: "windows", arch: "x64" }
- { os: ubuntu-20.04, target: "linux", arch: "x64" }
- { os: ubuntu-20.04, target: "linux", arch: "arm64" }
- { os: macos-13, target: "macos", arch: "x64" }
- { os: macos-14, target: "macos", arch: "arm64" }
node_ver: [ 16, 18, 19, 20, 21, 22, 23 ]
fail-fast: false
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: 'recursive'
# token: ${{ secrets.ZITI_CI_GH_TOKEN }}
- name: macOS tools
if: runner.os == 'macOS'
shell: bash
run: brew install autoconf autoconf-archive automake pkg-config libtool
- name: Setup PkgConfig (Windows)
if: matrix.config.target == 'windows'
run: |
choco install pkgconfiglite
- name: Get crossbuild tools
if: matrix.config.target == 'linux' && matrix.config.arch != 'x64'
run: |
sudo apt update -y
sudo apt install -y crossbuild-essential-${{ matrix.config.arch }}
- name: Node Version
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node_ver }}
- name: Extract branch name
shell: bash
run: echo "branch=${GITHUB_REF#refs/heads/}" >> $GITHUB_OUTPUT
id: extract_branch
- name: Print branch name
shell: bash
run: |
echo "## branch name is: ${{ steps.extract_branch.outputs.branch }}"
- name: Get current date
id: date
run: echo "date=$(date)" >> $GITHUB_OUTPUT
- name: Install CMake/Ninja
uses: lukka/[email protected]
- name: Run VCPKG
uses: lukka/run-vcpkg@v11
# will use baseline from vcpkg.json
with:
# get baseline from vcpkg
vcpkgJsonGlob: './vcpkg.json'
- name: show versions
run: |
echo ===== gcc =====
gcc --version
echo ===== cmake =====
cmake --version
echo "ninja: $(ninja --version)"
echo "node: $(node --version)"
echo "npm: $(npm --version)"
- name: restore dependencies cache
uses: actions/cache/restore@v4
id: cache-restore
with:
key: deps-${{ matrix.config.target }}-${{ matrix.config.arch }}-${{ hashFiles('./vcpkg.json') }}
path: './vcpkg/packages'
- name: Build NodeJS-SDK
id: buildSDK
run: |
cd ${{ runner.workspace }}/${{ github.event.repository.name }}
npm install
npm run build:package -- --target_arch=${{ matrix.config.arch }}
env:
PRESET: ci-${{ matrix.config.target }}-${{ matrix.config.arch }}
TARGET_ARCH: ${{ matrix.config.arch }}
BUILD_DATE: ${{ steps.date.outputs.date }}
- name: show build result
if: always()
run: echo build result ${{ steps.buildSDK.outcome }}
- name: debug build failure
if: always() && steps.buildSDK.outcome == 'failure'
uses: actions/upload-artifact@v3
with:
name: build-logs-${{ matrix.config.target }}-${{ matrix.config.arch }}
path: |
./vcpkg/buildtrees/**/*.log
./build/**/*log
- name: Hello test
if: matrix.config.arch == 'x64'
run: |
node tests/hello.js
- name: save dependencies cache
uses: actions/cache/save@v4
id: cache-save
# save deps even build has failed
if: always()
with:
key: ${{ steps.cache-restore.outputs.cache-primary-key }}
path: './vcpkg/packages'
- name: upload artifacts
uses: actions/upload-artifact@v3
with:
name: ziti_nodejs_${{ matrix.config.target }}_${{ matrix.config.arch }}_nodev${{ matrix.node_ver }}
path: |
./build/Release/ziti_sdk_nodejs.node
if-no-files-found: error
- name: upload release bundle
uses: softprops/[email protected]
if: startsWith(github.ref, 'refs/tags/')
with:
files: |
./build/stage/**/ziti_sdk_nodejs*.tar.gz
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
if: env.AWS_KEY_ID != '' && startsWith(github.ref, 'refs/tags/')
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-1
- name: Publish Binary to S3 (for all OS's, Node versions, and architectures)
run: |
./node_modules/.bin/node-pre-gyp --target_arch=${{ matrix.config.arch }} unpublish publish
sleep 5
if: startsWith(github.ref, 'refs/tags/')
- name: Install Binary
run: |
npm install --fallback-to-build=false
sleep 5
if: startsWith(github.ref, 'refs/tags/')
- name: Fetch Binary info
if: env.AWS_KEY_ID != '' && startsWith(github.ref, 'refs/tags/')
run: |
./node_modules/.bin/node-pre-gyp info
- name: NPM Publish
uses: JS-DevTools/npm-publish@v1
with:
token: ${{ secrets.NPM_TOKEN }}
access: public
if: |
matrix.config.os == 'ubuntu-20.04' && matrix.node_ver == '20' && matrix.config.arch == 'x64' && startsWith(github.ref, 'refs/tags/')