@@ -3,60 +3,154 @@ name: xtracfg
33on : [push]
44
55jobs :
6- build :
6+ build_libraries :
7+ runs-on : ${{ matrix.os.runner }}
78 strategy :
89 matrix :
910 os :
10- - runner : ubuntu-latest
11+ - runner : ubuntu-24.04
1112 type : linux
1213 platform : linux-amd64
13- # - runner: buildjet-2vcpu-ubuntu-2204-arm
14- # type: linux
15- # platform: linux-arm64
16- - runner : macos-latest
14+ - runner : ubuntu-24.04-arm # buildjet-2vcpu-ubuntu-2204-arm
15+ type : linux
16+ platform : linux-arm64
17+ - runner : macos-14
1718 type : macos
1819 platform : darwin-arm64
19- runs-on : ${{ matrix.os.runner }}
20- defaults :
21- run :
22- working-directory : ./xtracfg
20+ # - runner: windows-2022
21+ # type: windows
22+ # platform: windows-amd64
2323 steps :
2424 - uses : actions/checkout@v4
25+ - uses : actions/setup-node@v4
26+ with :
27+ node-version : 20
2528 - uses : actions/setup-go@v5
2629 with :
27- go-version : " 1.21.13 "
30+ go-version : " 1.23.2 "
2831 cache-dependency-path : xtracfg/go.sum
2932 - uses : graalvm/setup-graalvm@v1
3033 with :
31- java-version : " 17 "
32- distribution : " liberica "
34+ java-version : " 21 "
35+ distribution : " graalvm "
3336 native-image-job-reports : true
3437 cache : gradle
35- cache-dependency-path : |
36- xtracfg/*.gradle*
37- xtracfg/**/gradle-wrapper.properties
38- - name : build go
38+ # cache-dependency-path: |
39+ # xtracfg/*.gradle*
40+ # xtracfg/**/gradle-wrapper.properties
41+ - name : zlib
42+ if : ${{ matrix.os.type == 'linux' }}
43+ working-directory : /tmp
3944 env :
40- CI_COMMIT_BRANCH : ${{ github.ref_name }}
41- CI_COMMIT_SHA : ${{ github.sha }}
42- CI_COMMIT_TAG : ${{ github.ref_type == 'tag' && github.ref_name || '' }}
43- JAVA_INCLUDE : ${{ matrix.os.type == 'macos' && 'darwin' || 'linux' }}
45+ ZLIB_VERSION : 1.2.11
46+ run : |
47+ wget https://zlib.net/fossils/zlib-${ZLIB_VERSION}.tar.gz
48+ tar xzvf zlib-${ZLIB_VERSION}.tar.gz
49+ mv zlib-${ZLIB_VERSION} zlib
50+ cd zlib
51+ CFLAGS="-fPIC" ./configure --static
52+ make
53+ - name : java
54+ working-directory : ./libxtracfg/java
4455 run : |
45- git config --global --add safe.directory $GITHUB_WORKSPACE
46- CGO_CFLAGS="-I$JAVA_HOME/include -I$JAVA_HOME/include/${JAVA_INCLUDE}" go build -buildmode c-archive -o dist/libxtracfg.a -ldflags="-s -w '-extldflags=-z noexecstack' -X github.com/interactive-instruments/xtraplatform-cli/xtracfg/cmd.gitTag=${CI_COMMIT_TAG} -X github.com/interactive-instruments/xtraplatform-cli/xtracfg/cmd.gitSha=${CI_COMMIT_SHA} -X github.com/interactive-instruments/xtraplatform-cli/xtracfg/cmd.gitBranch=${CI_COMMIT_BRANCH}"
56+ ./gradlew nativeCompile -PLIB=true
4757 - name : log1
4858 run : |
49- ls -lR ./dist
50- - name : build java
59+ ls -l ./libxtracfg/c/build
60+ # TODO: windows
61+ - name : c
62+ working-directory : ./libxtracfg/c
5163 run : |
52- ./gradlew nativeCompile ${{ matrix.os.type == 'linux' && '-PSTATIC=true' || '' }}
64+ ./build.sh
65+ ./test.sh
5366 - name : log2
5467 run : |
55- ls -lR ./build/native/nativeCompile
68+ ls -l ./libxtracfg/c/build
69+ - name : js
70+ working-directory : ./libxtracfg/js/xtracfg-native-binding
71+ run : |
72+ npm --loglevel verbose ci
73+ npm --loglevel verbose run prebuildify
74+ npm --loglevel verbose run test
75+ - name : log3
76+ run : |
77+ ls -lR ./libxtracfg/js/xtracfg-native-binding/prebuilds
78+ # TODO: run tests for java, c, go
79+ - uses : actions/upload-artifact@v4
80+ with :
81+ name : libxtracfg-c-${{ matrix.os.platform }}
82+ path : ./libxtracfg/c/build/libxtracfg.a
83+ retention-days : 1
84+ - uses : actions/upload-artifact@v4
85+ with :
86+ name : libxtracfg-c-hash-${{ matrix.os.platform }}
87+ path : ./libxtracfg/go/xtracfg/libxtracfg.sha1sum
88+ retention-days : 1
89+ - uses : actions/upload-artifact@v4
90+ with :
91+ name : libxtracfg-js-${{ matrix.os.platform }}
92+ path : ./libxtracfg/js/xtracfg-native-binding/prebuilds
93+ retention-days : 1
94+
95+ build_binaries :
96+ runs-on : ${{ matrix.os.runner }}
97+ needs : build_libraries
98+ strategy :
99+ matrix :
100+ os :
101+ - runner : ubuntu-24.04
102+ type : linux
103+ platform : linux-amd64
104+ - runner : ubuntu-24.04-arm # buildjet-2vcpu-ubuntu-2204-arm
105+ type : linux
106+ platform : linux-arm64
107+ - runner : macos-14
108+ type : macos
109+ platform : darwin-arm64
110+ # - runner: windows-2022
111+ # type: windows
112+ # platform: windows-amd64
113+ defaults :
114+ run :
115+ working-directory : ./xtracfg
116+ steps :
117+ - uses : actions/checkout@v4
118+ - uses : actions/setup-go@v5
119+ with :
120+ go-version : " 1.23.2"
121+ cache-dependency-path : xtracfg/go.sum
122+ - uses : actions/download-artifact@v4
123+ with :
124+ name : libxtracfg-c-${{ matrix.os.platform }}
125+ path : ./libxtracfg/c/build/
126+ - uses : actions/download-artifact@v4
127+ with :
128+ name : libxtracfg-c-hash-${{ matrix.os.platform }}
129+ path : ./libxtracfg/go/xtracfg/
130+ -
uses :
bhowell2/[email protected] 131+ id : short-sha
132+ with :
133+ value : ${{ github.sha }}
134+ length_from_start : 7
135+ - name : build
136+ env :
137+ CMD_GIT_BRANCH : github.com/interactive-instruments/xtraplatform-cli/xtracfg/cmd.gitBranch=${{ github.ref_name }}
138+ CMD_GIT_SHA : github.com/interactive-instruments/xtraplatform-cli/xtracfg/cmd.gitSha=${{ steps.short-sha.outputs.substring }}
139+ CMD_GIT_TAG : github.com/interactive-instruments/xtraplatform-cli/xtracfg/cmd.gitTag=${{ github.ref_type == 'tag' && github.ref_name || '' }}
140+ EXT_LDFLAGS : ${{ matrix.os.type == 'macos' && '-framework CoreServices -framework Foundation' || '-z noexecstack' }}
141+ run : |
142+ go build -o build/xtracfg -ldflags="-s -w -X ${CMD_GIT_TAG} -X ${CMD_GIT_SHA} -X ${CMD_GIT_BRANCH} '-extldflags=${EXT_LDFLAGS}'"
143+ - name : log1
144+ run : |
145+ ls -lR ./build
146+ - name : test
147+ run : |
148+ ./build/xtracfg --version
149+ ./build/xtracfg info
56150 - uses : actions/upload-artifact@v4
57151 with :
58- name : ${{ matrix.os.platform }}
59- path : ./xtracfg/build/native/nativeCompile
152+ name : xtracfg- ${{ matrix.os.platform }}
153+ path : ./xtracfg/build/xtracfg
60154 retention-days : 1
61155 - uses : actions/upload-artifact@v4
62156 if : ${{ matrix.os.platform == 'linux-amd64' }}
@@ -65,20 +159,93 @@ jobs:
65159 path : ./xtracfg/Dockerfile
66160 retention-days : 1
67161
68- docker :
162+ publish_npm :
163+ runs-on : ubuntu-latest
164+ needs : build_libraries
165+ defaults :
166+ run :
167+ working-directory : ./libxtracfg/js
168+ steps :
169+ - uses : actions/checkout@v4
170+ with :
171+ fetch-depth : 0 # need full history for snapshot version
172+ - uses : actions/download-artifact@v4
173+ with :
174+ pattern : " libxtracfg-js-*"
175+ path : ./libxtracfg/js/xtracfg-native-binding/prebuilds
176+ merge-multiple : true
177+ - name : log1
178+ run : |
179+ ls -lR ./xtracfg-native-binding/prebuilds
180+ - name : publish-branch
181+ if : ${{ github.ref_type == 'branch' }}
182+ env :
183+ DIST_TAG : ${{ github.ref_name == 'main' && 'next' || github.ref_name }}
184+ NPM_TOKEN : ${{ secrets.npm_rw_token }}
185+ run : |
186+ set -x
187+ #npm run bump -- prerelease --build-metadata ${DIST_TAG} --preid ${DIST_TAG}
188+ npm ci --ignore-scripts
189+ npm run build
190+ npm run publish -- --canary preminor --preid ${DIST_TAG} --dist-tag ${DIST_TAG}
191+ - name : publish-tag
192+ if : ${{ github.ref_type == 'tag' }}
193+ env :
194+ NPM_TOKEN : ${{ secrets.npm_rw_token }}
195+ run : |
196+ set -x
197+ npm ci --ignore-scripts
198+ npm run build
199+ npm run publish -- from-package
200+ - name : log2
201+ run : |
202+ ls -lR ./**/build
203+
204+ publish_docker :
69205 runs-on : ubuntu-latest
70- needs : build
206+ needs : build_binaries
71207 steps :
72208 - name : load
73209 uses : actions/download-artifact@v4
210+ with :
211+ pattern : " {common,xtracfg-}*"
212+ - name : chmod
213+ run : |
214+ chmod +x ./xtracfg-*/xtracfg
74215 - name : log1
75216 run : |
76217 ls -lR
218+ -
uses :
mmatheson/[email protected] 219+ with :
220+ version : v4.2.4
221+ files : |
222+ ./xtracfg-*/xtracfg
223+ args : --best --force-macos
224+ - name : log2
225+ run : |
226+ ls -lR
227+ - name : release-github
228+ if : ${{ github.ref_type == 'tag' && startsWith(github.ref_name, 'v') }}
229+ env :
230+ GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
231+ run : |
232+ tar -czvf xtracfg_${{ github.ref_name }}_linux_amd64.tar.gz -C ./xtracfg-linux-amd64 xtracfg
233+ tar -czvf xtracfg_${{ github.ref_name }}_linux_arm64.tar.gz -C ./xtracfg-linux-arm64 xtracfg
234+ tar -czvf xtracfg_${{ github.ref_name }}_macos_arm64.tar.gz -C ./xtracfg-darwin-arm64 xtracfg
235+ gh release upload ${{ github.ref_name }} xtracfg_${{ github.ref_name }}_linux_amd64.tar.gz --repo ldproxy/xtraplatform-cli
236+ gh release upload ${{ github.ref_name }} xtracfg_${{ github.ref_name }}_linux_arm64.tar.gz --repo ldproxy/xtraplatform-cli
237+ gh release upload ${{ github.ref_name }} xtracfg_${{ github.ref_name }}_macos_arm64.tar.gz --repo ldproxy/xtraplatform-cli
77238 -
uses :
bhowell2/[email protected] 78239 id : short-sha
79240 with :
80241 value : ${{ github.sha }}
81242 length_from_start : 7
243+ -
uses :
bhowell2/[email protected] 244+ if : ${{ github.ref_type == 'tag' && startsWith(github.ref_name, 'v') }}
245+ id : short-tag
246+ with :
247+ value : ${{ github.ref_name }}
248+ index_of_str : " v"
82249 - name : login
83250 uses : docker/login-action@v3
84251 with :
87254 password : ${{ secrets.ghcr_rw_token }}
88255 - name : buildx
89256 uses : docker/setup-buildx-action@v3
90- - name : push
91- if : ${{ github.ref_name == 'main' }}
257+ - name : publish-main
258+ if : ${{ github.ref_type == 'branch' && github. ref_name == 'main' }}
92259 uses : docker/build-push-action@v6
93260 with :
94261 context : .
@@ -100,17 +267,34 @@ jobs:
100267 ghcr.io/ldproxy/xtracfg:next-${{steps.short-sha.outputs.substring}}
101268 platforms : |
102269 linux/amd64
103- # linux/arm64
104- - name : push -branch
105- if : ${{ github.ref_name != 'main' }}
270+ linux/arm64
271+ - name : publish -branch
272+ if : ${{ github.ref_type == 'branch' && github. ref_name != 'main' }}
106273 uses : docker/build-push-action@v6
107274 with :
108275 context : .
276+ file : ./common/Dockerfile
109277 push : true
110278 pull : true
111279 tags : |
112280 ghcr.io/ldproxy/xtracfg:${{ github.ref_name }}
113281 ghcr.io/ldproxy/xtracfg:${{ github.ref_name }}-${{steps.short-sha.outputs.substring}}
114282 platforms : |
115283 linux/amd64
116- # linux/arm64
284+ linux/arm64
285+ - name : publish-tag
286+ if : ${{ github.ref_type == 'tag' && startsWith(github.ref_name, 'v') }}
287+ uses : docker/build-push-action@v6
288+ with :
289+ context : .
290+ file : ./common/Dockerfile
291+ push : true
292+ pull : true
293+ tags : |
294+ ghcr.io/ldproxy/xtracfg:${{ steps.short-tag.outputs.substring }}
295+ ghcr.io/ldproxy/xtracfg:latest
296+ platforms : |
297+ linux/amd64
298+ linux/arm64
299+
300+ # TODO: validate binaries and docker images
0 commit comments