Binary and Deb

This commit is contained in:
aceberg 2022-12-29 12:52:46 +07:00
parent 9029d46ea8
commit 5baf134df2
5 changed files with 99 additions and 0 deletions

32
.github/workflows/release.yml vendored Normal file
View file

@ -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-*'

33
build/ci/build-deb.sh Executable file
View file

@ -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 <aceberg_a@proton.me>
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

18
build/ci/build.sh Executable file
View file

@ -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 .

4
configs/install.sh Executable file
View file

@ -0,0 +1,4 @@
#!/bin/sh
cp watchyourlan /usr/bin/
cp watchyourlan.service /lib/systemd/system/

View file

@ -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