Skip to content

release-binaries

release-binaries #8

Workflow file for this run

name: release-binaries
on:
release:
types: [published]
permissions:
contents: write
jobs:
build:
name: Build ${{ matrix.target }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
# Linux
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
artifact_name: resonix-node-${{ github.ref_name }}-linux-x86_64.tar.gz
archive_ext: tar.gz
- os: ubuntu-latest
target: aarch64-unknown-linux-gnu
artifact_name: resonix-node-${{ github.ref_name }}-linux-aarch64.tar.gz
archive_ext: tar.gz
- os: ubuntu-latest
target: armv7-unknown-linux-gnueabihf
artifact_name: resonix-node-${{ github.ref_name }}-linux-armv7.tar.gz
archive_ext: tar.gz
# Windows
- os: windows-latest
target: x86_64-pc-windows-msvc
artifact_name: resonix-node-${{ github.ref_name }}-windows-x86_64.zip
archive_ext: zip
- os: windows-latest
target: aarch64-pc-windows-msvc
artifact_name: resonix-node-${{ github.ref_name }}-windows-aarch64.zip
archive_ext: zip
# macOS (arm64 + Intel)
- os: macos-latest
target: aarch64-apple-darwin
artifact_name: resonix-node-${{ github.ref_name }}-macos-aarch64.tar.gz
archive_ext: tar.gz
- os: macos-13
target: x86_64-apple-darwin
artifact_name: resonix-node-${{ github.ref_name }}-macos-x86_64.tar.gz
archive_ext: tar.gz
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Install Linux aarch64 cross toolchain
if: ${{ matrix.target == 'aarch64-unknown-linux-gnu' }}
run: |
sudo dpkg --add-architecture arm64
sudo apt-get update
# Install the cross toolchain plus the target OpenSSL dev files so openssl-sys can link
sudo apt-get install -y gcc-aarch64-linux-gnu pkg-config libssl-dev:arm64
shell: bash
- name: Install Linux armv7 cross toolchain
if: ${{ matrix.target == 'armv7-unknown-linux-gnueabihf' }}
run: |
sudo dpkg --add-architecture armhf
sudo apt-get update
# Provide armv7 toolchain and OpenSSL dev headers/libs for the cross build
sudo apt-get install -y gcc-arm-linux-gnueabihf pkg-config libssl-dev:armhf
shell: bash
- name: Build
run: |
echo "Building target ${{ matrix.target }}"
if [[ "${{ matrix.target }}" == "aarch64-unknown-linux-gnu" ]]; then
export CC_aarch64_unknown_linux_gnu=aarch64-linux-gnu-gcc
export AR_aarch64_unknown_linux_gnu=aarch64-linux-gnu-ar
export CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc
export PKG_CONFIG_ALLOW_CROSS=1
export PKG_CONFIG_PATH="/usr/lib/aarch64-linux-gnu/pkgconfig:${PKG_CONFIG_PATH:-}"
export OPENSSL_LIB_DIR=/usr/lib/aarch64-linux-gnu
export OPENSSL_INCLUDE_DIR=/usr/include/aarch64-linux-gnu
fi
if [[ "${{ matrix.target }}" == "armv7-unknown-linux-gnueabihf" ]]; then
export CC_armv7_unknown_linux_gnueabihf=arm-linux-gnueabihf-gcc
export AR_armv7_unknown_linux_gnueabihf=arm-linux-gnueabihf-ar
export CARGO_TARGET_ARMV7_UNKNOWN_LINUX_GNUEABIHF_LINKER=arm-linux-gnueabihf-gcc
export PKG_CONFIG_ALLOW_CROSS=1
export PKG_CONFIG_PATH="/usr/lib/arm-linux-gnueabihf/pkgconfig:${PKG_CONFIG_PATH:-}"
export OPENSSL_LIB_DIR=/usr/lib/arm-linux-gnueabihf
export OPENSSL_INCLUDE_DIR=/usr/include/arm-linux-gnueabihf
fi
cargo build --release --target ${{ matrix.target }}
shell: bash
- name: Package (Unix)
if: ${{ matrix.archive_ext == 'tar.gz' }}
run: |
set -euxo pipefail
BIN_NAME=resonix-node
TARGET_DIR=target/${{ matrix.target }}/release
mkdir -p dist
cp "$TARGET_DIR/$BIN_NAME" dist/
tar -C dist -czf "${{ matrix.artifact_name }}" "$BIN_NAME"
if command -v sha256sum >/dev/null 2>&1; then
sha256sum "${{ matrix.artifact_name }}" > "${{ matrix.artifact_name }}.sha256"
else
shasum -a 256 "${{ matrix.artifact_name }}" | awk '{print $1 " " $2}' > "${{ matrix.artifact_name }}.sha256"
fi
shell: bash
- name: Package (Windows)
if: ${{ matrix.archive_ext == 'zip' }}
run: |
$ErrorActionPreference = 'Stop'
$binName = 'resonix-node.exe'
$targetDir = "target/${{ matrix.target }}/release"
New-Item -ItemType Directory -Force -Path dist | Out-Null
Copy-Item -Path "$targetDir/$binName" -Destination dist/
$artifact = "${{ matrix.artifact_name }}"
Compress-Archive -Path "dist/$binName" -DestinationPath $artifact -Force
# Compute SHA256
$hash = Get-FileHash -Algorithm SHA256 $artifact
Set-Content -NoNewline -Path "$artifact.sha256" -Value ("$($hash.Hash) $artifact")
shell: pwsh
- name: Upload to GitHub Release
uses: softprops/action-gh-release@v2
with:
files: |
${{ matrix.artifact_name }}
${{ matrix.artifact_name }}.sha256
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}