This repository was archived by the owner on Dec 15, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
152 lines (136 loc) · 5.52 KB
/
release.yaml
File metadata and controls
152 lines (136 loc) · 5.52 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
on:
push:
tags:
- "v*"
name: Create Release
jobs:
build:
name: Build and Release
runs-on: ${{ matrix.os }}
permissions:
contents: write
strategy:
fail-fast: false
matrix:
include:
# Linux builds
- os: ubuntu-latest
target: x86_64-unknown-linux-musl
binary_name: zinit-linux-x86_64
- os: ubuntu-latest
target: aarch64-unknown-linux-musl
binary_name: zinit-linux-aarch64
# macOS builds
- os: macos-latest
target: x86_64-apple-darwin
binary_name: zinit-macos-x86_64
- os: macos-latest
target: aarch64-apple-darwin
binary_name: zinit-macos-aarch64
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Cache Rust dependencies
uses: actions/cache@v3
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-${{ matrix.target }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-${{ matrix.target }}-cargo-
- name: Setup build environment (macOS)
if: matrix.os == 'macos-latest'
run: |
brew install llvm
if [[ "${{ matrix.target }}" == "aarch64-apple-darwin" ]]; then
rustup target add aarch64-apple-darwin
fi
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
target: ${{ matrix.target }}
override: true
profile: minimal
- name: Install MUSL tools (Linux)
if: matrix.os == 'ubuntu-latest'
run: |
sudo apt-get update
sudo apt-get install -y musl-tools musl-dev
# Install required Rust targets
if [[ "${{ matrix.target }}" == "aarch64-unknown-linux-musl" ]]; then
rustup target add aarch64-unknown-linux-musl
fi
if [[ "${{ matrix.target }}" == "x86_64-unknown-linux-musl" ]]; then
rustup target add x86_64-unknown-linux-musl
fi
- name: Setup aarch64 MUSL cross toolchain
if: matrix.os == 'ubuntu-latest' && matrix.target == 'aarch64-unknown-linux-musl'
uses: taiki-e/setup-cross-toolchain@v1
with:
target: aarch64-unknown-linux-musl
- name: Build release
env:
CC: ${{ matrix.os == 'macos-latest' && 'clang' || '' }}
CXX: ${{ matrix.os == 'macos-latest' && 'clang++' || '' }}
MACOSX_DEPLOYMENT_TARGET: '10.12'
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_MUSL_LINKER: ${{ matrix.target == 'aarch64-unknown-linux-musl' && 'aarch64-linux-musl-gcc' || '' }}
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_MUSL_AR: ${{ matrix.target == 'aarch64-unknown-linux-musl' && 'aarch64-linux-musl-ar' || '' }}
CC_aarch64_unknown_linux_musl: ${{ matrix.target == 'aarch64-unknown-linux-musl' && 'aarch64-linux-musl-gcc' || '' }}
run: |
if [[ "${{ matrix.target }}" == "aarch64-apple-darwin" ]]; then
export RUSTFLAGS="-C target-feature=+crt-static"
fi
cargo build --release --target=${{ matrix.target }} --verbose
if [ ! -f "target/${{ matrix.target }}/release/zinit" ]; then
echo "::error::Binary not found at target/${{ matrix.target }}/release/zinit"
exit 1
fi
- name: Strip binary (Linux)
if: matrix.os == 'ubuntu-latest'
run: |
# Use cross-toolchain strip if available (provided by taiki-e/setup-cross-toolchain)
if [[ -n "${STRIP:-}" ]]; then
"$STRIP" "target/${{ matrix.target }}/release/zinit" || true
# For aarch64-musl, prefer the target-specific strip if present
elif [[ "${{ matrix.target }}" == "aarch64-unknown-linux-musl" ]] && command -v aarch64-unknown-linux-musl-strip >/dev/null 2>&1; then
aarch64-unknown-linux-musl-strip "target/${{ matrix.target }}/release/zinit" || true
# Fall back to llvm-strip if installed, else to system strip
elif command -v llvm-strip >/dev/null 2>&1; then
llvm-strip "target/${{ matrix.target }}/release/zinit" || strip "target/${{ matrix.target }}/release/zinit" || true
else
strip "target/${{ matrix.target }}/release/zinit" || true
fi
- name: Strip binary (macOS)
if: matrix.os == 'macos-latest'
run: |
strip -x target/${{ matrix.target }}/release/zinit || true
- name: Rename binary
run: |
cp target/${{ matrix.target }}/release/zinit ${{ matrix.binary_name }}
if [ ! -f "${{ matrix.binary_name }}" ]; then
echo "::error::Binary not copied successfully to ${{ matrix.binary_name }}"
exit 1
fi
ls -la ${{ matrix.binary_name }}
file ${{ matrix.binary_name }} || true
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.binary_name }}
path: ${{ matrix.binary_name }}
retention-days: 5
- name: Upload Release Assets
uses: softprops/action-gh-release@v2
with:
files: ${{ matrix.binary_name }}
name: Release ${{ github.ref_name }}
draft: false
prerelease: false
fail_on_unmatched_files: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}