-
Notifications
You must be signed in to change notification settings - Fork 1
252 lines (246 loc) · 7.77 KB
/
xtracfg.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
name: xtracfg
on: [push]
jobs:
build_libraries:
runs-on: ${{ matrix.os.runner }}
strategy:
matrix:
os:
- runner: ubuntu-latest
type: linux
platform: linux-amd64
#- runner: buildjet-2vcpu-ubuntu-2204-arm
# type: linux
# platform: linux-arm64
- runner: macos-latest
type: macos
platform: darwin-arm64
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
- uses: actions/setup-go@v5
with:
go-version: "1.23.2"
cache-dependency-path: xtracfg/go.sum
- uses: graalvm/setup-graalvm@v1
with:
java-version: "21"
distribution: "graalvm"
native-image-job-reports: true
cache: gradle
#cache-dependency-path: |
# xtracfg/*.gradle*
# xtracfg/**/gradle-wrapper.properties
- name: zlib
if: ${{ matrix.os.platform == 'linux-amd64' }}
working-directory: /tmp
env:
ZLIB_VERSION: 1.2.11
run: |
wget https://zlib.net/fossils/zlib-${ZLIB_VERSION}.tar.gz
tar xzvf zlib-${ZLIB_VERSION}.tar.gz
mv zlib-${ZLIB_VERSION} zlib
cd zlib
CFLAGS="-fPIC" ./configure --static
make
- name: java
working-directory: ./libxtracfg/java
run: |
./gradlew nativeCompile -PLIB=true
- name: log1
run: |
ls -l ./libxtracfg/c/build
- name: c
working-directory: ./libxtracfg/c
run: |
./build.sh
./test.sh
- name: log2
run: |
ls -l ./libxtracfg/c/build
- name: js
working-directory: ./libxtracfg/js/xtracfg-native-binding
run: |
npm ci
npm run prebuildify
npm run test
- name: log3
run: |
ls -lR ./libxtracfg/js/xtracfg-native-binding/prebuilds
# TODO: run tests for java, c, go
- uses: actions/upload-artifact@v4
with:
name: libxtracfg-c-${{ matrix.os.platform }}
path: ./libxtracfg/c/build/libxtracfg.a
retention-days: 1
- uses: actions/upload-artifact@v4
with:
name: libxtracfg-c-hash-${{ matrix.os.platform }}
path: ./libxtracfg/go/xtracfg/libxtracfg.sha1sum
retention-days: 1
- uses: actions/upload-artifact@v4
with:
name: libxtracfg-js-${{ matrix.os.platform }}
path: ./libxtracfg/js/xtracfg-native-binding/prebuilds
retention-days: 1
build_binaries:
runs-on: ${{ matrix.os.runner }}
needs: build_libraries
strategy:
matrix:
os:
- runner: ubuntu-latest
type: linux
platform: linux-amd64
#- runner: buildjet-2vcpu-ubuntu-2204-arm
# type: linux
# platform: linux-arm64
- runner: macos-latest
type: macos
platform: darwin-arm64
defaults:
run:
working-directory: ./xtracfg
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: "1.23.2"
cache-dependency-path: xtracfg/go.sum
- uses: actions/download-artifact@v4
with:
name: libxtracfg-c-${{ matrix.os.platform }}
path: ./libxtracfg/c/build/
- uses: actions/download-artifact@v4
with:
name: libxtracfg-c-hash-${{ matrix.os.platform }}
path: ./libxtracfg/go/xtracfg/
- uses: bhowell2/[email protected]
id: short-sha
with:
value: ${{ github.sha }}
length_from_start: 7
- name: build
env:
CMD_GIT_BRANCH: github.com/interactive-instruments/xtraplatform-cli/xtracfg/cmd.gitBranch=${{ github.ref_name }}
CMD_GIT_SHA: github.com/interactive-instruments/xtraplatform-cli/xtracfg/cmd.gitSha=${{ steps.short-sha.outputs.substring }}
CMD_GIT_TAG: github.com/interactive-instruments/xtraplatform-cli/xtracfg/cmd.gitTag=${{ github.ref_type == 'tag' && github.ref_name || '' }}
EXT_LDFLAGS: ${{ matrix.os.type == 'macos' && '-framework CoreServices -framework Foundation' || '-z noexecstack' }}
run: |
go build -o build/xtracfg -ldflags="-s -w -X ${CMD_GIT_TAG} -X ${CMD_GIT_SHA} -X ${CMD_GIT_BRANCH} '-extldflags=${EXT_LDFLAGS}'"
- name: log1
run: |
ls -lR ./build
- name: test
run: |
./build/xtracfg --version
./build/xtracfg info
- uses: actions/upload-artifact@v4
with:
name: xtracfg-${{ matrix.os.platform }}
path: ./xtracfg/build/xtracfg
retention-days: 1
- uses: actions/upload-artifact@v4
if: ${{ matrix.os.platform == 'linux-amd64' }}
with:
name: common
path: ./xtracfg/Dockerfile
retention-days: 1
publish_npm:
runs-on: ubuntu-latest
needs: build_libraries
defaults:
run:
working-directory: ./libxtracfg/js
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # need full history for snapshot version
- uses: actions/download-artifact@v4
with:
pattern: "libxtracfg-js-*"
path: ./libxtracfg/js/xtracfg-native-binding/prebuilds
merge-multiple: true
- name: log1
run: |
ls -lR ./xtracfg-native-binding/prebuilds
- name: publish
env:
DIST_TAG: ${{ github.ref_name == 'main' && 'next' || github.ref_name }}
NPM_TOKEN: ${{ secrets.npm_rw_token }}
run: |
set -x
#npm run bump -- prerelease --build-metadata ${DIST_TAG} --preid ${DIST_TAG}
npm ci --ignore-scripts
npm run build
npm run publish -- --canary preminor --preid ${DIST_TAG} --dist-tag ${DIST_TAG}
- name: log2
run: |
ls -lR ./**/build
publish_docker:
runs-on: ubuntu-latest
needs: build_binaries
steps:
- name: load
uses: actions/download-artifact@v4
with:
pattern: "{common,xtracfg-}*"
- name: chmod
run: |
chmod +x ./xtracfg-*/xtracfg
- name: log1
run: |
ls -lR
- uses: mmatheson/[email protected]
with:
version: v4.2.4
files: |
./xtracfg-*/xtracfg
args: --best --force-macos
- name: log2
run: |
ls -lR
- uses: bhowell2/[email protected]
id: short-sha
with:
value: ${{ github.sha }}
length_from_start: 7
- name: login
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.ghcr_rw_token }}
- name: buildx
uses: docker/setup-buildx-action@v3
- name: push
if: ${{ github.ref_name == 'main' }}
uses: docker/build-push-action@v6
with:
context: .
file: ./common/Dockerfile
push: true
pull: true
tags: |
ghcr.io/ldproxy/xtracfg:next
ghcr.io/ldproxy/xtracfg:next-${{steps.short-sha.outputs.substring}}
platforms: |
linux/amd64
# linux/arm64
- name: push-branch
if: ${{ github.ref_name != 'main' }}
uses: docker/build-push-action@v6
with:
context: .
file: ./common/Dockerfile
push: true
pull: true
tags: |
ghcr.io/ldproxy/xtracfg:${{ github.ref_name }}
ghcr.io/ldproxy/xtracfg:${{ github.ref_name }}-${{steps.short-sha.outputs.substring}}
platforms: |
linux/amd64
# linux/arm64
# TODO: validate binaries and docker images