Skip to content

Commit a01d698

Browse files
committed
feat: add CI release workflow with prebuilt binaries
- Add GitHub Actions workflow for cross-compilation (macOS arm64/x86_64, Linux x86_64/arm64) - Add setup-workspace.sh to replace path deps with crates.io versions in CI - Bump version to v0.5.0
1 parent dcb0628 commit a01d698

4 files changed

Lines changed: 136 additions & 2 deletions

File tree

‎.github/setup-workspace.sh‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/bin/bash
2+
# Setup for building the Code crate standalone in CI.
3+
# Replaces path dependencies with crates.io versions so we don't need
4+
# the full monorepo workspace.
5+
6+
set -euo pipefail
7+
8+
echo "Replacing path dependencies with crates.io versions..."
9+
10+
# Replace path deps with registry versions in Cargo.toml
11+
sed -i.bak \
12+
-e 's|a3s-tools-core = { version = "0.1", path = "../tools-core" }|a3s-tools-core = "0.1"|' \
13+
-e 's|a3s-lane = { version = "0.1", path = "../lane" }|a3s-lane = "0.1"|' \
14+
-e 's|a3s-cron = { version = "0.1", path = "../cron" }|a3s-cron = "0.1"|' \
15+
-e 's|a3s-privacy = { version = "0.1", path = "../privacy" }|a3s-privacy = "0.1"|' \
16+
-e 's|a3s-updater = { version = "0.2", path = "../updater" }|a3s-updater = "0.2"|' \
17+
Cargo.toml
18+
19+
rm -f Cargo.toml.bak
20+
21+
echo "Path dependencies replaced. Ready to build."

‎.github/workflows/release.yml‎

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*"
7+
8+
permissions:
9+
contents: write
10+
11+
jobs:
12+
build:
13+
strategy:
14+
fail-fast: false
15+
matrix:
16+
include:
17+
- target: aarch64-apple-darwin
18+
os: macos-latest
19+
name: darwin-arm64
20+
- target: x86_64-apple-darwin
21+
os: macos-latest
22+
name: darwin-x86_64
23+
- target: x86_64-unknown-linux-gnu
24+
os: ubuntu-latest
25+
name: linux-x86_64
26+
- target: aarch64-unknown-linux-gnu
27+
os: ubuntu-latest
28+
name: linux-arm64
29+
cross: true
30+
31+
name: Build ${{ matrix.name }}
32+
runs-on: ${{ matrix.os }}
33+
34+
steps:
35+
- uses: actions/checkout@v4
36+
37+
- name: Setup workspace
38+
run: bash .github/setup-workspace.sh
39+
40+
- name: Install Rust
41+
uses: dtolnay/rust-toolchain@stable
42+
with:
43+
targets: ${{ matrix.target }}
44+
45+
- name: Install protobuf compiler
46+
shell: bash
47+
run: |
48+
if [ "${{ matrix.os }}" = "ubuntu-latest" ]; then
49+
sudo apt-get update && sudo apt-get install -y protobuf-compiler
50+
else
51+
brew install protobuf
52+
fi
53+
54+
- name: Install cross-compilation tools
55+
if: matrix.cross
56+
run: |
57+
sudo apt-get update
58+
sudo apt-get install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu
59+
echo "CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc" >> $GITHUB_ENV
60+
61+
- name: Build
62+
run: cargo build --release --target ${{ matrix.target }} --bin a3s-code
63+
64+
- name: Strip binary
65+
shell: bash
66+
run: |
67+
BINARY="target/${{ matrix.target }}/release/a3s-code"
68+
if [ "${{ matrix.cross }}" = "true" ]; then
69+
aarch64-linux-gnu-strip "$BINARY" || true
70+
else
71+
strip "$BINARY" || true
72+
fi
73+
74+
- name: Package
75+
shell: bash
76+
run: |
77+
VERSION="${GITHUB_REF#refs/tags/v}"
78+
ARCHIVE="a3s-code-${VERSION}-${{ matrix.name }}.tar.gz"
79+
tar -czf "$ARCHIVE" -C "target/${{ matrix.target }}/release" a3s-code
80+
echo "ARCHIVE=$ARCHIVE" >> $GITHUB_ENV
81+
82+
- name: Upload artifact
83+
uses: actions/upload-artifact@v4
84+
with:
85+
name: a3s-code-${{ matrix.name }}
86+
path: ${{ env.ARCHIVE }}
87+
88+
release:
89+
name: Create Release
90+
runs-on: ubuntu-latest
91+
needs: build
92+
steps:
93+
- uses: actions/checkout@v4
94+
95+
- name: Download all artifacts
96+
uses: actions/download-artifact@v4
97+
with:
98+
path: artifacts
99+
merge-multiple: true
100+
101+
- name: Generate checksums
102+
run: |
103+
cd artifacts
104+
sha256sum *.tar.gz > checksums.txt
105+
cat checksums.txt
106+
107+
- name: Create GitHub Release
108+
uses: softprops/action-gh-release@v2
109+
with:
110+
generate_release_notes: true
111+
files: |
112+
artifacts/*.tar.gz
113+
artifacts/checksums.txt

‎Cargo.lock‎

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎Cargo.toml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "a3s-code"
3-
version = "0.4.7"
3+
version = "0.5.0"
44
edition = "2021"
55
authors = ["A3S Lab Team"]
66
license = "MIT"

0 commit comments

Comments
 (0)