Release v1.3.2 #23
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
name: Release | |
on: | |
push: | |
tags: | |
- "v*" | |
workflow_dispatch: {} | |
jobs: | |
build: | |
name: Build binaries | |
permissions: | |
contents: read | |
packages: write | |
strategy: | |
fail-fast: false | |
matrix: | |
target: | |
- aarch64-unknown-linux-gnu | |
- aarch64-unknown-linux-musl | |
- armv7-unknown-linux-gnueabihf | |
- armv7-unknown-linux-musleabihf | |
- x86_64-unknown-linux-musl | |
os: [ubuntu-latest] | |
include: | |
# Use an older Ubuntu version for glibc compatibility with Debian v11 Buster | |
- target: x86_64-unknown-linux-gnu | |
os: ubuntu-20.04 | |
env: | |
RELEASE: ${{ startsWith(github.ref, 'refs/tags/v') }} | |
PROFILE: ${{ startsWith(github.ref, 'refs/tags/v') && 'release' || 'debug' }} | |
USE_CROSS: "${{ !startsWith(matrix.target, 'x86_64-unknown-linux-') }}" | |
MUSL: ${{ contains(matrix.target, '-unknown-linux-musl') }} | |
CARGO: cargo | |
runs-on: ${{ matrix.os }} | |
steps: | |
- name: Setup | Checkout | |
uses: actions/[email protected] | |
- name: Setup | Rust | |
uses: dtolnay/rust-toolchain@439cf607258077187679211f12aa6f19af4a0af7 | |
with: | |
toolchain: stable | |
- name: Setup | Cache | |
uses: Swatinem/rust-cache@3cf7f8cc28d1b4e7d01e3783be10a97d55d483c8 # v2.7.1 | |
with: | |
shared-key: ${{ matrix.target }}-${{ matrix.os }}-${{ env.PROFILE }}-build | |
- name: Setup | Cross | |
if: env.USE_CROSS == 'true' | |
run: | | |
cargo install --bins cross | |
echo "CARGO=cross" >> $GITHUB_ENV | |
- name: Setup | Install build dependencies | |
if: env.USE_CROSS == 'false' | |
run: | | |
rustup target add ${{ matrix.target }} | |
if [[ "$MUSL" == 'true' ]]; then | |
sudo apt-get update | |
sudo apt-get install --assume-yes musl-tools | |
fi | |
- name: Setup | Log in to the Container registry | |
if: env.USE_CROSS == 'true' | |
uses: docker/[email protected] | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Setup | Set build options | |
if: env.RELEASE == 'true' | |
run: | | |
echo 'RELEASE_FLAG=--release' >> $GITHUB_ENV | |
- name: Build | |
run: ${{ env.CARGO }} build --verbose ${{ env.RELEASE_FLAG }} --target ${{ matrix.target }} | |
- name: Prepare artifacts | |
run: | | |
mkdir -p 'binaries/${{ matrix.target }}' | |
cp target/${{ matrix.target }}/${{ ENV.PROFILE }}/ruuvi2mqtt binaries/${{ matrix.target }}/ | |
- name: Upload artifacts | |
uses: actions/[email protected] | |
with: | |
name: binaries | |
path: binaries | |
docker: | |
name: Build and push Docker images | |
needs: build | |
permissions: | |
contents: read | |
packages: write | |
env: | |
PLATFORMS: linux/amd64,linux/arm64,linux/arm/v7 | |
REGISTRY: ghcr.io | |
IMAGE_NAME: ${{ github.repository }} | |
runs-on: ubuntu-latest | |
steps: | |
- name: Setup | Checkout | |
uses: actions/[email protected] | |
- name: Setup | Download artifacts | |
uses: actions/[email protected] | |
with: | |
name: binaries | |
path: binaries | |
- name: Setup | Prepare binaries | |
run: | | |
chmod 0755 binaries/*/ruuvi2mqtt | |
mkdir -p binaries/{${{ env.PLATFORMS }}} | |
ln -s ../../aarch64-unknown-linux-musl/ruuvi2mqtt binaries/linux/arm64/ | |
ln -s ../../../armv7-unknown-linux-musleabihf/ruuvi2mqtt binaries/linux/arm/v7/ | |
ln -s ../../x86_64-unknown-linux-musl/ruuvi2mqtt binaries/linux/amd64/ | |
- name: Setup | Log in to the Container registry | |
uses: docker/[email protected] | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Setup | Docker QEMU | |
uses: docker/[email protected] | |
- name: Setup | Docker Buildx | |
uses: docker/[email protected] | |
- name: Extract metadata (tags, labels) for Docker | |
id: meta | |
uses: docker/[email protected] | |
with: | |
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | |
- name: Build and push Docker image | |
uses: docker/[email protected] | |
with: | |
context: . | |
platforms: ${{ env.PLATFORMS }} | |
push: true | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} |