Merge pull request #378 from alsuren/dependabot/cargo/log-0.4.20 #338
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: 1.34.2 | |
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@v3 | |
- 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@v3 | |
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@v3 | |
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@v3 | |
with: | |
name: debian-packages | |
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@v3 | |
with: | |
name: debian-packages | |
- 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: "${{ steps.parse_tag.outputs.group1 }}_*.deb" | |
asset_content_type: application/vnd.debian.binary-package |