Skip to content

Commit cb10d37

Browse files
committed
Add GitHub Actions workflow for building and packaging release binaries
1 parent 963b78d commit cb10d37

File tree

1 file changed

+113
-0
lines changed

1 file changed

+113
-0
lines changed

.github/workflows/release.yml

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
name: release-binaries
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
permissions:
8+
contents: write
9+
10+
jobs:
11+
build:
12+
name: Build ${{ matrix.target }}
13+
runs-on: ${{ matrix.os }}
14+
strategy:
15+
fail-fast: false
16+
matrix:
17+
include:
18+
# Linux
19+
- os: ubuntu-latest
20+
target: x86_64-unknown-linux-gnu
21+
artifact_name: resonix-node-${{ github.ref_name }}-linux-x86_64.tar.gz
22+
archive_ext: tar.gz
23+
- os: ubuntu-latest
24+
target: aarch64-unknown-linux-gnu
25+
artifact_name: resonix-node-${{ github.ref_name }}-linux-aarch64.tar.gz
26+
archive_ext: tar.gz
27+
# Windows
28+
- os: windows-latest
29+
target: x86_64-pc-windows-msvc
30+
artifact_name: resonix-node-${{ github.ref_name }}-windows-x86_64.zip
31+
archive_ext: zip
32+
- os: windows-latest
33+
target: aarch64-pc-windows-msvc
34+
artifact_name: resonix-node-${{ github.ref_name }}-windows-aarch64.zip
35+
archive_ext: zip
36+
# macOS (arm64 + Intel)
37+
- os: macos-latest
38+
target: aarch64-apple-darwin
39+
artifact_name: resonix-node-${{ github.ref_name }}-macos-aarch64.tar.gz
40+
archive_ext: tar.gz
41+
- os: macos-13
42+
target: x86_64-apple-darwin
43+
artifact_name: resonix-node-${{ github.ref_name }}-macos-x86_64.tar.gz
44+
archive_ext: tar.gz
45+
46+
steps:
47+
- name: Checkout
48+
uses: actions/checkout@v4
49+
with:
50+
fetch-depth: 0
51+
52+
- name: Install Rust toolchain
53+
uses: dtolnay/rust-toolchain@stable
54+
with:
55+
targets: ${{ matrix.target }}
56+
57+
- name: Install Linux aarch64 cross toolchain
58+
if: ${{ matrix.target == 'aarch64-unknown-linux-gnu' }}
59+
run: |
60+
sudo apt-get update
61+
sudo apt-get install -y gcc-aarch64-linux-gnu
62+
shell: bash
63+
64+
- name: Build
65+
run: |
66+
echo "Building target ${{ matrix.target }}"
67+
if [[ "${{ matrix.target }}" == "aarch64-unknown-linux-gnu" ]]; then
68+
export CC_aarch64_unknown_linux_gnu=aarch64-linux-gnu-gcc
69+
export AR_aarch64_unknown_linux_gnu=aarch64-linux-gnu-ar
70+
export CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc
71+
fi
72+
cargo build --release --target ${{ matrix.target }}
73+
shell: bash
74+
75+
- name: Package (Unix)
76+
if: ${{ matrix.archive_ext == 'tar.gz' }}
77+
run: |
78+
set -euxo pipefail
79+
BIN_NAME=resonix-node
80+
TARGET_DIR=target/${{ matrix.target }}/release
81+
mkdir -p dist
82+
cp "$TARGET_DIR/$BIN_NAME" dist/
83+
tar -C dist -czf "${{ matrix.artifact_name }}" "$BIN_NAME"
84+
if command -v sha256sum >/dev/null 2>&1; then
85+
sha256sum "${{ matrix.artifact_name }}" > "${{ matrix.artifact_name }}.sha256"
86+
else
87+
shasum -a 256 "${{ matrix.artifact_name }}" | awk '{print $1 " " $2}' > "${{ matrix.artifact_name }}.sha256"
88+
fi
89+
shell: bash
90+
91+
- name: Package (Windows)
92+
if: ${{ matrix.archive_ext == 'zip' }}
93+
run: |
94+
$ErrorActionPreference = 'Stop'
95+
$binName = 'resonix-node.exe'
96+
$targetDir = "target/${{ matrix.target }}/release"
97+
New-Item -ItemType Directory -Force -Path dist | Out-Null
98+
Copy-Item -Path "$targetDir/$binName" -Destination dist/
99+
$artifact = "${{ matrix.artifact_name }}"
100+
Compress-Archive -Path "dist/$binName" -DestinationPath $artifact -Force
101+
# Compute SHA256
102+
$hash = Get-FileHash -Algorithm SHA256 $artifact
103+
Set-Content -NoNewline -Path "$artifact.sha256" -Value ("$($hash.Hash) $artifact")
104+
shell: pwsh
105+
106+
- name: Upload to GitHub Release
107+
uses: softprops/action-gh-release@v2
108+
with:
109+
files: |
110+
${{ matrix.artifact_name }}
111+
${{ matrix.artifact_name }}.sha256
112+
env:
113+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)