Skip to content

Commit

Permalink
github: upload binaries as artifact during build
Browse files Browse the repository at this point in the history
  • Loading branch information
981213 committed Mar 2, 2024
1 parent 21ce6aa commit 91096c8
Showing 1 changed file with 51 additions and 9 deletions.
60 changes: 51 additions & 9 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,62 @@
name: Rust
name: Build binaries

on:
push:
branches: [ "main" ]
branches: [ "main", "action" ]
pull_request:
branches: [ "main" ]
branches: [ "main", "action" ]

env:
CARGO_TERM_COLOR: always
PROJECT_NAME: mtk_uartboot
RUSTFLAGS: -C target-feature=+crt-static

jobs:
build:
build-and-upload:
runs-on: ${{ matrix.runner }}

runs-on: ubuntu-latest
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:
- uses: actions/checkout@v4
- name: Build
run: cargo build --verbose
- name: Checkout
uses: actions/checkout@v4

- 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: Get binary path
shell: bash
run: |
if [ "${{ matrix.runner }}" = "windows-latest" ]; then
bin_path="target/${{ matrix.target }}/release/${PROJECT_NAME}.exe"
else
bin_path="target/${{ matrix.target }}/release/${PROJECT_NAME}"
fi
echo "ASSET=$bin_path" >> $GITHUB_ENV
- name: Upload the binaries
- uses: actions/upload-artifact@v4
with:
name: binary
path: ${{ env.ASSET }}

0 comments on commit 91096c8

Please sign in to comment.