-
Notifications
You must be signed in to change notification settings - Fork 13
151 lines (132 loc) · 4.83 KB
/
release.yml
File metadata and controls
151 lines (132 loc) · 4.83 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
name: Release
on:
push:
tags:
- 'v*'
permissions:
contents: write
jobs:
build:
strategy:
matrix:
include:
- target: x86_64-unknown-linux-musl
os: ubuntu-latest
artifact: fintool-linux-x86_64
- target: aarch64-unknown-linux-musl
os: ubuntu-latest
artifact: fintool-linux-aarch64
- target: aarch64-apple-darwin
os: macos-latest
artifact: fintool-macos-aarch64
- target: x86_64-pc-windows-gnu
os: ubuntu-latest
artifact: fintool-windows-x86_64.exe
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Install musl tools (Linux x86_64)
if: matrix.target == 'x86_64-unknown-linux-musl'
run: sudo apt-get update && sudo apt-get install -y musl-tools perl make
- name: Install cross-compilation tools (Linux aarch64)
if: matrix.target == 'aarch64-unknown-linux-musl'
run: |
sudo apt-get update && sudo apt-get install -y musl-tools perl make
cargo install cross --git https://github.com/cross-rs/cross
- name: Install MinGW (Windows cross-compile)
if: matrix.target == 'x86_64-pc-windows-gnu'
run: sudo apt-get update && sudo apt-get install -y mingw-w64 perl make
- name: Cache cargo
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-${{ matrix.target }}-cargo-${{ hashFiles('**/Cargo.toml') }}
- name: Build (cross - Linux aarch64)
if: matrix.target == 'aarch64-unknown-linux-musl'
run: cross build --release --target ${{ matrix.target }}
env:
CROSS_CONTAINER_OPTS: "--platform linux/amd64"
- name: Build (native)
if: matrix.target != 'aarch64-unknown-linux-musl'
run: cargo build --release --target ${{ matrix.target }}
env:
# Static linking for musl targets is automatic
# For Windows GNU, link statically
RUSTFLAGS: ${{ matrix.target == 'x86_64-pc-windows-gnu' && '-C target-feature=+crt-static' || '' }}
- name: Verify static linking
run: |
bin="target/${{ matrix.target }}/release/fintool"
if [[ "${{ matrix.target }}" == *"windows"* ]]; then
bin="${bin}.exe"
fi
echo "=== Binary info ==="
file "$bin"
if [[ "${{ matrix.target }}" == *"linux-musl"* ]]; then
# musl binaries should be statically linked
if ldd "$bin" 2>&1 | grep -q "not a dynamic executable\|statically linked"; then
echo "✅ Static binary confirmed"
else
echo "❌ Binary is dynamically linked!"
ldd "$bin"
exit 1
fi
elif [[ "${{ matrix.target }}" == *"apple-darwin"* ]]; then
# macOS: check no non-system dylibs
echo "Dynamic libraries:"
otool -L "$bin" || true
elif [[ "${{ matrix.target }}" == *"windows"* ]]; then
echo "Windows binary — static check via file output above"
fi
- name: Package zip
run: |
dir="${{ matrix.artifact }}"
mkdir -p "$dir"
src="target/${{ matrix.target }}/release/fintool"
if [[ "${{ matrix.target }}" == *"windows"* ]]; then
cp "${src}.exe" "$dir/fintool.exe"
else
cp "$src" "$dir/fintool"
chmod +x "$dir/fintool"
fi
cp config.toml.default "$dir/"
zip -r "${{ matrix.artifact }}.zip" "$dir"
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.artifact }}
path: ${{ matrix.artifact }}.zip
release:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Create checksums
run: |
cd artifacts
for dir in */; do
for file in "$dir"*.zip; do
sha256sum "$file" >> ../checksums.txt
done
done
cat ../checksums.txt
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
generate_release_notes: true
files: |
artifacts/fintool-linux-x86_64/fintool-linux-x86_64.zip
artifacts/fintool-linux-aarch64/fintool-linux-aarch64.zip
artifacts/fintool-macos-aarch64/fintool-macos-aarch64.zip
artifacts/fintool-windows-x86_64.exe/fintool-windows-x86_64.exe.zip
checksums.txt