name: Rust Release Workflow
on:
push:
tags:
- "v*"
jobs:
build_linux:
name: Build for Linux (x86_64)
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
targets: x86_64-unknown-linux-gnu
- name: Build release binary
run: |
cargo build --release --target x86_64-unknown-linux-gnu
- name: Archive binary
run: tar -czvf ${{ github.event.repository.name }}-linux-x86_64.tar.gz -C target/x86_64-unknown-linux-gnu/release ${{ github.event.repository.name }}
- name: Upload artifact
uses: actions/upload-artifact@v4 with:
name: linux-release
path: ${{ github.event.repository.name }}-linux-x86_64.tar.gz
build_windows:
name: Build for Windows (x86_64)
runs-on: windows-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
targets: x86_64-pc-windows-msvc
- name: Build release binary
run: cargo build --release --target x86_64-pc-windows-msvc
- name: Archive binary
run: Compress-Archive -Path target/x86_64-pc-windows-msvc/release/${{ github.event.repository.name }}.exe -DestinationPath ${{ github.event.repository.name }}-windows-x86_64.zip
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: windows-release
path: ${{ github.event.repository.name }}-windows-x86_64.zip
build_macos:
name: Build for macOS (x86_64 & arm64)
runs-on: macos-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
- name: Add macOS x86_64 target
run: rustup target add x86_64-apple-darwin
- name: Ad macOS aarch64 target
run: rustup target add aarch64-apple-darwin
- name: Build for macOS (x86_64)
run: cargo build --release --target x86_64-apple-darwin
- name: Archive binary (x86_64)
run: tar -czvf ${{ github.event.repository.name }}-macos-x86_64.tar.gz -C target/x86_64-apple-darwin/release ${{ github.event.repository.name }}
- name: Upload artifact (x86_64)
uses: actions/upload-artifact@v4
with:
name: macos-x86_64-release
path: ${{ github.event.repository.name }}-macos-x86_64.tar.gz
- name: Build for macOS (aarch64)
run: cargo build --release --target aarch64-apple-darwin
- name: Archive binary (aarch64)
run: tar -czvf ${{ github.event.repository.name }}-macos-aarch64.tar.gz -C target/aarch64-apple-darwin/release ${{ github.event.repository.name }}
- name: Upload artifact (aarch64)
uses: actions/upload-artifact@v4
with:
name: macos-aarch64-release
path: ${{ github.event.repository.name }}-macos-aarch64.tar.gz
create_release:
name: Create GitHub Release
runs-on: ubuntu-latest
needs: [build_linux, build_windows, build_macos]
permissions:
contents: write
steps:
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Create GitHub Release
uses: softprops/action-gh-release@v2 with:
tag_name: ${{ github.ref_name }}
body: |
Release ${{ github.ref_name }}
This is an automated release for B.E.L.T.
Includes binaries for Linux, Windows, and macOS.
files: |
artifacts/linux-release/${{ github.event.repository.name }}-linux-x86_64.tar.gz
artifacts/windows-release/${{ github.event.repository.name }}-windows-x86_64.zip
artifacts/macos-x86_64-release/${{ github.event.repository.name }}-macos-x86_64.tar.gz
artifacts/macos-aarch64-release/${{ github.event.repository.name }}-macos-aarch64.tar.gz
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}