From a8b2f5416b8db201f2c7ce5551f3cfffffe969d7 Mon Sep 17 00:00:00 2001 From: Florian Thienel Date: Fri, 2 Apr 2021 16:38:44 +0200 Subject: [PATCH] build a binary deb package instead of a source package - life is way too short for all this hassle! --- {debian => .debpkg/DEBIAN}/control | 17 ++--- .../lib/systemd/system}/hamdeck.service | 0 .../lib/udev/rules.d/99-hamdeck.rules | 0 .github/workflows/ci.yml | 48 +++++++++++++ .github/workflows/release.yml | 72 +++++++++++++++++++ build-debpkg.sh | 3 + debian/changelog | 5 -- debian/compat | 1 - debian/rules | 39 ---------- 9 files changed, 129 insertions(+), 56 deletions(-) rename {debian => .debpkg/DEBIAN}/control (67%) rename {debian => .debpkg/lib/systemd/system}/hamdeck.service (100%) rename debian/hamdeck.udev => .debpkg/lib/udev/rules.d/99-hamdeck.rules (100%) create mode 100644 .github/workflows/ci.yml create mode 100644 .github/workflows/release.yml create mode 100755 build-debpkg.sh delete mode 100644 debian/changelog delete mode 100644 debian/compat delete mode 100755 debian/rules diff --git a/debian/control b/.debpkg/DEBIAN/control similarity index 67% rename from debian/control rename to .debpkg/DEBIAN/control index a7b2391..b5e8f55 100644 --- a/debian/control +++ b/.debpkg/DEBIAN/control @@ -1,16 +1,11 @@ -Source: hamdeck -Section: ham -Priority: extra +Package: hamdeck +Architecture: amd64 +Section: universe/hamradio +Priority: optional +Version: !THE_VERSION! Maintainer: Florian Thienel Homepage: http://github.com/ftl/hamdeck -Build-Depends: - debhelper (>= 12), - golang-go (>= 2:1.16), - libhidapi-libusb0 (>= 0.9) - -Package: hamdeck -Architecture: amd64 i386 armhf -Recommends: pulseaudio +Bugs: http://github.com/ftl/hamdeck/issues Description: HamDeck allows you to control and automate your ham radio station using an Elgato Stream Deck device. You can define buttons using a JSON configuration file. HamDeck connects to the local pulseaudio server, to a diff --git a/debian/hamdeck.service b/.debpkg/lib/systemd/system/hamdeck.service similarity index 100% rename from debian/hamdeck.service rename to .debpkg/lib/systemd/system/hamdeck.service diff --git a/debian/hamdeck.udev b/.debpkg/lib/udev/rules.d/99-hamdeck.rules similarity index 100% rename from debian/hamdeck.udev rename to .debpkg/lib/udev/rules.d/99-hamdeck.rules diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..5ec6cc1 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,48 @@ +name: Continuous Build + +on: + push: + branches: + - master + - "**" + pull_request: + branches: + - master + +jobs: + + build: + name: Continuous Build + runs-on: ubuntu-20.04 + steps: + - name: Install Linux packages + run: sudo apt update && sudo apt install -y --no-install-recommends debhelper libhidapi-libusb0 + + - name: Set up Go 1.16 + uses: actions/setup-go@v2 + with: + go-version: 1.16 + id: go + + - name: Check out code into the Go module directory + uses: actions/checkout@v2 + + - name: Caching build artifacts and modules + uses: actions/cache@v2 + with: + path: | + ~/go/pkg/mod + ~/.cache/go-build + key: ${{ runner.os }}-go-modules-${{ hashFiles('**/go.sum') }} + + - name: Get dependencies + run: go get -v -t -d ./... + + - name: Build and Test + run: env VERSION=ci@$GITHUB_REF make + + - name: 'Upload binary for linux_x86_64' + uses: actions/upload-artifact@v2 + with: + name: hamdeck-binary + path: ./hamdeck diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..3d83d68 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,72 @@ +name: Release Build + +on: + push: + tags: + - 'v*.*.*' + branches: + - releng + +jobs: + + build: + name: Release Build + runs-on: ubuntu-20.04 + steps: + - id: version_number + run: echo "::set-output name=version_number::$(echo '${{github.ref}}' | sed -E 's#refs/tags/v##')" + + - name: Install Linux packages + run: sudo apt update && sudo apt install -y --no-install-recommends debhelper libhidapi-libusb0 + + - name: Set up Go 1.16 + uses: actions/setup-go@v2 + with: + go-version: 1.16 + id: go + + - name: Check out code into the Go module directory + uses: actions/checkout@v2 + + - name: Caching build artifacts and modules + uses: actions/cache@v2 + with: + path: | + ~/go/pkg/mod + ~/.cache/go-build + key: ${{ runner.os }}-go-modules-${{ hashFiles('**/go.sum') }} + + - name: Get dependencies + run: go get -v -t -d ./... + + - name: Build and Test + run: | + echo "Version ${{ steps.version_number.outputs.version_number }}" + env VERSION="${{ steps.version_number.outputs.version_number }}" make + + - name: Create package structure + run: | + mkdir -p ./.debpkg/usr/bin + cp ./hamdeck ./.debpkg/usr/bin/hamdeck + chmod +x ./.debpkg/usr/bin/hamdeck + mkdir -p ./.debpkg/usr/share/hamdeck + cp ./example_conf.json ./.debpkg/usr/share/hamdeck/example_conf.json + + - name: Create deb package + run: ./build-debpkg.sh ${{ steps.version_number.outputs.version_number }} + + - id: package_filename + run: echo "::set-output name=package_filename::$(ls ./hamdeck*.deb | head -n 1)" + + - name: 'Upload package for linux_x86_64' + uses: actions/upload-artifact@v2 + with: + name: hamdeck-package + path: ./hamdeck*.deb + + - name: Upload package to release + uses: svenstaro/upload-release-action@v2 + with: + repo_token: ${{ secrets.GITHUB_TOKEN }} + file: ${{ steps.package_filename.outputs.package_filename }} + tag: ${{ github.ref }} diff --git a/build-debpkg.sh b/build-debpkg.sh new file mode 100755 index 0000000..afe2b2b --- /dev/null +++ b/build-debpkg.sh @@ -0,0 +1,3 @@ +#!/bin/bash +sed -i -E "s#!THE_VERSION!#$1#" ./.debpkg/DEBIAN/control +dpkg-deb --build ./.debpkg . diff --git a/debian/changelog b/debian/changelog deleted file mode 100644 index 66fa40b..0000000 --- a/debian/changelog +++ /dev/null @@ -1,5 +0,0 @@ -hamdeck (0.1.0) UNRELEASED; urgency=medium - - * Initial release. - - -- Florian Thienel Mon, 15 Mar 2021 20:04:33 +0100 diff --git a/debian/compat b/debian/compat deleted file mode 100644 index f11c82a..0000000 --- a/debian/compat +++ /dev/null @@ -1 +0,0 @@ -9 \ No newline at end of file diff --git a/debian/rules b/debian/rules deleted file mode 100755 index 71a5c32..0000000 --- a/debian/rules +++ /dev/null @@ -1,39 +0,0 @@ -#!/usr/bin/make -f -# -*- makefile -*- - -VERSION?= $(shell < debian/changelog head -1 | egrep -o "[0-9]+\.[0-9]+\.[0-9]+") -PKGDIR = debian/hamdeck - -%: - dh $@ - -clean: - dh_clean - rm -rf $(PKGDIR) - -build: - env VERSION=$(VERSION) make - -binary-arch: clean build - dh_prep - dh_installdirs - - mkdir -p $(PKGDIR)/usr/bin - mkdir -p $(PKGDIR)/usr/share/hamdeck - mkdir -p $(PKGDIR)/lib/udev/rules.d - mkdir -p $(PKGDIR)/lib/systemd/system - - mv ./hamdeck $(PKGDIR)/usr/bin/ - cp example_conf.json $(PKGDIR)/usr/share/hamdeck/ - - dh_strip - dh_compress - dh_fixperms - dh_installinit - dh_installdeb - dh_installudev - dh_gencontrol - dh_md5sums - dh_builddeb - -binary: binary-arch