-
Notifications
You must be signed in to change notification settings - Fork 1
209 lines (174 loc) · 6.08 KB
/
build.yaml
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
name: Build and Release an SDK Generator
on:
push:
branches:
- main
# FIXME drop this!!
pull_request:
branches:
- main
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
build-jar:
name: Build jar
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Java 11
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 11
- name: Setup Clojure
uses: DeLaGuardo/setup-clojure@12.5
with:
cli: latest
- name: Cache clojure dependencies
uses: actions/cache@v4
with:
path: ~/.m2/repository
key: cljdeps-${{ hashFiles('**/deps.edn') }}
restore-keys: cljdeps-
- name: Run tests
run: echo "TODO"
- name: Build uberjar
run: |
clojure -T:build uberjar :jar-name aidbox-sdk
- name: Upload jar artifact
uses: actions/upload-artifact@v4
with:
name: build-jar
path: target/aidbox-sdk.jar
# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- #
build-native:
name: Build for ${{ matrix.os }}
runs-on: ${{ matrix.os }}
needs: build-jar
strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest
- windows-latest
- macos-latest
steps:
- uses: actions/checkout@v4
- name: Download jar artifact
uses: actions/download-artifact@v4
with:
name: build-jar
path: ./
- name: Setup GraalVM
uses: graalvm/setup-graalvm@v1
with:
java-version: "21"
distribution: "graalvm"
github-token: ${{ secrets.GITHUB_TOKEN }}
native-image-job-reports: "true"
- name: Generate reflection config
run: |
java -agentlib:native-image-agent=caller-filter-file=/home/runner/work/aidbox-sdk/aidbox-sdk/trace-filter.json,config-output-dir=/home/runner/work/aidbox-sdk/aidbox-sdk -jar ./aidbox-sdk.jar ./resources/schemas ./out
- name: Compile to native binary
run: |
mv aidbox-sdk.jar source.jar
native-image -jar ./source.jar -march=native --no-fallback --features=clj_easy.graal_build_time.InitClojureClasses -H:ReflectionConfigurationFiles=./reflect-config.json aidbox-sdk-${{ matrix.os }}
- name: Upload amd64 binary artifact
uses: actions/upload-artifact@v4
with:
name: build-${{ matrix.os }}
path: ./aidbox-sdk*
# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- #
create-release:
name: Release new version
runs-on: ubuntu-latest
needs: [build-jar, build-native]
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- name: Download artifacts
uses: actions/download-artifact@v4
with:
pattern: build-*
path: release/
merge-multiple: true
- name: Fetch all tags
run: git fetch --tags
- name: Determine next version
id: next_version
run: |
# Get the latest tag
latest_tag=$(git describe --tags `git rev-list --tags --max-count=1`)
echo "Latest tag: $latest_tag"
if [ -z "$latest_tag" ]; then
next_version="v1"
else
# Parse the version number
IFS='.' read -r -a version_parts <<< "${latest_tag:1}"
major=${version_parts[0]}
minor=${version_parts[1]}
patch=${version_parts[2]}
# Increment the patch version
patch=$((patch + 1))
next_version="v$major.$minor.$patch"
fi
echo "Next version: $next_version"
echo "tag=$next_version" >> $GITHUB_OUTPUT
- name: Create a new tag
run: |
git tag ${{ steps.next_version.outputs.tag }}
git push origin ${{ steps.next_version.outputs.tag }}
# FIXME this action is archived
- name: Create Github Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.next_version.outputs.tag }}
release_name: Release ${{ steps.next_version.outputs.tag }}
draft: false
prerelease: false
# FIXME this action is archived
# FIXME do not enumarote files in reales manually
- name: Upload Release Asset (jar)
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: release/aidbox-sdk.jar
asset_name: aidbox-sdk.jar
asset_content_type: application/java-archive
# FIXME this action is archived
- name: Upload Release Asset (amd64)
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: release/aidbox-sdk-ubuntu-latest
asset_name: aidbox-sdk-linux
asset_content_type: application/octet-stream
# FIXME this action is archived
- name: Upload Release Asset (arm64)
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: release/aidbox-sdk-macos-latest
asset_name: aidbox-sdk-macos-m1
asset_content_type: application/octet-stream
# FIXME this action is archived
- name: Upload Release Assets (Windows)
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: release/aidbox-sdk-windows-latest.exe
asset_name: aidbox-sdk-windows.exe
asset_content_type: application/octet-stream