-
Notifications
You must be signed in to change notification settings - Fork 0
225 lines (189 loc) · 6.47 KB
/
Copy pathrelease.yml
File metadata and controls
225 lines (189 loc) · 6.47 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
223
224
225
name: Release
on:
push:
tags:
- 'v*'
workflow_dispatch:
inputs:
version:
description: 'Release version'
required: false
permissions:
contents: write
jobs:
build:
name: Build ${{ matrix.target }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- target: x86_64-apple-darwin
os: macos-latest
suffix: darwin-x64
- target: aarch64-apple-darwin
os: macos-latest
suffix: darwin-arm64
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
suffix: linux-x64
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Rust Cache
uses: Swatinem/rust-cache@v2
with:
workspaces: "rust-core"
key: ${{ matrix.target }}
- name: Install protoc
uses: arduino/setup-protoc@v3
with:
version: "25.x"
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Build Rust binary (${{ matrix.target }})
working-directory: rust-core
run: cargo build --release --target ${{ matrix.target }}
env:
CC_x86_64_apple_darwin: clang -arch x86_64
MACOSX_DEPLOYMENT_TARGET: "10.15"
- name: Create release archive (tar.gz)
run: |
BIN_DIR="codexray-${{ matrix.suffix }}"
mkdir -p "$BIN_DIR"
# Copy binary
cp rust-core/target/${{ matrix.target }}/release/codexray "$BIN_DIR/"
# Copy docs
cp rust-core/LICENSE "$BIN_DIR/" 2>/dev/null || true
cp rust-core/README.md "$BIN_DIR/" 2>/dev/null || true
cp rust-core/README_ZH.md "$BIN_DIR/" 2>/dev/null || true
# Ensure execute permission is set
chmod +x "$BIN_DIR/codexray"
# Create tar.gz (preserves execute permissions)
tar -czf "codexray-${{ matrix.suffix }}.tar.gz" "$BIN_DIR"
# Verify
echo "Archive contents:"
tar -tzf "codexray-${{ matrix.suffix }}.tar.gz"
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: codexray-${{ matrix.suffix }}
path: codexray-${{ matrix.suffix }}.tar.gz
if-no-files-found: error
musl-build:
name: Build linux-x64 (musl static)
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install musl tools and build deps
run: |
sudo apt-get update
sudo apt-get install -y musl-tools perl make pkg-config
- name: Setup Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: x86_64-unknown-linux-musl
- name: Rust Cache
uses: Swatinem/rust-cache@v2
with:
workspaces: "rust-core"
key: musl
- name: Install protoc
uses: arduino/setup-protoc@v3
with:
version: "25.x"
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Build Rust binary (static musl)
working-directory: rust-core
run: |
export CC_x86_64_unknown_linux_musl=musl-gcc
export CXX_x86_64_unknown_linux_musl=musl-g++
cargo build --release --target x86_64-unknown-linux-musl
- name: Verify static linking
run: |
echo "=== Verifying static linking ==="
file rust-core/target/x86_64-unknown-linux-musl/release/codexray
echo ""
echo "=== Checking for dynamic symbols ==="
if command -v readelf &> /dev/null; then
readelf -d rust-core/target/x86_64-unknown-linux-musl/release/codexray 2>&1 | head -20 || echo "(no dynamic section = fully static)"
fi
if command -v ldd &> /dev/null; then
ldd rust-core/target/x86_64-unknown-linux-musl/release/codexray 2>&1 | head -10 || true
fi
- name: Create release archive (tar.gz)
run: |
BIN_DIR="codexray-linux-x64-musl"
mkdir -p "$BIN_DIR"
cp rust-core/target/x86_64-unknown-linux-musl/release/codexray "$BIN_DIR/"
cp rust-core/LICENSE "$BIN_DIR/" 2>/dev/null || true
cp rust-core/README.md "$BIN_DIR/" 2>/dev/null || true
cp rust-core/README_ZH.md "$BIN_DIR/" 2>/dev/null || true
chmod +x "$BIN_DIR/codexray"
tar -czf "codexray-linux-x64-musl.tar.gz" "$BIN_DIR"
echo "Archive contents:"
tar -tzf "codexray-linux-x64-musl.tar.gz"
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: codexray-linux-x64-musl
path: codexray-linux-x64-musl.tar.gz
if-no-files-found: error
create-release:
name: Create Release
needs: [build, musl-build]
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/v') || github.event_name == 'workflow_dispatch'
steps:
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Organize release assets
run: |
set -euo pipefail
echo "=== Artifacts structure ==="
find artifacts -type f -exec ls -lh {} \;
echo ""
mkdir -p release
for dir in artifacts/*/; do
name="$(basename "$dir")"
cp "$dir/${name}.tar.gz" "release/" 2>/dev/null || true
done
echo "=== Release assets ==="
ls -lh release/
- name: Create Release
uses: softprops/action-gh-release@v2
with:
files: |
release/codexray-darwin-x64.tar.gz
release/codexray-darwin-arm64.tar.gz
release/codexray-linux-x64.tar.gz
release/codexray-linux-x64-musl.tar.gz
generate_release_notes: true
fail_on_unmatched_files: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
publish-npm:
name: Publish to npm
needs: [build, musl-build]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
registry-url: 'https://registry.npmjs.org'
- name: Install dependencies & build
run: |
npm install
npm run build
- name: Publish
run: npm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}