v0.3.0 #11
Workflow file for this run
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
# Reference: | |
# https://eugene-babichenko.github.io/blog/2020/05/09/github-actions-cross-platform-auto-releases/ | |
name: Release | |
on: | |
release: | |
types: [ created ] | |
env: | |
BIN_NAME: hpm_isp | |
jobs: | |
build-release: | |
name: build-release | |
strategy: | |
fail-fast: false | |
matrix: | |
build: [linux, macos, win-msvc] | |
include: | |
- build: linux | |
os: ubuntu-latest | |
rust: stable | |
target: x86_64-unknown-linux-gnu | |
- build: macos | |
os: macos-latest | |
rust: stable | |
target: x86_64-apple-darwin | |
- build: win-msvc | |
os: windows-2019 | |
rust: stable | |
target: x86_64-pc-windows-msvc | |
runs-on: ${{ matrix.os }} | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
with: | |
fetch-depth: 1 | |
- name: Install packages (Ubuntu) | |
if: matrix.os == 'ubuntu-latest' | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y --no-install-recommends libusb-1.0-0-dev libudev-dev | |
- name: Install Rust | |
uses: actions-rs/toolchain@v1 | |
with: | |
toolchain: ${{ matrix.rust }} | |
profile: minimal | |
override: true | |
target: ${{ matrix.target }} | |
- name: Build release binary | |
run: cargo build --target ${{ matrix.target }} --verbose --release | |
- name: Build archive | |
shell: bash | |
run: | | |
outdir="./target/${{ env.TARGET_DIR }}/release" | |
staging="${{ env.BIN_NAME }}-${{ github.event.release.tag_name }}-${{ matrix.target }}" | |
mkdir -p "$staging" | |
cp {README.md,LICENSE,99-hpm_bootrom.rules} "$staging/" | |
if [ "${{ matrix.os }}" = "windows-2019" ]; then | |
cp "target/${{ matrix.target }}/release/${{ env.BIN_NAME }}.exe" "$staging/" | |
cd "$staging" | |
7z a "../$staging.zip" . | |
echo "ASSET=$staging.zip" >> $GITHUB_ENV | |
else | |
cp "target/${{ matrix.target }}/release/${{ env.BIN_NAME }}" "$staging/" | |
tar czf "$staging.tar.gz" -C "$staging" . | |
echo "ASSET=$staging.tar.gz" >> $GITHUB_ENV | |
fi | |
- name: Upload release archive | |
uses: actions/[email protected] | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ github.event.release.upload_url }} | |
asset_path: ${{ env.ASSET }} | |
asset_name: ${{ env.ASSET }} | |
asset_content_type: application/octet-stream |