-
Notifications
You must be signed in to change notification settings - Fork 57
257 lines (229 loc) · 9.76 KB
/
cli.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
253
254
255
256
257
name: Gloo CLI
on:
pull_request:
paths:
- "engine/**"
- ".github/workflows/cli.yml"
branches:
- canary
push:
paths:
- "engine/.bumpversion.cfg"
branches:
- canary
tags:
- "release/baml-cli/v*.*.*"
permissions:
contents: read
pull-requests: read
repository-projects: read
jobs:
build:
name: Build ${{ matrix.platform.name }}
strategy:
fail-fast: false # Don't stop all builds if one fails
matrix:
platform:
- os: ubuntu-20.04
target: x86_64-unknown-linux-gnu
bin: baml
name: baml-linux-x86_64
command: build
- os: windows-latest
target: x86_64-pc-windows-msvc
bin: baml.exe
name: baml-Windows-x86_64
command: both
- os: macOS-latest
target: x86_64-apple-darwin
bin: baml
name: baml-Darwin-x86_64
command: both
- os: macOS-latest
target: aarch64-apple-darwin
bin: baml
name: baml-Darwin-apple-silicon
command: build # Can't test on macOS-latest because it's Intel
runs-on: ${{ matrix.platform.os }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- uses: Swatinem/rust-cache@v2
with:
workspaces: |
engine
prefix-key: "v2-rust" # We changed the ubuntu version so we need to invalidate the cache
- name: Build binary
uses: houseabsolute/actions-rust-cross@v0
with:
command: ${{ matrix.platform.command }}
target: ${{ matrix.platform.target }}
args: "--locked --release"
strip: false # Don't strip debug symbols
working-directory: engine/baml-cli
# Run Tests on Linux
- name: Run tests
if: ${{ matrix.platform.target == 'x86_64-unknown-linux-gnu' }}
working-directory: engine/baml-cli
run: |
cargo test --locked --release --target x86_64-unknown-linux-gnu
- name: Add artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.platform.name }}
path: engine/target/${{ matrix.platform.target }}/release/${{ matrix.platform.bin }}
pre-release:
permissions:
contents: write
runs-on: ubuntu-latest
needs: build
if: github.ref == 'refs/heads/canary'
environment: nightly
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Get artifact [Darwin-Intel]
uses: actions/download-artifact@v4
with:
name: baml-Darwin-x86_64
path: engine/target/x86_64-apple-darwin/release/
- name: Get artifact [Darwin-Silicon]
uses: actions/download-artifact@v4
with:
name: baml-Darwin-apple-silicon
path: engine/target/aarch64-apple-darwin/release/
- name: Get artifact [Linux]
uses: actions/download-artifact@v4
with:
name: baml-linux-x86_64
path: engine/target/x86_64-unknown-linux-gnu/release/
- name: Get artifact [Windows]
uses: actions/download-artifact@v4
with:
name: baml-Windows-x86_64
path: engine/target/x86_64-pc-windows-msvc/release/
- id: hash
run: |
VERSION=$(cat engine/.bumpversion.cfg | grep "current_version =" | cut -d '=' -f 2 | sed 's/[", ]//g')
if [[ ! $VERSION =~ ^[0-9]+\.[0-9]+\.[0-9]+-canary\.[0-9]+$ ]]; then
echo "Version ($VERSION) is not a pre-release build"
exit 1
fi
pushd engine/target/x86_64-unknown-linux-gnu/release
tar -czvf baml-linux-x86_64.tar.gz baml
echo "linux_hash=$(shasum -a 256 baml-linux-x86_64.tar.gz | cut -d ' ' -f 1)" >> $GITHUB_OUTPUT
popd
pushd engine/target/x86_64-apple-darwin/release
tar -czvf baml-apple-intel.tar.gz baml
echo "darwin_intel_hash=$(shasum -a 256 baml-apple-intel.tar.gz | cut -d ' ' -f 1)" >> $GITHUB_OUTPUT
popd
pushd engine/target/aarch64-apple-darwin/release
tar -czvf baml-apple-arm.tar.gz baml
echo "darwin_arm_hash=$(shasum -a 256 baml-apple-arm.tar.gz | cut -d ' ' -f 1)" >> $GITHUB_OUTPUT
popd
windows_binary_path="engine/target/x86_64-pc-windows-msvc/release/baml.exe"
echo "windows_hash=$(shasum -a 256 "$windows_binary_path" | cut -d ' ' -f 1)" >> $GITHUB_OUTPUT
echo "version=$(echo $VERSION | cut -d '-' -f 1)" >> $GITHUB_OUTPUT
echo "full_version=$VERSION" >> $GITHUB_OUTPUT
- name: Release
uses: softprops/action-gh-release@v2
with:
tag_name: "unstable/cli/v${{ steps.hash.outputs.version }}"
files: |
engine/target/x86_64-unknown-linux-gnu/release/baml-linux-x86_64.tar.gz
engine/target/x86_64-apple-darwin/release/baml-apple-intel.tar.gz
engine/target/aarch64-apple-darwin/release/baml-apple-arm.tar.gz
engine/target/x86_64-pc-windows-msvc/release/baml.exe
prerelease: true # Must manually upgrade to release once homebrew is updated.
body: |
## Hashes
Full Version: `${{ steps.hash.outputs.full_version }}`
Linux: `${{ steps.hash.outputs.linux_hash }}`
Mac: Intel: `${{ steps.hash.outputs.darwin_intel_hash }}`
Mac: Apple Silicon: `${{ steps.hash.outputs.darwin_arm_hash }}`
Windows: `${{ steps.hash.outputs.windows_hash }}`
- name: Trigger homebrew-baml update
uses: peter-evans/repository-dispatch@v3
with:
token: ${{ secrets.HOMEBREW_BAML_PAT }}
repository: boundaryml/homebrew-baml
event-type: update-formula
client-payload: '{"version": "${{ steps.hash.outputs.full_version }}", "hash_linux": "${{ steps.hash.outputs.linux_hash }}", "hash_mac_intel": "${{ steps.hash.outputs.darwin_intel_hash }}", "hash_mac_arm": "${{ steps.hash.outputs.darwin_arm_hash }}", "hash_windows": "${{ steps.hash.outputs.windows_hash }}", "nightly": true}'
release:
permissions:
contents: write
pull-requests: write
runs-on: ubuntu-latest
needs: build
if: startsWith(github.ref, 'refs/tags/release/')
environment: release
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Get artifact [Darwin-Intel]
uses: actions/download-artifact@v4
with:
name: baml-Darwin-x86_64
path: engine/target/x86_64-apple-darwin/release/
- name: Get artifact [Darwin-Silicon]
uses: actions/download-artifact@v4
with:
name: baml-Darwin-apple-silicon
path: engine/target/aarch64-apple-darwin/release/
- name: Get artifact [Linux]
uses: actions/download-artifact@v4
with:
name: baml-linux-x86_64
path: engine/target/x86_64-unknown-linux-gnu/release/
- name: Get artifact [Windows]
uses: actions/download-artifact@v4
with:
name: baml-Windows-x86_64
path: engine/target/x86_64-pc-windows-msvc/release/
- id: hash
run: |
VERSION=$(cat engine/.bumpversion.cfg | grep "current_version =" | cut -d '=' -f 2 | sed 's/[", ]//g')
if [[ ! $VERSION =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "Version ($VERSION) is not a release build"
exit 1
fi
pushd engine/target/x86_64-unknown-linux-gnu/release
tar -czvf baml-linux-x86_64.tar.gz baml
echo "linux_hash=$(shasum -a 256 baml-linux-x86_64.tar.gz | cut -d ' ' -f 1)" >> $GITHUB_OUTPUT
popd
pushd engine/target/x86_64-apple-darwin/release
tar -czvf baml-apple-intel.tar.gz baml
echo "darwin_intel_hash=$(shasum -a 256 baml-apple-intel.tar.gz | cut -d ' ' -f 1)" >> $GITHUB_OUTPUT
popd
pushd engine/target/aarch64-apple-darwin/release
tar -czvf baml-apple-arm.tar.gz baml
echo "darwin_arm_hash=$(shasum -a 256 baml-apple-arm.tar.gz | cut -d ' ' -f 1)" >> $GITHUB_OUTPUT
popd
windows_binary_path="engine/target/x86_64-pc-windows-msvc/release/baml.exe"
echo "windows_hash=$(shasum -a 256 "$windows_binary_path" | cut -d ' ' -f 1)" >> $GITHUB_OUTPUT
echo "version=$(echo $VERSION | cut -d '-' -f 1)" >> $GITHUB_OUTPUT
echo "full_version=$VERSION" >> $GITHUB_OUTPUT
- name: Release
uses: softprops/action-gh-release@v2
with:
name: "Cli: ${{ steps.hash.outputs.version }}"
tag_name: "release/baml-cli/v${{ steps.hash.outputs.version }}"
files: |
engine/target/x86_64-unknown-linux-gnu/release/baml-linux-x86_64.tar.gz
engine/target/x86_64-apple-darwin/release/baml-apple-intel.tar.gz
engine/target/aarch64-apple-darwin/release/baml-apple-arm.tar.gz
engine/target/x86_64-pc-windows-msvc/release/baml.exe
prerelease: false
body: |
## Hashes
Linux: `${{ steps.hash.outputs.linux_hash }}`
Mac: Intel: `${{ steps.hash.outputs.darwin_intel_hash }}`
Mac: Apple Silicon: `${{ steps.hash.outputs.darwin_arm_hash }}`
Windows: `${{ steps.hash.outputs.windows_hash }}`
- name: Trigger homebrew-baml update
uses: peter-evans/repository-dispatch@v3
with:
token: ${{ secrets.HOMEBREW_BAML_PAT }}
repository: boundaryml/homebrew-baml
event-type: update-formula
client-payload: '{"version": "${{ steps.hash.outputs.version }}", "hash_linux": "${{ steps.hash.outputs.linux_hash }}", "hash_mac_intel": "${{ steps.hash.outputs.darwin_intel_hash }}", "hash_mac_arm": "${{ steps.hash.outputs.darwin_arm_hash }}", "hash_windows": "${{ steps.hash.outputs.windows_hash }}"}'