From e610eb95f6edea9fcc71085ddfff16c87e4058f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kau=C3=AA=20Fraga=20Rodrigues?= <88486000+kauefraga@users.noreply.github.com> Date: Sat, 4 May 2024 11:42:25 -0300 Subject: [PATCH] config: create an action to build ruke (#10) --- .github/workflows/rust.yml | 56 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 .github/workflows/rust.yml diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml new file mode 100644 index 0000000..8fa6d19 --- /dev/null +++ b/.github/workflows/rust.yml @@ -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}"