Repository navigation
218 lines (202 loc) · 7.31 KB
/
Copy pathrelease.yml
File metadata and controls
218 lines (202 loc) · 7.31 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
name: Release
on:
push:
tags: ['v*']
permissions:
contents: write
env:
BIN_NAME: claude-code-proxy
jobs:
checks:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- uses: dtolnay/rust-toolchain@stable
- name: Test
run: cargo test --locked
build:
needs: checks
strategy:
fail-fast: false
matrix:
include:
- os: macos-14
target: aarch64-apple-darwin
platform: darwin-arm64
ext: ""
archive: tar.gz
- os: macos-15-intel
target: x86_64-apple-darwin
platform: darwin-amd64
ext: ""
archive: tar.gz
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
platform: linux-amd64
ext: ""
archive: tar.gz
- os: ubuntu-24.04-arm
target: aarch64-unknown-linux-gnu
platform: linux-arm64
ext: ""
archive: tar.gz
- os: windows-latest
target: x86_64-pc-windows-msvc
platform: windows-amd64
ext: .exe
archive: zip
- os: windows-11-arm
target: aarch64-pc-windows-msvc
platform: windows-arm64
ext: .exe
archive: zip
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v5
- uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Build
run: |
cargo build --release --locked --target ${{ matrix.target }}
- name: Verify Unix binary
if: runner.os != 'Windows'
env:
VERSION: ${{ github.ref_name }}
run: |
expected="claude-code-proxy ${VERSION#v}"
actual="$(target/${{ matrix.target }}/release/${BIN_NAME} --version)"
test "$actual" = "$expected"
- name: Verify Windows binary
if: runner.os == 'Windows'
shell: pwsh
env:
VERSION: ${{ github.ref_name }}
run: |
$expected = "claude-code-proxy $($env:VERSION.TrimStart('v'))"
$actual = & "target/${{ matrix.target }}/release/${env:BIN_NAME}.exe" --version
if ($actual -ne $expected) {
Write-Error "expected '$expected', got '$actual'"
}
- name: Package Unix
if: runner.os != 'Windows'
run: |
mkdir -p dist
cp "target/${{ matrix.target }}/release/${BIN_NAME}" "dist/${BIN_NAME}"
archive="${BIN_NAME}-${{ matrix.platform }}.${{ matrix.archive }}"
tar -C dist -czf "$archive" "${BIN_NAME}"
shasum -a 256 "$archive" > "${BIN_NAME}-${{ matrix.platform }}.sha256"
- name: Package Windows
if: runner.os == 'Windows'
shell: pwsh
run: |
New-Item -ItemType Directory -Force dist | Out-Null
Copy-Item "target/${{ matrix.target }}/release/${env:BIN_NAME}.exe" "dist/${env:BIN_NAME}.exe"
$archive = "${env:BIN_NAME}-${{ matrix.platform }}.${{ matrix.archive }}"
Compress-Archive -Path "dist/${env:BIN_NAME}.exe" -DestinationPath $archive -Force
$hash = (Get-FileHash -Algorithm SHA256 $archive).Hash.ToLower()
"$hash $archive" | Out-File -FilePath "${env:BIN_NAME}-${{ matrix.platform }}.sha256" -Encoding ascii
- uses: actions/upload-artifact@v5
with:
name: ${{ matrix.platform }}
path: |
${{ env.BIN_NAME }}-${{ matrix.platform }}.${{ matrix.archive }}
${{ env.BIN_NAME }}-${{ matrix.platform }}.sha256
smoke-windows:
needs: build
runs-on: windows-latest
steps:
- uses: actions/download-artifact@v5
with:
name: windows-amd64
- shell: pwsh
run: |
Expand-Archive claude-code-proxy-windows-amd64.zip -DestinationPath .
.\claude-code-proxy.exe --version
release:
needs: [build, smoke-windows]
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/download-artifact@v5
with:
merge-multiple: true
- uses: softprops/action-gh-release@v2
with:
token: ${{ secrets.RELEASE_TOKEN }}
generate_release_notes: true
files: |
*.tar.gz
*.zip
*.sha256
update-tap:
needs: release
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v5
with:
merge-multiple: true
- uses: actions/checkout@v5
with:
repository: raine/homebrew-claude-code-proxy
token: ${{ secrets.RELEASE_TOKEN }}
path: tap
- name: Generate formula and push to tap
env:
VERSION: ${{ github.ref_name }}
run: |
VERSION="${VERSION#v}"
SHA_ARM=$(awk '{print $1}' claude-code-proxy-darwin-arm64.sha256)
SHA_INTEL=$(awk '{print $1}' claude-code-proxy-darwin-amd64.sha256)
SHA_LINUX_AMD=$(awk '{print $1}' claude-code-proxy-linux-amd64.sha256)
SHA_LINUX_ARM=$(awk '{print $1}' claude-code-proxy-linux-arm64.sha256)
mkdir -p tap/Formula
cat > tap/Formula/claude-code-proxy.rb << EOF
class ClaudeCodeProxy < Formula
desc "Local proxy: Claude Code to ChatGPT subscription via Codex Responses API"
homepage "https://github.com/raine/claude-code-proxy"
version "${VERSION}"
license "MIT"
on_macos do
if Hardware::CPU.arm?
url "https://github.com/raine/claude-code-proxy/releases/download/v${VERSION}/claude-code-proxy-darwin-arm64.tar.gz"
sha256 "${SHA_ARM}"
else
url "https://github.com/raine/claude-code-proxy/releases/download/v${VERSION}/claude-code-proxy-darwin-amd64.tar.gz"
sha256 "${SHA_INTEL}"
end
end
on_linux do
if Hardware::CPU.arm?
url "https://github.com/raine/claude-code-proxy/releases/download/v${VERSION}/claude-code-proxy-linux-arm64.tar.gz"
sha256 "${SHA_LINUX_ARM}"
else
url "https://github.com/raine/claude-code-proxy/releases/download/v${VERSION}/claude-code-proxy-linux-amd64.tar.gz"
sha256 "${SHA_LINUX_AMD}"
end
end
def install
bin.install "claude-code-proxy"
end
service do
state_home = ENV.fetch("XDG_STATE_HOME", "#{Dir.home}/.local/state")
run [opt_bin/"claude-code-proxy", "serve", "--no-monitor"]
keep_alive true
environment_variables XDG_STATE_HOME: state_home
log_path "#{state_home}/claude-code-proxy/service.log"
error_log_path "#{state_home}/claude-code-proxy/service.log"
end
test do
assert_match version.to_s, shell_output("\#{bin}/claude-code-proxy --version")
end
end
EOF
sed -i 's/^ //' tap/Formula/claude-code-proxy.rb
cd tap
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add Formula/claude-code-proxy.rb
git commit -m "claude-code-proxy ${VERSION}"
git pull --rebase
git push