Repository navigation
128 lines (111 loc) · 4.26 KB
/
Copy pathrelease.yml
File metadata and controls
128 lines (111 loc) · 4.26 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
name: Release
# Builds release binaries for all supported platforms.
# Runs automatically on version tags; can be run manually
# (workflow_dispatch) to verify the pipeline without tagging.
on:
push:
tags: ['v*']
workflow_dispatch:
permissions:
contents: write
env:
CARGO_TERM_COLOR: always
jobs:
build:
name: ${{ matrix.name }}
runs-on: ${{ matrix.runner }}
strategy:
fail-fast: false
matrix:
include:
- name: windows-x64
runner: windows-latest
bin: target/dist/ghostpp-rs.exe
bin_name: ghostpp-rs.exe
artifact: ghostpp-rs-windows-x64.tar.gz
- name: macos-arm64
runner: macos-latest
bin: target/dist/ghostpp-rs
bin_name: ghostpp-rs
artifact: ghostpp-rs-macos-arm64.tar.gz
- name: linux-x64
runner: ubuntu-latest
bin: target/dist/ghostpp-rs
bin_name: ghostpp-rs
artifact: ghostpp-rs-linux-x64.tar.gz
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Install zlib/bzip2 dev libraries (Linux)
if: runner.os == 'Linux'
run: sudo apt-get update && sudo apt-get install -y zlib1g-dev libbz2-dev
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
# The `dist` profile strips debug info/symbols for the smallest download
- name: Build
run: cargo build --profile dist --locked
- name: Package (tar.gz)
shell: bash
run: |
cp "${{ matrix.bin }}" "${{ matrix.bin_name }}"
tar -czf "${{ matrix.artifact }}" "${{ matrix.bin_name }}"
- uses: actions/upload-artifact@v4
with:
name: ${{ matrix.artifact }}
path: ${{ matrix.artifact }}
if-no-files-found: error
- name: Attach to release
if: startsWith(github.ref, 'refs/tags/')
uses: softprops/action-gh-release@v2
with:
files: ${{ matrix.artifact }}
# ARM64 musl: produces a fully static binary with no runtime dependencies,
# so it runs on any ARM64 Linux distribution. The Alpine container is only
# the build environment — it provides a complete musl C/C++ toolchain and
# musl-built static zlib/bzip2 out of the box.
#
# The build runs via `docker run` instead of a job-level `container:`
# because JavaScript actions (checkout, upload-artifact, ...) are not
# supported inside Alpine containers on ARM64 runners — so those steps
# run on the host and only the compile happens inside the container.
build-linux-arm64-musl:
name: linux-arm64-musl (static)
runs-on: ubuntu-24.04-arm
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
# +crt-static makes the binary fully static. The explicit --target is
# required even though it equals the host triple: it stops cargo from
# applying RUSTFLAGS to proc-macros, which cannot be built with a
# static CRT.
- name: Build static musl binary in Alpine container
run: |
docker run --rm -v "$PWD:/work" -w /work \
-e RUSTFLAGS="-C target-feature=+crt-static" \
rust:alpine sh -ec '
apk add --no-cache build-base cmake zlib-dev zlib-static bzip2-dev bzip2-static
cargo build --profile dist --locked --target aarch64-unknown-linux-musl
'
- name: Verify binary is fully static
run: |
if readelf -d target/aarch64-unknown-linux-musl/dist/ghostpp-rs | grep -q NEEDED; then
echo "::error::Binary has dynamic library dependencies — not fully static"
exit 1
fi
echo "OK: no dynamic dependencies"
- name: Package (tar.gz)
run: |
cp target/aarch64-unknown-linux-musl/dist/ghostpp-rs ghostpp-rs
tar -czf ghostpp-rs-linux-arm64-musl.tar.gz ghostpp-rs
- uses: actions/upload-artifact@v4
with:
name: ghostpp-rs-linux-arm64-musl.tar.gz
path: ghostpp-rs-linux-arm64-musl.tar.gz
if-no-files-found: error
- name: Attach to release
if: startsWith(github.ref, 'refs/tags/')
uses: softprops/action-gh-release@v2
with:
files: ghostpp-rs-linux-arm64-musl.tar.gz