kinjo 0.3.8

Kinjo: mDNS TUI and commands launch for local network services
Documentation
name: Build Debian release packages

on:
  workflow_call:
    inputs:
      version:
        required: true
        type: string
      ref:
        description: "Exact release commit to check out and package."
        required: true
        type: string

permissions:
  contents: read

env:
  CARGO_TERM_COLOR: always

jobs:
  deb:
    name: Debian package on ${{ matrix.arch }}
    timeout-minutes: 35
    strategy:
      fail-fast: false
      matrix:
        include:
          - arch: amd64
            os: ubuntu-24.04
          - arch: arm64
            os: ubuntu-24.04-arm

    runs-on: ${{ matrix.os }}
    steps:
      - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
        with:
          ref: ${{ inputs.ref }}
          persist-credentials: false

      - name: Check candidate identity
        env:
          VERSION: ${{ inputs.version }}
        run: scripts/release/check-version.sh manifest "$VERSION"

      - name: Set up build environment
        uses: ./.github/actions/setup

      - name: Install cargo-deb
        uses: taiki-e/cache-cargo-install-action@417450f3c33ee20393705369577571770643d4c7 # v3
        with:
          tool: cargo-deb@3.7.0

      - name: Build and inspect Debian package
        env:
          VERSION: ${{ inputs.version }}
        run: |
          SOURCE_DATE_EPOCH="$(git show -s --format=%ct HEAD)"
          export SOURCE_DATE_EPOCH
          cargo deb --locked --verbose
          package="$(find target/debian -maxdepth 1 -name '*.deb' -print -quit)"
          test -n "$package"
          dpkg-deb --info "$package"
          dpkg-deb --contents "$package"
          dpkg-deb --field "$package" Version | grep -Fx "${VERSION}-1"
          dpkg-deb --field "$package" Architecture | grep -Fx "${{ matrix.arch }}"
          dpkg-deb --fsys-tarfile "$package" | tar -tf - > package-contents.txt
          grep -Fx './usr/bin/kinjo' package-contents.txt
          grep -Fx './usr/share/doc/kinjo/README.md' package-contents.txt
          grep -Fx './usr/share/doc/kinjo/LICENSE' package-contents.txt
          grep -Eq '^\./etc/kinjo/commands/[^/]+\.toml$' package-contents.txt
          sudo apt-get update
          sudo apt-get install -y "./$package"
          test -x "$(command -v kinjo)"
          kinjo --version | grep -F "$VERSION"

      - name: Upload staged Debian package
        uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
        with:
          name: release-deb-${{ matrix.arch }}-${{ inputs.version }}
          path: target/debian/*.deb
          if-no-files-found: error
          retention-days: 7