-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Github Action to build and release binaries of new tags
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
1 parent
4ffa71b
commit c35d563
Showing
2 changed files
with
89 additions
and
0 deletions.
There are no files selected for viewing
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
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 }} |
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