-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Based on: https://dzfrias.dev/blog/deploy-rust-cross-platform-github-actions Signed-off-by: Chuanhong Guo <[email protected]>
- Loading branch information
Showing
2 changed files
with
90 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,70 @@ | ||
on: | ||
release: | ||
types: [created] | ||
|
||
env: | ||
PROJECT_NAME: mtk_uartboot | ||
|
||
jobs: | ||
build-and-upload: | ||
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@v4 | ||
|
||
- name: Install Rust | ||
uses: dtolnay/rust-toolchain@stable | ||
with: | ||
targets: "${{ matrix.target }}" | ||
|
||
- name: Setup Cache | ||
uses: Swatinem/rust-cache@v2 | ||
|
||
- name: Get the release version from the tag | ||
shell: bash | ||
run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV | ||
|
||
- name: Build Binary | ||
run: cargo build --verbose --locked --release --target ${{ matrix.target }} | ||
|
||
- name: Build archive | ||
shell: bash | ||
run: | | ||
dirname="${PROJECT_NAME}-${{ env.VERSION }}-${{ matrix.target }}" | ||
mkdir "$dirname" | ||
if [ "${{ matrix.os }}" = "windows-latest" ]; then | ||
mv "target/${{ matrix.target }}/release/${PROJECT_NAME}.exe" "$dirname" | ||
else | ||
mv "target/${{ matrix.target }}/release/${PROJECT_NAME}" "$dirname" | ||
fi | ||
if [ "${{ matrix.os }}" = "windows-latest" ]; then | ||
7z a "$dirname.zip" "$dirname" | ||
echo "ASSET=$dirname.zip" >> $GITHUB_ENV | ||
else | ||
tar -czf "$dirname.tar.gz" "$dirname" | ||
echo "ASSET=$dirname.tar.gz" >> $GITHUB_ENV | ||
fi | ||
- name: Upload the binaries | ||
uses: softprops/action-gh-release@v1 | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
name: Rust | ||
|
||
on: | ||
push: | ||
branches: [ "main" ] | ||
pull_request: | ||
branches: [ "main" ] | ||
|
||
env: | ||
CARGO_TERM_COLOR: always | ||
|
||
jobs: | ||
build: | ||
|
||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Build | ||
run: cargo build --verbose |