-
Notifications
You must be signed in to change notification settings - Fork 3
171 lines (144 loc) · 4.94 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
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-latest, target: "macos", arch: "x64" }
- { os: macos-latest, target: "macos", arch: "arm64" }
node_ver: [ 16, 18, 19, 20, 21]
fail-fast: false
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: 'recursive'
# token: ${{ secrets.ZITI_CI_GH_TOKEN }}
- 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/get-cmake@latest
- name: Run VCPKG
uses: lukka/run-vcpkg@v11
with:
# tag: 2023.10.19
vcpkgGitCommitId: '8eb57355a4ffb410a2e94c07b4dca2dffbee8e50'
- name: gcc version
run: |
gcc --version
- name: cmake version
run: |
cmake --version
- name: ninja version
run: |
ninja --version
- name: node version
run: |
node --version
- name: npm version
run: |
npm --version
- name: Build NodeJS-SDK
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: Hello test
if: matrix.config.arch == 'x64'
run: |
node tests/hello.js
- 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/')