-
Notifications
You must be signed in to change notification settings - Fork 1
184 lines (179 loc) · 5.63 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
name: xtracfg
on: [push]
jobs:
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-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: java
working-directory: ./libxtracfg/java
run: |
./gradlew nativeCompile -PLIB=true
- name: log
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
# 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
binary:
runs-on: ${{ matrix.os.runner }}
needs: 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
docker:
runs-on: ubuntu-latest
needs: binary
steps:
- name: load
uses: actions/download-artifact@v4
with:
pattern: "{common,xtracfg-}*"
- name: log1
run: |
ls -lR
- uses: docker://backplane/upx:latest
with:
args: upx --best ./xtracfg-*/xtracfg
- 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: .
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