-
-
Notifications
You must be signed in to change notification settings - Fork 8
102 lines (90 loc) · 3.71 KB
/
release.yml
File metadata and controls
102 lines (90 loc) · 3.71 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
name: Release
on:
release:
types: [published]
permissions:
contents: write
jobs:
build-and-upload:
name: Build and Upload Release Assets
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
# Linux builds use musl for universal compatibility (no GLIBC dependency)
- os: ubuntu-latest
target: x86_64-unknown-linux-musl
binary_name: dotstate
asset_name: dotstate-x86_64-unknown-linux-musl
use_cross: true
- os: ubuntu-latest
target: aarch64-unknown-linux-musl
binary_name: dotstate
asset_name: dotstate-aarch64-unknown-linux-musl
use_cross: true
# macOS builds use native toolchain
- os: macos-latest
target: x86_64-apple-darwin
binary_name: dotstate
asset_name: dotstate-x86_64-apple-darwin
use_cross: false
- os: macos-latest
target: aarch64-apple-darwin
binary_name: dotstate
asset_name: dotstate-aarch64-apple-darwin
use_cross: false
steps:
- uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Cache Cargo dependencies
uses: swatinem/rust-cache@v2
with:
workspaces: '.'
# Linux builds use cross for musl static linking
- name: Install cross
if: matrix.use_cross
run: cargo install cross --git https://github.com/cross-rs/cross
- name: Build with cross (Linux musl)
if: matrix.use_cross
run: cross build --release --target ${{ matrix.target }}
# macOS builds use native cargo
- name: Build with cargo (macOS)
if: "!matrix.use_cross"
run: cargo build --release --target ${{ matrix.target }}
- name: Create archive
run: |
cd target/${{ matrix.target }}/release
tar czf ${{ github.workspace }}/${{ matrix.asset_name }}.tar.gz ${{ matrix.binary_name }}
cd ${{ github.workspace }}
shasum -a 256 ${{ matrix.asset_name }}.tar.gz | awk '{print $1}' > ${{ matrix.asset_name }}.tar.gz.sha256
ls -lh ${{ matrix.asset_name }}.tar.gz ${{ matrix.asset_name }}.tar.gz.sha256
- name: Verify files exist
run: |
echo "Checking for files in ${{ github.workspace }}:"
ls -la ${{ github.workspace }}/${{ matrix.asset_name }}.tar.gz || echo "❌ Archive not found"
ls -la ${{ github.workspace }}/${{ matrix.asset_name }}.tar.gz.sha256 || echo "❌ Checksum not found"
- name: Verify binary is statically linked (Linux)
if: matrix.use_cross
run: |
echo "Checking binary type..."
file target/${{ matrix.target }}/release/${{ matrix.binary_name }}
echo ""
echo "Checking for dynamic dependencies..."
# musl binaries should show "statically linked" or have no dynamic deps
if ldd target/${{ matrix.target }}/release/${{ matrix.binary_name }} 2>&1 | grep -q "not a dynamic executable"; then
echo "✅ Binary is statically linked (no dynamic dependencies)"
else
echo "⚠️ Binary may have dynamic dependencies (this is OK for some musl builds)"
ldd target/${{ matrix.target }}/release/${{ matrix.binary_name }} || true
fi
- name: Upload to release
uses: softprops/action-gh-release@v1
with:
files: |
${{ github.workspace }}/${{ matrix.asset_name }}.tar.gz
${{ github.workspace }}/${{ matrix.asset_name }}.tar.gz.sha256
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}