Merge pull request #575 from alsuren/dependabot/cargo/thiserror-2.0.8 #513
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: Package | |
on: | |
push: | |
branches: [master] | |
tags: ["applehat-*", "homie-influx-*", "mijia-homie-*"] | |
env: | |
CARGO_TERM_COLOR: always | |
cargo-deb-version: 2.0.0 | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
target: | |
- arm-unknown-linux-gnueabi | |
- armv7-unknown-linux-gnueabihf | |
- aarch64-unknown-linux-gnu | |
- x86_64-unknown-linux-gnu | |
include: | |
- target: arm-unknown-linux-gnueabi | |
binutils: binutils-arm-linux-gnueabi | |
- target: armv7-unknown-linux-gnueabihf | |
binutils: binutils-arm-linux-gnueabihf | |
- target: aarch64-unknown-linux-gnu | |
binutils: binutils-aarch64-linux-gnu | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install dependencies | |
run: sudo apt-get update && sudo apt-get install libdbus-1-dev ${{ matrix.binutils }} | |
- name: Toolchain | |
uses: actions-rs/toolchain@v1 | |
with: | |
toolchain: stable | |
target: ${{ matrix.target }} | |
override: true | |
- name: Cache .cargo and target | |
uses: actions/cache@v4 | |
with: | |
path: | | |
~/.cargo/git | |
~/.cargo/registry | |
target | |
key: ${{ runner.os }}-${{ matrix.target }}-package-cargo-${{ hashFiles('**/Cargo.lock', '**/Cross.toml') }} | |
- name: Cache cargo-deb and cross | |
uses: actions/cache@v4 | |
with: | |
path: | | |
~/.cargo/bin/cargo-deb | |
~/.cargo/bin/cross | |
~/.cargo/.crates.toml | |
~/.cargo/.crates2.json | |
key: ${{ runner.os }}-cargo-bin-${{ env.cargo-deb-version }} | |
- name: Install cargo-deb | |
run: cargo install cargo-deb --version ${{ env.cargo-deb-version }} | |
- name: Cross build | |
uses: actions-rs/cargo@v1 | |
with: | |
use-cross: true | |
command: build | |
args: --release --target ${{ matrix.target }} | |
- name: Package applehat | |
uses: actions-rs/cargo@v1 | |
with: | |
command: deb | |
args: --target ${{ matrix.target }} --no-build --package applehat | |
- name: Package homie-influx | |
uses: actions-rs/cargo@v1 | |
with: | |
command: deb | |
args: --target ${{ matrix.target }} --no-build --package homie-influx | |
- name: Package mijia-homie | |
uses: actions-rs/cargo@v1 | |
with: | |
command: deb | |
args: --target ${{ matrix.target }} --no-build --package mijia-homie | |
- name: Upload packages | |
uses: actions/upload-artifact@v4 | |
with: | |
name: debian-packages-${{ matrix.target }} | |
path: target/${{ matrix.target }}/debian/ | |
release: | |
name: Draft release | |
runs-on: ubuntu-latest | |
needs: build | |
if: github.event_name == 'push' && (startsWith(github.ref, 'refs/tags/applehat-') || startsWith(github.ref, 'refs/tags/homie-influx-') || startsWith(github.ref, 'refs/tags/mijia-homie-')) | |
steps: | |
- name: Download packages | |
uses: actions/download-artifact@v4 | |
- name: Parse tag for package and version | |
id: parse_tag | |
uses: actions-ecosystem/action-regex-match@v2 | |
with: | |
text: ${{ github.ref }} | |
regex: "^refs/tags/(applehat|homie-influx|mijia-homie)-(.+)$" | |
- name: Create draft release | |
id: create_release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions. | |
with: | |
tag_name: ${{ github.ref }} | |
release_name: ${{ steps.parse_tag.outputs.group1 }} release ${{ steps.parse_tag.outputs.group2 }} | |
draft: true | |
prerelease: false | |
- name: Upload packages to release | |
uses: shogo82148/actions-upload-release-asset@v1 | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: "debian-packages-*/${{ steps.parse_tag.outputs.group1 }}_*.deb" | |
asset_content_type: application/vnd.debian.binary-package |