-
Notifications
You must be signed in to change notification settings - Fork 43
105 lines (92 loc) · 3.4 KB
/
build-broker-binary.yml
File metadata and controls
105 lines (92 loc) · 3.4 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
name: Build Broker Binary
on:
push:
branches: [main]
paths:
- 'src/**'
- 'Cargo.toml'
- 'Cargo.lock'
- '.github/workflows/build-broker-binary.yml'
workflow_dispatch:
inputs:
tag:
description: 'Release tag (e.g. v3.0.0, latest)'
required: false
default: 'latest'
type: string
jobs:
build:
name: Build (${{ matrix.target }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-musl
artifact: agent-relay-broker-linux-x86_64
- os: ubuntu-latest
target: aarch64-unknown-linux-musl
artifact: agent-relay-broker-linux-aarch64
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- uses: Swatinem/rust-cache@v2
with:
key: ${{ matrix.target }}
- name: Install musl tools (x86_64)
if: matrix.target == 'x86_64-unknown-linux-musl'
run: |
sudo apt-get update
sudo apt-get install -y musl-tools
- name: Install cross and strip tools (aarch64)
if: matrix.target == 'aarch64-unknown-linux-musl'
run: sudo apt-get update && sudo apt-get install -y binutils-aarch64-linux-gnu
- name: Install cross (aarch64)
if: matrix.target == 'aarch64-unknown-linux-musl'
uses: taiki-e/install-action@cross
- name: Build static binary
run: |
if [[ "${{ matrix.target }}" == "aarch64-unknown-linux-musl" ]]; then
RUSTFLAGS="-C target-feature=+crt-static" cross build --release --target ${{ matrix.target }} --bin agent-relay-broker
aarch64-linux-gnu-strip target/${{ matrix.target }}/release/agent-relay-broker 2>/dev/null || true
else
RUSTFLAGS="-C target-feature=+crt-static" cargo build --release --target ${{ matrix.target }} --bin agent-relay-broker
strip target/${{ matrix.target }}/release/agent-relay-broker 2>/dev/null || true
fi
- name: Verify static linking
run: |
file target/${{ matrix.target }}/release/agent-relay-broker
# Ensure no dynamic glibc dependency
ldd target/${{ matrix.target }}/release/agent-relay-broker 2>&1 | grep -q "not a dynamic" || \
echo "Warning: binary may have dynamic dependencies"
- name: Rename artifact
run: cp target/${{ matrix.target }}/release/agent-relay-broker ${{ matrix.artifact }}
- uses: actions/upload-artifact@v4
with:
name: ${{ matrix.artifact }}
path: ${{ matrix.artifact }}
release:
name: Upload to Release
needs: build
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/download-artifact@v4
with:
path: artifacts
merge-multiple: true
- name: Create or update release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ inputs.tag || 'latest' }}
name: Broker Binary ${{ inputs.tag || 'latest' }}
body: |
Statically-linked broker binaries (musl, no glibc dependency).
Built from commit ${{ github.sha }}.
files: artifacts/*
prerelease: ${{ inputs.tag == '' || inputs.tag == 'latest' }}
make_latest: false