Improve FreeBSD build support #33
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
name: Release Binaries | |
"on": | |
push: | |
tags: | |
- 'v*.*.*' | |
jobs: | |
release: | |
name: Release - ${{ matrix.platform.os-name }} | |
strategy: | |
matrix: | |
platform: | |
- os-name: Linux-x86_64 | |
runs-on: ubuntu-latest | |
target: x86_64-unknown-linux-musl | |
artifact_name: rustygate-linux-amd64 | |
cross_build: true | |
- os-name: Linux-aarch64 | |
runs-on: ubuntu-latest | |
target: aarch64-unknown-linux-musl | |
artifact_name: rustygate-linux-arm64 | |
cross_build: true | |
- os-name: FreeBSD-x86_64 | |
runs-on: ubuntu-latest | |
target: x86_64-unknown-freebsd | |
artifact_name: rustygate-freebsd-amd64 | |
cross_build: true | |
skip_tests: true # FreeBSD tests might not work in Linux environment | |
- os-name: macOS-x86_64 | |
runs-on: macos-latest | |
target: x86_64-apple-darwin | |
artifact_name: rustygate-darwin-amd64 | |
cross_build: false | |
- os-name: macOS-aarch64 | |
runs-on: macos-latest | |
target: aarch64-apple-darwin | |
artifact_name: rustygate-darwin-arm64 | |
cross_build: false | |
runs-on: ${{ matrix.platform.runs-on }} | |
steps: | |
- uses: actions/checkout@v4 | |
# Linux/FreeBSD cross-compilation steps | |
- name: Install build dependencies | |
if: matrix.platform.cross_build | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y musl-tools perl make | |
if [[ "${{ matrix.platform.target }}" == *"freebsd"* ]]; then | |
sudo apt-get install -y freebsd-buildutils | |
fi | |
- name: Build with Cross | |
if: matrix.platform.cross_build | |
uses: houseabsolute/[email protected] | |
with: | |
target: ${{ matrix.platform.target }} | |
args: "--release" | |
strip: true | |
env: | | |
OPENSSL_STATIC=1 | |
RUSTFLAGS="-C target-feature=+crt-static" | |
CROSS_CONTAINER_OPTS="--platform linux/amd64" # Ensure consistent platform for cross | |
# macOS-specific steps | |
- name: Install Rust | |
if: "!matrix.platform.cross_build" | |
uses: dtolnay/rust-toolchain@stable | |
with: | |
targets: ${{ matrix.platform.target }} | |
- name: Build | |
if: "!matrix.platform.cross_build" | |
run: cargo build --release --target ${{ matrix.platform.target }} | |
# Common steps | |
- name: Prepare artifact | |
run: | | |
cp target/${{ matrix.platform.target }}/release/main ${{ matrix.platform.artifact_name }} | |
- name: Generate SHA256 | |
run: | | |
if [ "${{ matrix.platform.cross_build }}" = "true" ]; then | |
sha256sum ${{ matrix.platform.artifact_name }} | |
else | |
shasum -a 256 ${{ matrix.platform.artifact_name }} | |
fi > ${{ matrix.platform.artifact_name }}.sha256 | |
- name: Upload artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ matrix.platform.artifact_name }} | |
path: | | |
${{ matrix.platform.artifact_name }} | |
${{ matrix.platform.artifact_name }}.sha256 | |
create-release: | |
needs: release | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Download artifacts | |
uses: actions/download-artifact@v4 | |
- name: Create Release | |
uses: softprops/action-gh-release@v1 | |
with: | |
files: | | |
**/rustygate-* | |
generate_release_notes: true |