From 7c218fc664c4559062f48784b78f1f5383e567b1 Mon Sep 17 00:00:00 2001 From: Marco Realacci Date: Tue, 28 Jan 2025 19:02:32 +0100 Subject: [PATCH] add build workflow --- .forgejo/workflows/build-debian-package.yml | 44 +++++++++++++++++++++ debian/changelog.in | 5 +++ debian/control | 12 ++++++ debian/install | 2 + debian/rules | 3 ++ debian/source/format | 1 + main.py => src/main.py | 0 7 files changed, 67 insertions(+) create mode 100644 .forgejo/workflows/build-debian-package.yml create mode 100644 debian/changelog.in create mode 100644 debian/control create mode 100644 debian/install create mode 100644 debian/rules create mode 100644 debian/source/format rename main.py => src/main.py (100%) diff --git a/.forgejo/workflows/build-debian-package.yml b/.forgejo/workflows/build-debian-package.yml new file mode 100644 index 0000000..aa6ca00 --- /dev/null +++ b/.forgejo/workflows/build-debian-package.yml @@ -0,0 +1,44 @@ +name: Build and Deploy Debian Package + +on: + push: + tags: + - '*' + +jobs: + build-package: + runs-on: docker + container: + image: catthehacker/ubuntu:act-latest + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Parse distribution + run: | + if [[ "$GITHUB_REF_NAME" == *"@stable"* ]]; then + echo "DISTRO=stable" >> $GITHUB_ENV + else + echo "DISTRO=unstable" >> $GITHUB_ENV + fi + + - name: Setup Debian Packaging + run: | + sudo apt-get update + sudo apt-get install -y devscripts debhelper dh-python dh-systemd build-essential + + - name: Build Debian Package + run: | + debuild -us -uc -b + + - name: Upload to Forgejo Debian Registry + env: + FORGEJO_TOKEN: ${{ secrets.FORGEJO_TOKEN }} + run: | + PACKAGE_NAME="magicfw_0.1.0-1_all.deb" # Update version accordingly + DISTRO="debian" # e.g., bullseye, bookworm + COMPONENT="main" + + curl --user "your_username:$FORGEJO_TOKEN" \ + --upload-file ../${PACKAGE_NAME} \ + "https://git.marcorealacci.me/api/packages/${{ github.repository_owner }}/debian/pool/${DISTRO}/${COMPONENT}/${PACKAGE_NAME}" \ No newline at end of file diff --git a/debian/changelog.in b/debian/changelog.in new file mode 100644 index 0000000..b759478 --- /dev/null +++ b/debian/changelog.in @@ -0,0 +1,5 @@ +magicfw ({{VERSION}}) unstable; urgency=medium + + * Automatic release from Git tag {{TAG}} + + -- Auto Release Bot $(date -R) \ No newline at end of file diff --git a/debian/control b/debian/control new file mode 100644 index 0000000..1b68312 --- /dev/null +++ b/debian/control @@ -0,0 +1,12 @@ +Source: magicfw +Section: utils +Priority: optional +Maintainer: Marco Realacci +Build-Depends: debhelper-compat (= 13), dh-python, python3-all +Standards-Version: 4.6.0 + +Package: magicfw +Architecture: all +Depends: ${python3:Depends}, ${misc:Depends} +Description: A magic firewall service + Automatic build from Git tag ${TAG}. \ No newline at end of file diff --git a/debian/install b/debian/install new file mode 100644 index 0000000..8ccaa70 --- /dev/null +++ b/debian/install @@ -0,0 +1,2 @@ +src/main.py usr/bin/ +systemd/magicfw.service lib/systemd/system/ \ No newline at end of file diff --git a/debian/rules b/debian/rules new file mode 100644 index 0000000..a81fae6 --- /dev/null +++ b/debian/rules @@ -0,0 +1,3 @@ +#!/usr/bin/make -f +%: + dh $@ --with python3,systemd --buildsystem=pybuild \ No newline at end of file diff --git a/debian/source/format b/debian/source/format new file mode 100644 index 0000000..46ebe02 --- /dev/null +++ b/debian/source/format @@ -0,0 +1 @@ +3.0 (quilt) \ No newline at end of file diff --git a/main.py b/src/main.py similarity index 100% rename from main.py rename to src/main.py