From 5746a1a4fdc6253fd29f60c1eb2960d1af26fe67 Mon Sep 17 00:00:00 2001 From: Sam Willcocks Date: Thu, 4 May 2023 23:12:16 +0100 Subject: [PATCH] Add building via gh workflows --- .github/workflows/main.yml | 29 +++++++++++++++++++++++++++++ .goreleaser.yaml | 28 ++++++++++++++++++++++++++++ flake.nix | 2 +- 3 files changed, 58 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/main.yml create mode 100644 .goreleaser.yaml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..e004418 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,29 @@ +name: main + +on: push + +jobs: + test: + name: Test + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: cachix/install-nix-action@v19 + - run: nix develop -c go generate + - run: nix develop -c go test + + release: + name: Build Release + if: startsWith(github.event.ref, 'refs/tags/v') + needs: + - test + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: cachix/install-nix-action@v19 + - run: nix develop -c goreleaser release + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - uses: softprops/action-gh-release@v1 + with: + files: "*.deb" diff --git a/.goreleaser.yaml b/.goreleaser.yaml new file mode 100644 index 0000000..0ce648d --- /dev/null +++ b/.goreleaser.yaml @@ -0,0 +1,28 @@ +builds: + - id: debanator + main: ./cmd/main.go + ldflags: + - -s -w + - -X github.com/wlcx/debanator.Version={{.Version}} + - -X github.com/wlcx/debanator.Commit={{.ShortCommit}} + env: + - CGO_ENABLED=0 + goos: + - linux + - darwin + goarch: + - arm + - arm64 + - amd64 + goarm: + - 7 + +nfpms: + - id: debanator + package_name: debanator + vendor: wlcx industries + builds: + - debanator + maintainer: Sam W + formats: + - deb diff --git a/flake.nix b/flake.nix index ec83545..33a4a61 100644 --- a/flake.nix +++ b/flake.nix @@ -30,7 +30,7 @@ apps.default = utils.lib.mkApp {drv = packages.default;}; devShells.default = - pkgs.devshell.mkShell {packages = with pkgs; [go gopls];}; + pkgs.devshell.mkShell {packages = with pkgs; [go gopls goreleaser];}; formatter = pkgs.alejandra; }); }