feat: use something more useful than panicking with 500 when no data … #43
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
name: Rust | |
on: | |
push: | |
branches: | |
- "main" | |
tags: | |
- "v*" | |
pull_request: | |
branches: | |
- "main" | |
env: | |
CARGO_TERM_COLOR: always | |
CARGO_INCREMENTAL: 0 | |
jobs: | |
build-and-release: | |
name: Build - ${{ matrix.platform.release_for }} | |
permissions: | |
packages: write | |
contents: write | |
strategy: | |
fail-fast: false | |
matrix: | |
platform: | |
- release_for: RaspberryPi-armv7 | |
os: ubuntu-20.04 | |
target: armv7-unknown-linux-musleabihf | |
bin: amp-sensor-backend | |
name: amp-sensor-backend-raspberrypi-armv7-musleabihf | |
command: build | |
## These can be released, but only if they are requested by a | |
## community, since they are more expensive to run | |
# - release_for: Windows-x86_64 | |
# os: windows-latest | |
# target: x86_64-pc-windows-msvc | |
# bin: amp-sensor-backend.exe | |
# name: amp-sensor-backend-Windows-x86_64 | |
# command: both | |
# - release_for: macOS-x86_64 | |
# os: macOS-latest | |
# target: x86_64-apple-darwin | |
# bin: amp-sensor-backend | |
# name: amp-sensor-backend-Darwin-x86_64 | |
# command: both | |
# - release_for: macOS-aarch64 | |
# os: macOS-latest | |
# target: aarch64-apple-darwin | |
# bin: amp-sensor-backend | |
# name: amp-sensor-backend-Darwin-aarch64 | |
# command: both | |
- release_for: RaspberryPi-aarch64 | |
os: ubuntu-20.04 | |
target: aarch64-unknown-linux-musl | |
bin: amp-sensor-backend | |
name: amp-sensor-backend-linux-aarch64-musl | |
command: build | |
- release_for: Linux-x86_64 | |
os: ubuntu-20.04 | |
target: x86_64-unknown-linux-musl | |
bin: amp-sensor-backend | |
name: amp-sensor-backend-linux-x86_64-musl | |
command: both | |
runs-on: ${{ matrix.platform.os }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- uses: Swatinem/rust-cache@v2 | |
with: | |
key: ${{ matrix.platform.target }} | |
cache-on-failure: true | |
- name: Install musl-tools for cross-compilation | |
if: endsWith(matrix.platform.target, '-musl') | |
run: sudo apt-get install -y musl-tools | |
- name: Build binary | |
uses: houseabsolute/actions-rust-cross@v0 | |
with: | |
command: ${{ matrix.platform.command }} | |
target: ${{ matrix.platform.target }} | |
args: "--locked --release" | |
strip: true | |
- run: mkdir -p release | |
- name: Copy binary to release target directory | |
run: cp target/${{ matrix.platform.target }}/release/${{ matrix.platform.bin }} release/${{ matrix.platform.name }} | |
if: startsWith( github.ref, 'refs/tags/v' ) | |
- name: Publish Github release | |
uses: softprops/action-gh-release@v2 | |
with: | |
files: release/${{ matrix.platform.name }} | |
token: ${{ secrets.GITHUB_TOKEN }} | |
prerelease: true | |
draft: false | |
if: startsWith( github.ref, 'refs/tags/v' ) | |