-
Notifications
You must be signed in to change notification settings - Fork 2
158 lines (136 loc) · 5.17 KB
/
Copy pathrelease.yml
File metadata and controls
158 lines (136 loc) · 5.17 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
name: Release
on:
push:
tags:
- "v*.*.*"
jobs:
build:
name: Build (${{ matrix.triple }})
runs-on: ${{ matrix.os }}
permissions:
contents: read
strategy:
fail-fast: false
matrix:
include:
- triple: linux-x64
target: x86_64-unknown-linux-gnu
os: ubuntu-24.04
- triple: linux-arm64
target: aarch64-unknown-linux-gnu
os: ubuntu-24.04-arm
- triple: darwin-arm64
target: aarch64-apple-darwin
os: macos-14
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
# rust-toolchain.toml pins a specific channel (currently 1.91), so
# cargo ignores whatever `targets` dtolnay installed onto `stable` and
# uses the pinned toolchain instead. Add the target to that pinned
# toolchain explicitly so macOS + linux-arm64 cross-arch builds find
# `core`.
- name: Install target for pinned toolchain
run: rustup target add ${{ matrix.target }}
# The hoangsa-ui-server crate embeds crates/hoangsa-ui-web/dist/ via
# rust-embed at compile time. dist/ is gitignored, so build the SPA
# here before cargo runs — otherwise the embedded asset set is empty
# and the UI binary serves the placeholder page.
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: "22"
cache: "npm"
cache-dependency-path: crates/hoangsa-ui-web/package-lock.json
- name: Build SPA
working-directory: crates/hoangsa-ui-web
run: |
npm ci
npm run build
- name: Build binaries
shell: bash
run: |
cargo build --release --locked --target ${{ matrix.target }} \
-p hoangsa-cli -p hoangsa-memory -p hoangsa-memory-mcp \
-p hoangsa-proxy -p hoangsa-ui-server
- name: Stage binaries
shell: bash
run: |
set -euo pipefail
mkdir -p stage/bin
cp target/${{ matrix.target }}/release/hoangsa-cli stage/bin/
cp target/${{ matrix.target }}/release/hoangsa-memory stage/bin/
cp target/${{ matrix.target }}/release/hoangsa-memory-mcp stage/bin/
cp target/${{ matrix.target }}/release/hoangsa-ui stage/bin/
cp target/${{ matrix.target }}/release/hsp stage/bin/
chmod +x stage/bin/*
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: hoangsa-${{ matrix.triple }}
path: stage/bin/
retention-days: 1
assemble-release:
name: Assemble release tarballs
needs: [build]
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Assemble per-triple tarballs
shell: bash
run: |
set -euo pipefail
mkdir -p dist
# Bundle scripts/lib/ui.sh into dist/install.sh so the curl|sh
# endpoint stays a single self-contained file. The awk pass
# strips the runtime source line from the script body.
cat scripts/lib/ui.sh > dist/install.sh
awk '!/^\. "\$\(dirname "\$0"\)\/lib\/ui\.sh"$/' \
scripts/install.sh >> dist/install.sh
chmod 0755 dist/install.sh
sh -n dist/install.sh
for triple in darwin-arm64 linux-x64 linux-arm64; do
stage="stage/$triple"
mkdir -p "$stage/bin"
cp "artifacts/hoangsa-$triple/hoangsa-cli" "$stage/bin/hoangsa-cli"
cp "artifacts/hoangsa-$triple/hoangsa-memory" "$stage/bin/hoangsa-memory"
cp "artifacts/hoangsa-$triple/hoangsa-memory-mcp" "$stage/bin/hoangsa-memory-mcp"
cp "artifacts/hoangsa-$triple/hoangsa-ui" "$stage/bin/hoangsa-ui"
cp "artifacts/hoangsa-$triple/hsp" "$stage/bin/hsp"
chmod +x "$stage"/bin/*
cp -r templates "$stage/templates"
[ -f LICENSE ] && cp LICENSE "$stage/LICENSE"
[ -f VERSION ] && cp VERSION "$stage/VERSION"
tar --transform "s,^\./,hoangsa-$triple/," -C "$stage" -czf "dist/hoangsa-$triple.tar.gz" .
done
- name: Compute SHA256SUMS
shell: bash
working-directory: dist
run: |
set -euo pipefail
sha256sum hoangsa-*.tar.gz install.sh > SHA256SUMS
cat SHA256SUMS
- name: Upload to GitHub Release
shell: bash
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
set -euo pipefail
gh release view "${GITHUB_REF_NAME}" >/dev/null 2>&1 \
|| gh release create "${GITHUB_REF_NAME}" --generate-notes --verify-tag
gh release upload "${GITHUB_REF_NAME}" \
dist/hoangsa-*.tar.gz \
dist/install.sh \
dist/SHA256SUMS \
--clobber