From 5baf134df2c879078bc7e9259ef214f0da030384 Mon Sep 17 00:00:00 2001 From: aceberg <1502200+aceberg@users.noreply.github.com> Date: Thu, 29 Dec 2022 12:52:46 +0700 Subject: [PATCH] Binary and Deb --- .github/workflows/release.yml | 32 ++++++++++++++++++++++++++++++++ build/ci/build-deb.sh | 33 +++++++++++++++++++++++++++++++++ build/ci/build.sh | 18 ++++++++++++++++++ configs/install.sh | 4 ++++ configs/watchyourlan.service | 12 ++++++++++++ 5 files changed, 99 insertions(+) create mode 100644 .github/workflows/release.yml create mode 100755 build/ci/build-deb.sh create mode 100755 build/ci/build.sh create mode 100755 configs/install.sh create mode 100644 configs/watchyourlan.service diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..13cf444 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,32 @@ +name: Binary-release + +on: + workflow_dispatch: + release: + types: [created] + +jobs: + generate: + name: Create release-artifacts + runs-on: ubuntu-20.04 + steps: + - name: Checkout the repository + uses: actions/checkout@master + + - name: Get version tag from env file + uses: c-py/action-dotenv-to-setenv@v2 + with: + env-file: .version + + - name: Build and archive + run: build/ci/build.sh ${{ env.VERSION }} + + - name: Build .deb package + run: build/ci/build-deb.sh ${{ env.VERSION }} + + - name: Upload the artifacts + uses: skx/github-action-publish-binaries@master + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + args: 'watchyourlan-*' \ No newline at end of file diff --git a/build/ci/build-deb.sh b/build/ci/build-deb.sh new file mode 100755 index 0000000..79434e2 --- /dev/null +++ b/build/ci/build-deb.sh @@ -0,0 +1,33 @@ +#!/bin/bash + +PKGDIR=watchyourlan-$1-0_all + +umask 0022 + +mkdir -p $PKGDIR/usr/bin +mkdir -p $PKGDIR/lib/systemd/system + +cp configs/watchyourlan.service $PKGDIR/lib/systemd/system/ + +cp watchyourlan $PKGDIR/usr/bin/ + +mkdir -p $PKGDIR/DEBIAN + +echo "Package: watchyourlan +Version: $1 +Section: utils +Priority: optional +Architecture: all +Maintainer: aceberg +Description: Lightweight network IP scanner with web GUI +" > $PKGDIR/DEBIAN/control + +echo " +systemctl daemon-reload +" > $PKGDIR/DEBIAN/postinst + +chmod 775 $PKGDIR/DEBIAN/postinst + +dpkg-deb --build --root-owner-group $PKGDIR + +rm -rf $PKGDIR \ No newline at end of file diff --git a/build/ci/build.sh b/build/ci/build.sh new file mode 100755 index 0000000..4cbc1d2 --- /dev/null +++ b/build/ci/build.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +cd cmd/WatchYourLAN/ && CGO_ENABLED=0 go build -o ../../watchyourlan . +cd ../../ + +PKGDIR=/opt/watchyourlan + +umask 0022 + +mkdir -p $PKGDIR +cp watchyourlan $PKGDIR/ +cp configs/watchyourlan.service $PKGDIR/ +cp configs/install.sh $PKGDIR/ + +cd /opt +tar cvzf watchyourlan-$1.tar.gz watchyourlan +cd - +cp /opt/watchyourlan-$1.tar.gz . \ No newline at end of file diff --git a/configs/install.sh b/configs/install.sh new file mode 100755 index 0000000..25f3fbb --- /dev/null +++ b/configs/install.sh @@ -0,0 +1,4 @@ +#!/bin/sh + +cp watchyourlan /usr/bin/ +cp watchyourlan.service /lib/systemd/system/ \ No newline at end of file diff --git a/configs/watchyourlan.service b/configs/watchyourlan.service new file mode 100644 index 0000000..4258359 --- /dev/null +++ b/configs/watchyourlan.service @@ -0,0 +1,12 @@ +[Unit] +Description=watchyourlan +Documentation=https://github.com/aceberg/WatchYourLAN +After=network-online.target +Wants=network-online.target + +[Service] +ExecStart=/usr/bin/watchyourlan -c /etc/watchyourlan/config +Restart=on-failure + +[Install] +WantedBy=multi-user.target \ No newline at end of file