Skip to content

Commit

Permalink
Add Github Action to build and release binaries of new tags
Browse files Browse the repository at this point in the history
Summary:
This adds a Github Action build and release binaries for Linux, MacOS and Windows upon new new tag.

# Why?

Simplify usage of Scrut by making binaries available for common platforms.

# What?

Add Github Action that starts automatic build and release for the following targets:
- x86_64-unknown-linux-musl
- aarch64-unknown-linux-musl
- x86_64-apple-darwin
- aarch64-apple-darwin
- x86_64-pc-windows-gnu

The binaries will be build, archived (zip for windows, tar zst for others) and then uploaded as a a release asset for a newly created release version.

Reviewed By: AndreasBackx

Differential Revision: D68104600

fbshipit-source-id: 35a781e96aa33dcefcd43a9f4357b0c3dbfd7de5
  • Loading branch information
ukautz authored and facebook-github-bot committed Jan 15, 2025
1 parent 4ffa71b commit c35d563
Show file tree
Hide file tree
Showing 2 changed files with 89 additions and 0 deletions.
86 changes: 86 additions & 0 deletions .github/workflows/release-binaries.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
# Build and release binaries for Linux, MacOS and Windows for common architectures via Github Actions
name: Build and Release Binaries

on:
push:
tags:
- '*'
workflow_dispatch: {}

permissions:
contents: write

jobs:
build-and-release:
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
# linux
- build: linux-x86_64
os: ubuntu-24.04
target: x86_64-unknown-linux-musl
- build: linux-aarch64
os: ubuntu-24.04
target: aarch64-unknown-linux-musl

# macos
- build: macos-x86_64
os: macos-15
target: x86_64-apple-darwin
- build: macos-aarch64
os: macos-15
target: aarch64-apple-darwin

# windows
- build: windows-x86_64
os: windows-2022
target: x86_64-pc-windows-gnu


steps:
- name: Checkout
uses: actions/checkout@v4

- name: Get Version
shell: bash
run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV

- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}

- uses: Swatinem/rust-cache@v2
with:
key: ${{ matrix.target }}

- name: Build Binary
run: cargo build --release

- name: Build Archive
shell: bash
run: |
binary_name="scrut"
dirname="$binary_name-${{ env.VERSION }}-${{ matrix.target }}"
mkdir -p "$dirname"
if [ "${{ matrix.os }}" = "windows-2022" ]; then
mv "target/release/$binary_name.exe" "$dirname"
else
mv "target/release/$binary_name" "$dirname"
fi
if [ "${{ matrix.os }}" = "windows-2022" ]; then
7z a "$dirname.zip" "$dirname"
echo "ASSET=$dirname.zip" >> $GITHUB_ENV
else
tar --use-compress-program zstdmt -cf "$dirname.tar.zst" "$dirname"
echo "ASSET=$dirname.tar.zst" >> $GITHUB_ENV
fi
- name: Release
uses: softprops/action-gh-release@v2
with:
files: |
${{ env.ASSET }}
3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,6 @@ vergen = { version = "7", features = ["git"] }
assert_cmd = "2.0"
insta = {version = "1.21.1", features = ["json"] }
predicates = "2.1"

[profile.release]
strip = true

0 comments on commit c35d563

Please sign in to comment.