-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
config: create an action to build ruke (#10)
- Loading branch information
Showing
1 changed file
with
56 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,56 @@ | ||
name: Build | ||
on: [push] | ||
env: | ||
PROJECT_NAME: ruke | ||
jobs: | ||
build: | ||
runs-on: ${{ matrix.runner }} | ||
|
||
strategy: | ||
matrix: | ||
include: | ||
- name: linux-amd64 | ||
runner: ubuntu-latest | ||
target: x86_64-unknown-linux-gnu | ||
- name: win-amd64 | ||
runner: windows-latest | ||
target: x86_64-pc-windows-msvc | ||
- name: macos-amd64 | ||
runner: macos-latest | ||
target: x86_64-apple-darwin | ||
- name: macos-arm64 | ||
runner: macos-latest | ||
target: aarch64-apple-darwin | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
- name: Install Rust | ||
uses: dtolnay/rust-toolchain@stable | ||
with: | ||
targets: "${{ matrix.target }}" | ||
|
||
- name: Setup Cache | ||
uses: Swatinem/rust-cache@v2 | ||
|
||
- name: Build Binary | ||
run: cargo build --verbose --locked --release --target ${{ matrix.target }} | ||
|
||
- name: Release Binary | ||
shell: bash | ||
run: | | ||
BIN_SUFFIX="" | ||
if [[ "${{ matrix.runner }}" == "windows-latest" ]]; then | ||
BIN_SUFFIX=".exe" | ||
fi | ||
# The built binary output location | ||
BIN_OUTPUT="target/${{ matrix.target }}/release/${PROJECT_NAME}${BIN_SUFFIX}" | ||
|
||
# Define a better name for the final binary | ||
BIN_RELEASE="${PROJECT_NAME}-${{ matrix.name }}${BIN_SUFFIX}" | ||
BIN_RELEASE_VERSIONED="${PROJECT_NAME}-${{ github.ref_name }}-${{ matrix.name }}${BIN_SUFFIX}" | ||
|
||
# Move the built binary where you want it | ||
mv "${BIN_OUTPUT}" "./bin/${BIN_RELEASE}" |