Skip to content

Build Release Binaries #2

Build Release Binaries

Build Release Binaries #2

Workflow file for this run

name: Build Release Binaries
on:
push:
branches: [main]
paths:
- 'Cargo.toml'
- 'src/**'
- '.github/workflows/release.yml'
workflow_dispatch:
jobs:
build:
strategy:
matrix:
include:
- target: x86_64-unknown-linux-musl
arch: x86_64
runner: ubuntu-latest
- target: aarch64-unknown-linux-musl
arch: aarch64
runner: ubuntu-latest
runs-on: ${{ matrix.runner }}
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Install cross
run: cargo install cross --git https://github.com/cross-rs/cross
- name: Build static binaries
run: cross build --release --target ${{ matrix.target }}
- name: Get version
id: version
run: echo "version=$(grep '^version' Cargo.toml | head -1 | sed 's/.*\"\(.*\)\".*/\1/')" >> "$GITHUB_OUTPUT"
- name: Package binaries
run: |
mkdir -p dist
cp target/${{ matrix.target }}/release/wolfnet dist/wolfnet-${{ matrix.arch }}
cp target/${{ matrix.target }}/release/wolfnetctl dist/wolfnetctl-${{ matrix.arch }}
chmod +x dist/wolfnet-${{ matrix.arch }} dist/wolfnetctl-${{ matrix.arch }}
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: wolfnet-${{ matrix.arch }}
path: dist/*
release:
needs: build
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- name: Get version
id: version
run: echo "version=$(grep '^version' Cargo.toml | head -1 | sed 's/.*\"\(.*\)\".*/\1/')" >> "$GITHUB_OUTPUT"
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: dist
merge-multiple: true
- name: Create or update release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
VERSION="v${{ steps.version.outputs.version }}"
# Delete existing release if it exists (update scenario)
gh release delete "$VERSION" --yes 2>/dev/null || true
git push --delete origin "$VERSION" 2>/dev/null || true
# Create release with binaries
gh release create "$VERSION" \
--title "WolfNet $VERSION" \
--notes "Prebuilt static binaries for Linux x86_64 and aarch64 (ARM64/Raspberry Pi 4+)." \
dist/wolfnet-x86_64 \
dist/wolfnet-aarch64 \
dist/wolfnetctl-x86_64 \
dist/wolfnetctl-aarch64