From 7d193fb35e21b74c13af2ed563eb70ead45b1953 Mon Sep 17 00:00:00 2001 From: Kristoffer Lind Date: Sun, 6 Nov 2022 15:18:51 +0100 Subject: [PATCH] add test and release workflows --- .github/workflows/release.yml | 36 +++++++++++++++++++++++++++++++++++ .github/workflows/test.yml | 35 ++++++++++++++++++++++++++++++++++ .goreleaser.yaml | 2 ++ Makefile | 2 +- shell.nix | 2 +- 5 files changed, 75 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/release.yml create mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..b20c21b --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,36 @@ +name: Release + +on: + push: + tags: + - 'v*' + +permissions: + contents: write + +env: + GO_VERSION: '1.19.2' + +jobs: + tests: + uses: ./.github/workflows/test.yml + goreleaser: + runs-on: ubuntu-latest + needs: tests + timeout-minutes: 10 + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + - uses: actions/setup-go@v3 + with: + go-version: ${{ env.GO_VERSION }} + cache: true + - name: Run GoReleaser + uses: goreleaser/goreleaser-action@v2 + with: + distribution: goreleaser + version: latest + args: release --rm-dist + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..352a861 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,35 @@ +name: Test + +on: + pull_request: + paths-ignore: + - 'README.md' + workflow_call: + +permissions: + contents: read + +env: + GO_VERSION: '1.19.2' + +jobs: + build: + name: Build + runs-on: ubuntu-latest + timeout-minutes: 5 + steps: + - uses: actions/setup-go@v3 + with: + go-version: ${{ env.GO_VERSION }} + - uses: actions/checkout@v3 + - run: make build + + test: + name: Test + needs: build + runs-on: ubuntu-latest + timeout-minutes: 5 + steps: + - uses: cachix/install-nix-action@v15 + - uses: actions/checkout@v3 + - script: nix-shell --pure --command "make test" diff --git a/.goreleaser.yaml b/.goreleaser.yaml index 2a6ef21..140a105 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -17,5 +17,7 @@ archives: amd64: x86_64 checksum: name_template: 'checksums.txt' +snapshot: + name_template: "{{ incpatch .Version }}-next" changelog: skip: true diff --git a/Makefile b/Makefile index 5aaca22..c3e90dc 100644 --- a/Makefile +++ b/Makefile @@ -12,6 +12,6 @@ test: build docker-compose down test-release: - goreleaser release --rm-dist --skip-publish --skip-sign --snapshot + goreleaser release --rm-dist --skip-publish --snapshot .PHONY: build install test-release diff --git a/shell.nix b/shell.nix index 58af746..a24773b 100644 --- a/shell.nix +++ b/shell.nix @@ -7,6 +7,6 @@ pkgs.mkShell { pkgs.docker pkgs.docker-compose pkgs.git - pkgs.go_1_18 + pkgs.go ]; }