From 184440d5a7b2dc2443bc3691015ae474e74f7807 Mon Sep 17 00:00:00 2001 From: aceberg <1502200+aceberg@users.noreply.github.com> Date: Mon, 6 Nov 2023 13:16:57 +0700 Subject: [PATCH] Goreleaser for binaries --- .github/workflows/binary-release.yml | 26 +++----- .../{docker-readme.yml => readme-docker.yml} | 2 +- .goreleaser.yaml | 65 +++++++++++++++++++ build/ci/build-deb.sh | 34 ---------- build/ci/build.sh | 18 ----- configs/postinstall.sh | 3 + go.mod | 12 ++-- go.sum | 21 +++--- 8 files changed, 93 insertions(+), 88 deletions(-) rename .github/workflows/{docker-readme.yml => readme-docker.yml} (95%) create mode 100644 .goreleaser.yaml delete mode 100755 build/ci/build-deb.sh delete mode 100755 build/ci/build.sh create mode 100644 configs/postinstall.sh diff --git a/.github/workflows/binary-release.yml b/.github/workflows/binary-release.yml index aeeda16..79666a6 100644 --- a/.github/workflows/binary-release.yml +++ b/.github/workflows/binary-release.yml @@ -8,30 +8,20 @@ on: jobs: generate: name: Create release-artifacts - runs-on: ubuntu-22.04 + runs-on: ubuntu-latest 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 - - uses: actions/setup-go@v4 with: - go-version: '1.21.1' + go-version: 'stable' - run: go 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 }} + - uses: goreleaser/goreleaser-action@v5 with: - args: 'watchyourlan-*' \ No newline at end of file + distribution: goreleaser + version: latest + args: release --clean + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/docker-readme.yml b/.github/workflows/readme-docker.yml similarity index 95% rename from .github/workflows/docker-readme.yml rename to .github/workflows/readme-docker.yml index 8205277..9847bf6 100644 --- a/.github/workflows/docker-readme.yml +++ b/.github/workflows/readme-docker.yml @@ -1,4 +1,4 @@ -name: DockerHub-README +name: README-to-DockerHub on: workflow_dispatch: diff --git a/.goreleaser.yaml b/.goreleaser.yaml new file mode 100644 index 0000000..3b0b00f --- /dev/null +++ b/.goreleaser.yaml @@ -0,0 +1,65 @@ +project_name: watchyourlan +builds: + - main: ./cmd/WatchYourLAN/ + binary: watchyourlan + id: default + env: [CGO_ENABLED=0] + goos: + - linux + - windows + - darwin + goarch: + - 386 + - amd64 + - arm + - arm64 + goarm: + - "5" + - "6" + - "7" + ignore: + - goos: darwin + goarch: 386 + - goos: darwin + goarch: arm + - goos: windows + goarch: 386 + - goos: windows + goarch: arm + +nfpms: + - maintainer: aceberg + description: Lightweight network IP scanner with web GUI + homepage: https://github.com/aceberg/watchyourlan + license: MIT + section: utils + formats: + - deb + - rpm + - apk + - termux.deb + dependencies: # Don't forget to edit! + - arp-scan + - tzdata + contents: + - src: ./configs/watchyourlan.service + dst: /lib/systemd/system/watchyourlan.service + scripts: + postinstall: ./configs/postinstall.sh + +archives: + - files: + - LICENSE.md + - README.md + - CHANGELOG.md + - src: ./configs/watchyourlan.service + dst: watchyourlan.service + - src: ./configs/install.sh + dst: install.sh + wrap_in_directory: true + format_overrides: + - goos: windows + format: zip + +checksum: + name_template: "checksums.txt" diff --git a/build/ci/build-deb.sh b/build/ci/build-deb.sh deleted file mode 100755 index 20da021..0000000 --- a/build/ci/build-deb.sh +++ /dev/null @@ -1,34 +0,0 @@ -#!/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 -Depends: arp-scan, tzdata -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 deleted file mode 100755 index 4cbc1d2..0000000 --- a/build/ci/build.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/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/postinstall.sh b/configs/postinstall.sh new file mode 100644 index 0000000..e15db17 --- /dev/null +++ b/configs/postinstall.sh @@ -0,0 +1,3 @@ +#!/bin/sh + +systemctl daemon-reload \ No newline at end of file diff --git a/go.mod b/go.mod index 93ba163..3a9201a 100644 --- a/go.mod +++ b/go.mod @@ -1,14 +1,14 @@ module github.com/aceberg/WatchYourLAN -go 1.21.1 +go 1.21.2 require ( github.com/containrrr/shoutrrr v0.8.0 - github.com/google/uuid v1.3.1 + github.com/google/uuid v1.4.0 github.com/jmoiron/sqlx v1.3.5 github.com/spf13/viper v1.17.0 golang.org/x/crypto v0.14.0 - modernc.org/sqlite v1.26.0 + modernc.org/sqlite v1.27.0 ) require ( @@ -42,9 +42,9 @@ require ( lukechampine.com/uint128 v1.2.0 // indirect modernc.org/cc/v3 v3.40.0 // indirect modernc.org/ccgo/v3 v3.16.13 // indirect - modernc.org/libc v1.24.1 // indirect - modernc.org/mathutil v1.5.0 // indirect - modernc.org/memory v1.6.0 // indirect + modernc.org/libc v1.29.0 // indirect + modernc.org/mathutil v1.6.0 // indirect + modernc.org/memory v1.7.2 // indirect modernc.org/opt v0.1.3 // indirect modernc.org/strutil v1.1.3 // indirect modernc.org/token v1.0.1 // indirect diff --git a/go.sum b/go.sum index 068d030..9e34ead 100644 --- a/go.sum +++ b/go.sum @@ -132,8 +132,8 @@ github.com/google/pprof v0.0.0-20221118152302-e6195bd50e26 h1:Xim43kblpZXfIBQsbu github.com/google/pprof v0.0.0-20221118152302-e6195bd50e26/go.mod h1:dDKJzRmX4S37WGHujM7tX//fmj1uioxKzKxz3lo4HJo= github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/google/uuid v1.3.1 h1:KjJaJ9iWZ3jOFZIf1Lqf4laDRCasjl0BCmnEGxkdLb4= -github.com/google/uuid v1.3.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/google/uuid v1.4.0 h1:MtMxsa51/r9yyhkyLsVeVt0B+BGQZzpQiTQ4eHZ8bc4= +github.com/google/uuid v1.4.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= github.com/googleapis/google-cloud-go-testing v0.0.0-20200911160855-bcd43fbb19e8/go.mod h1:dvDLG8qkwmyD9a/MJJN3XJcT3xFxOKAvTZGvuZmac9g= @@ -186,7 +186,6 @@ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZN github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U= github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= -github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo= github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec h1:W09IVJc94icq4NjY3clb7Lk8O1qJ8BdBEF8z0ibU0rE= github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= @@ -558,16 +557,16 @@ modernc.org/ccorpus v1.11.6 h1:J16RXiiqiCgua6+ZvQot4yUuUy8zxgqbqEEUuGPlISk= modernc.org/ccorpus v1.11.6/go.mod h1:2gEUTrWqdpH2pXsmTM1ZkjeSrUWDpjMu2T6m29L/ErQ= modernc.org/httpfs v1.0.6 h1:AAgIpFZRXuYnkjftxTAZwMIiwEqAfk8aVB2/oA6nAeM= modernc.org/httpfs v1.0.6/go.mod h1:7dosgurJGp0sPaRanU53W4xZYKh14wfzX420oZADeHM= -modernc.org/libc v1.24.1 h1:uvJSeCKL/AgzBo2yYIPPTy82v21KgGnizcGYfBHaNuM= -modernc.org/libc v1.24.1/go.mod h1:FmfO1RLrU3MHJfyi9eYYmZBfi/R+tqZ6+hQ3yQQUkak= -modernc.org/mathutil v1.5.0 h1:rV0Ko/6SfM+8G+yKiyI830l3Wuz1zRutdslNoQ0kfiQ= -modernc.org/mathutil v1.5.0/go.mod h1:mZW8CKdRPY1v87qxC/wUdX5O1qDzXMP5TH3wjfpga6E= -modernc.org/memory v1.6.0 h1:i6mzavxrE9a30whzMfwf7XWVODx2r5OYXvU46cirX7o= -modernc.org/memory v1.6.0/go.mod h1:PkUhL0Mugw21sHPeskwZW4D6VscE/GQJOnIpCnW6pSU= +modernc.org/libc v1.29.0 h1:tTFRFq69YKCF2QyGNuRUQxKBm1uZZLubf6Cjh/pVHXs= +modernc.org/libc v1.29.0/go.mod h1:DaG/4Q3LRRdqpiLyP0C2m1B8ZMGkQ+cCgOIjEtQlYhQ= +modernc.org/mathutil v1.6.0 h1:fRe9+AmYlaej+64JsEEhoWuAYBkOtQiMEU7n/XgfYi4= +modernc.org/mathutil v1.6.0/go.mod h1:Ui5Q9q1TR2gFm0AQRqQUaBWFLAhQpCwNcuhBOSedWPo= +modernc.org/memory v1.7.2 h1:Klh90S215mmH8c9gO98QxQFsY+W451E8AnzjoE2ee1E= +modernc.org/memory v1.7.2/go.mod h1:NO4NVCQy0N7ln+T9ngWqOQfi7ley4vpwvARR+Hjw95E= modernc.org/opt v0.1.3 h1:3XOZf2yznlhC+ibLltsDGzABUGVx8J6pnFMS3E4dcq4= modernc.org/opt v0.1.3/go.mod h1:WdSiB5evDcignE70guQKxYUl14mgWtbClRi5wmkkTX0= -modernc.org/sqlite v1.26.0 h1:SocQdLRSYlA8W99V8YH0NES75thx19d9sB/aFc4R8Lw= -modernc.org/sqlite v1.26.0/go.mod h1:FL3pVXie73rg3Rii6V/u5BoHlSoyeZeIgKZEgHARyCU= +modernc.org/sqlite v1.27.0 h1:MpKAHoyYB7xqcwnUwkuD+npwEa0fojF0B5QRbN+auJ8= +modernc.org/sqlite v1.27.0/go.mod h1:Qxpazz0zH8Z1xCFyi5GSL3FzbtZ3fvbjmywNogldEW0= modernc.org/strutil v1.1.3 h1:fNMm+oJklMGYfU9Ylcywl0CO5O6nTfaowNsh2wpPjzY= modernc.org/strutil v1.1.3/go.mod h1:MEHNA7PdEnEwLvspRMtWTNnp2nnyvMfkimT1NKNAGbw= modernc.org/tcl v1.15.2 h1:C4ybAYCGJw968e+Me18oW55kD/FexcHbqH2xak1ROSY=