-
Notifications
You must be signed in to change notification settings - Fork 0
222 lines (196 loc) · 7.69 KB
/
release.yml
File metadata and controls
222 lines (196 loc) · 7.69 KB
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
name: Release
on:
push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'
env:
CARGO_TERM_COLOR: always
BINARY_NAME: tellers
jobs:
# ── 1. Generate the API client on Linux (the Docker action only works there) ──
generate-api-client:
name: Generate API Client
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Generate API client
uses: openapi-generators/openapitools-generator-action@v1
with:
generator: rust
openapi-file: src/tellers_api/openapi.tellers_public_api.yaml
generator-tag: v7.17.0
command-args: >
-o generated/tellers_api_client
--additional-properties=packageName=tellers_api_client,packageVersion=0.1.0,library=reqwest,supportAsync=true,reqwestClient=true
--skip-validate-spec --strict-spec=false
- name: Upload generated API client
uses: actions/upload-artifact@v4
with:
name: generated-api-client
path: generated/tellers_api_client
# ── 2. Build release binaries for every target ──────────────────────────────
build:
name: Build — ${{ matrix.target }}
needs: generate-api-client
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- target: aarch64-apple-darwin
os: macos-latest
ext: tar.gz
- target: x86_64-apple-darwin
os: macos-latest
ext: tar.gz
- target: x86_64-unknown-linux-musl
os: ubuntu-latest
ext: tar.gz
- target: aarch64-unknown-linux-gnu
os: ubuntu-24.04-arm # native ARM64 runner — no cross-compilation needed
ext: tar.gz
- target: x86_64-pc-windows-msvc
os: windows-latest
ext: zip
steps:
- uses: actions/checkout@v4
- name: Download generated API client
uses: actions/download-artifact@v4
with:
name: generated-api-client
path: generated/tellers_api_client
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Install musl tools
if: matrix.target == 'x86_64-unknown-linux-musl'
run: sudo apt-get install -y musl-tools
- name: Build release binary
run: cargo build --release --locked --target ${{ matrix.target }}
- name: Get version from tag
id: version
shell: bash
run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> "$GITHUB_OUTPUT"
- name: Package binary (Unix)
if: matrix.ext == 'tar.gz'
shell: bash
run: |
BIN="target/${{ matrix.target }}/release/${{ env.BINARY_NAME }}"
ARCHIVE="${{ env.BINARY_NAME }}-${{ steps.version.outputs.VERSION }}-${{ matrix.target }}.tar.gz"
tar -czf "$ARCHIVE" -C "$(dirname "$BIN")" "$(basename "$BIN")"
sha256sum "$ARCHIVE" | cut -d' ' -f1 > "$ARCHIVE.sha256"
echo "ARCHIVE=$ARCHIVE" >> "$GITHUB_ENV"
- name: Package binary (Windows)
if: matrix.ext == 'zip'
shell: pwsh
run: |
$bin = "target/${{ matrix.target }}/release/${{ env.BINARY_NAME }}.exe"
$archive = "${{ env.BINARY_NAME }}-${{ steps.version.outputs.VERSION }}-${{ matrix.target }}.zip"
Compress-Archive -Path $bin -DestinationPath $archive
$hash = (Get-FileHash $archive -Algorithm SHA256).Hash.ToLower()
$hash | Out-File -FilePath "$archive.sha256" -NoNewline -Encoding ascii
echo "ARCHIVE=$archive" >> $env:GITHUB_ENV
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: release-${{ matrix.target }}
path: ${{ env.BINARY_NAME }}-* # archives + .sha256 files
# ── 3. Create the GitHub Release ────────────────────────────────────────────
release:
name: Create GitHub Release
needs: build
runs-on: ubuntu-latest
permissions:
contents: write
outputs:
version: ${{ steps.version.outputs.VERSION }}
steps:
- name: Get version from tag
id: version
run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> "$GITHUB_OUTPUT"
- name: Download all build artifacts
uses: actions/download-artifact@v4
with:
pattern: release-*
merge-multiple: true
path: artifacts
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
files: artifacts/**
generate_release_notes: true
# ── 4. Push updated formula to the Homebrew tap ─────────────────────────────
#
# Prerequisites (one-time setup):
# 1. Create repo tellers-ai/homebrew-tellers (`brew tap tellers-ai/tellers`)
# 2. Add Formula/tellers.rb (use .github/homebrew/tellers.rb as the seed)
# 3. Create a GitHub PAT (classic) with the "repo" scope
# 4. Add it as secret HOMEBREW_TAP_TOKEN in this repo's settings
#
update-homebrew-tap:
name: Update Homebrew Tap
needs: release
runs-on: ubuntu-latest
env:
VERSION: ${{ needs.release.outputs.version }}
steps:
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
pattern: release-*
merge-multiple: true
path: artifacts
- name: Generate formula
run: |
MACOS_ARM_SHA=$(cat "artifacts/tellers-${VERSION}-aarch64-apple-darwin.tar.gz.sha256")
MACOS_X86_SHA=$(cat "artifacts/tellers-${VERSION}-x86_64-apple-darwin.tar.gz.sha256")
LINUX_X86_SHA=$(cat "artifacts/tellers-${VERSION}-x86_64-unknown-linux-musl.tar.gz.sha256")
LINUX_ARM_SHA=$(cat "artifacts/tellers-${VERSION}-aarch64-unknown-linux-gnu.tar.gz.sha256")
VER="${VERSION#v}"
BASE="https://github.com/tellers-ai/tellers-cli/releases/download/${VERSION}"
cat > tellers.rb << EOF
class Tellers < Formula
desc "Tellers CLI - interact with tellers.ai from the terminal"
homepage "https://tellers.ai"
version "${VER}"
license "MIT"
on_macos do
if Hardware::CPU.arm?
url "${BASE}/tellers-${VERSION}-aarch64-apple-darwin.tar.gz"
sha256 "${MACOS_ARM_SHA}"
else
url "${BASE}/tellers-${VERSION}-x86_64-apple-darwin.tar.gz"
sha256 "${MACOS_X86_SHA}"
end
end
on_linux do
if Hardware::CPU.arm?
url "${BASE}/tellers-${VERSION}-aarch64-unknown-linux-gnu.tar.gz"
sha256 "${LINUX_ARM_SHA}"
else
url "${BASE}/tellers-${VERSION}-x86_64-unknown-linux-musl.tar.gz"
sha256 "${LINUX_X86_SHA}"
end
end
def install
bin.install "tellers"
end
test do
system "#{bin}/tellers", "--help"
end
end
EOF
- name: Push formula to tap repo
env:
TAP_TOKEN: ${{ secrets.HOMEBREW_TAP_TOKEN }}
run: |
git clone "https://x-access-token:${TAP_TOKEN}@github.com/tellers-ai/homebrew-tellers.git" tap
mkdir -p tap/Formula
cp tellers.rb tap/Formula/tellers.rb
cd tap
git config user.name "GitHub Actions"
git config user.email "actions@github.com"
git add Formula/tellers.rb
git diff --cached --quiet || git commit -m "tellers ${VERSION}"
git push