fix: correct paths and dependencies #5
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*' | |
env: | |
CARGO_TERM_COLOR: always | |
CARGO_INCREMENTAL: 0 | |
CARGO_NET_RETRY: 10 | |
RUSTUP_MAX_RETRIES: 10 | |
RUST_BACKTRACE: short | |
PKG_CONFIG_ALLOW_CROSS: 1 | |
jobs: | |
# First run the same checks as in CI | |
check: | |
name: Check | |
uses: ./.github/workflows/ci.yml | |
build-deb: | |
name: Build Debian Package | |
needs: check | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
target: | |
- armv7-unknown-linux-gnueabihf | |
- aarch64-unknown-linux-gnu | |
- x86_64-unknown-linux-gnu | |
include: | |
- target: armv7-unknown-linux-gnueabihf | |
arch: armhf | |
- target: aarch64-unknown-linux-gnu | |
arch: arm64 | |
- target: x86_64-unknown-linux-gnu | |
arch: amd64 | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install system dependencies | |
if: matrix.target == 'x86_64-unknown-linux-gnu' | |
run: | | |
sudo apt-get update && \ | |
sudo apt-get install -y libudev-dev && \ | |
find /usr -name libudev.pc | |
- name: Install Rust toolchain | |
uses: dtolnay/rust-toolchain@stable | |
with: | |
targets: ${{ matrix.target }} | |
- name: Cache cargo | |
uses: actions/cache@v3 | |
with: | |
path: | | |
~/.cargo/registry | |
~/.cargo/git | |
target | |
key: ${{ runner.os }}-cargo-${{ matrix.target }}-${{ hashFiles('**/Cargo.lock') }} | |
restore-keys: | | |
${{ runner.os }}-cargo-${{ matrix.target }}- | |
- name: Install cross | |
uses: taiki-e/install-action@cross | |
- name: Install cargo-deb | |
run: cargo install cargo-deb | |
- name: Build | |
run: | | |
if [ "${{ matrix.target }}" = "x86_64-unknown-linux-gnu" ]; then | |
cargo build --release --target ${{ matrix.target }} | |
else | |
cross build --release --target ${{ matrix.target }} | |
fi | |
- name: Build deb package | |
run: cargo deb --target ${{ matrix.target }} | |
- name: Upload artifacts | |
uses: actions/upload-artifact@v3 | |
with: | |
name: deb-${{ matrix.arch }} | |
path: target/${{ matrix.target }}/debian/*.deb | |
build-arch: | |
name: Build Arch Package | |
needs: check | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
target: | |
- x86_64-unknown-linux-gnu | |
- aarch64-unknown-linux-gnu | |
- armv7-unknown-linux-gnueabihf | |
include: | |
- target: x86_64-unknown-linux-gnu | |
arch: x86_64 | |
- target: aarch64-unknown-linux-gnu | |
arch: aarch64 | |
- target: armv7-unknown-linux-gnueabihf | |
arch: armv7h | |
container: | |
image: archlinux:base-devel | |
options: --privileged | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install dependencies | |
run: | | |
pacman -Syu --noconfirm | |
pacman -S --noconfirm git rustup cargo systemd pkg-config | |
rustup default stable | |
rustup target add ${{ matrix.target }} | |
- name: Cache cargo | |
uses: actions/cache@v3 | |
with: | |
path: | | |
~/.cargo/registry | |
~/.cargo/git | |
target | |
key: ${{ runner.os }}-arch-cargo-${{ matrix.target }}-${{ hashFiles('**/Cargo.lock') }} | |
- name: Install cross | |
uses: taiki-e/install-action@cross | |
- name: Prepare PKGBUILD | |
run: | | |
VERSION=$(grep -m1 'version =' Cargo.toml | cut -d '"' -f2) | |
sed -i "s/pkgver=.*/pkgver=$VERSION/" dist/arch/PKGBUILD | |
cp -r . "/tmp/modbus-relay" | |
cd /tmp | |
tar czf "modbus-relay.tar.gz" "modbus-relay" | |
- name: Build package | |
run: | | |
cd /tmp | |
mkdir -p pkg | |
cd pkg | |
mv ../modbus-relay.tar.gz . | |
cp /github/workspace/dist/arch/PKGBUILD . | |
CARCH=${{ matrix.arch }} makepkg -s --noconfirm | |
- name: Upload artifacts | |
uses: actions/upload-artifact@v3 | |
with: | |
name: pkg-${{ matrix.arch }} | |
path: /tmp/pkg/*.pkg.tar.zst | |
create-release: | |
name: Create Release | |
needs: [build-deb, build-arch] | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/download-artifact@v3 | |
- name: Create Release | |
uses: softprops/action-gh-release@v1 | |
with: | |
files: deb-*/*.deb pkg-*/*.pkg.tar.zst | |
generate_release_notes: true |