Skip to content

build and release

build and release #7

Workflow file for this run

name: build and release
on:
release:
types: [ created ]
workflow_dispatch:
permissions:
contents: write
jobs:
build:
name: ${{ matrix.platform.os_name }} with rust ${{ matrix.toolchain }}
runs-on: ${{ matrix.platform.os }}
strategy:
fail-fast: false
matrix:
platform:
- os_name: Linux-aarch64
os: ubuntu-latest
target: aarch64-unknown-linux-musl
bin: riden-flashtool-linux-arm64
- os_name: Linux-x86_64
os: ubuntu-latest
target: x86_64-unknown-linux-gnu
bin: riden-flashtool-linux-amd64
- os_name: Windows-x86_64
os: windows-latest
target: x86_64-pc-windows-msvc
bin: riden-flashtool-windows-amd64.exe
- os_name: macOS-x86_64
os: macOS-latest
target: x86_64-apple-darwin
bin: riden-flashtool-darwin-amd64
- os_name: macOS-aarch64
os: macOS-latest
target: aarch64-apple-darwin
bin: riden-flashtool-darwin-arm64
toolchain:
- stable
steps:
- uses: actions/checkout@v4
- name: Install dependencies (Linux)
if: startsWith(matrix.platform.os_name, 'Linux')
run: sudo apt-get update && sudo apt-get install -y libudev-dev
- name: Build binary
uses: houseabsolute/actions-rust-cross@v1
with:
command: "build"
target: ${{ matrix.platform.target }}
toolchain: ${{ matrix.toolchain }}
args: "--locked --release"
strip: true
- name: Rename binary (linux and macos)
run: mv target/${{ matrix.platform.target }}/release/riden-flashtool target/${{ matrix.platform.target }}/release/${{ matrix.platform.bin }}
if: matrix.platform.os_name != 'Windows-x86_64'
- name: Rename binary (windows)
run: mv target/${{ matrix.platform.target }}/release/riden-flashtool.exe target/${{ matrix.platform.target }}/release/${{ matrix.platform.bin }}
if: matrix.platform.os_name == 'Windows-x86_64'
- name: Create release zip archive (Linux and macOS)
run: |
zip -j target/${{ matrix.platform.target }}/release/${{ matrix.platform.bin }}.zip target/${{ matrix.platform.target }}/release/${{ matrix.platform.bin }}
shell: bash
if: matrix.platform.os_name != 'Windows-x86_64'
- name: Create release zip archive (Windows)
run: |
powershell Compress-Archive -Path target\${{ matrix.platform.target }}\release\${{ matrix.platform.bin }} -DestinationPath target\${{ matrix.platform.target }}\release\${{ matrix.platform.bin }}.zip
if: matrix.platform.os_name == 'Windows-x86_64'
- name: Generate SHA-256
run: shasum -a 256 target/${{ matrix.platform.target }}/release/${{ matrix.platform.bin }}.zip | cut -d ' ' -f 1 > target/${{ matrix.platform.target }}/release/${{ matrix.platform.bin }}.zip.sha256
# Only upload as GitHub Release asset if this is a release event
- name: Release zip archive and SHA-256 checksum to GitHub
if: github.event_name == 'release'
uses: softprops/action-gh-release@v2
with:
files: |
target/${{ matrix.platform.target }}/release/${{ matrix.platform.bin }}.zip
target/${{ matrix.platform.target }}/release/${{ matrix.platform.bin }}.zip.sha256
# For manual runs, upload as workflow artifact for download
- name: Upload artifact for manual download
if: github.event_name == 'workflow_dispatch'
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.platform.bin }}.zip
path: target/${{ matrix.platform.target }}/release/${{ matrix.platform.bin }}.zip
retention-days: 1