From 8c534e236ed9e3f2f95676c71e34bc124f3507ec Mon Sep 17 00:00:00 2001 From: Ryan McKern Date: Fri, 19 Jan 2024 15:15:51 -0800 Subject: [PATCH] Rework build system goreleaser will now be utilized to build and ship releases, as well as ensure consistent builds for intermediate commits and pull requests. --- .github/workflows/build.yml | 28 ++++++++++++++++++ .../workflows/{golangci-lint.yml => lint.yml} | 8 ++--- .github/workflows/release.yml | 29 +++++++++++++++++++ .github/workflows/{go.yml => test.yml} | 2 +- Makefile | 8 ++--- 5 files changed, 64 insertions(+), 11 deletions(-) create mode 100644 .github/workflows/build.yml rename .github/workflows/{golangci-lint.yml => lint.yml} (80%) create mode 100644 .github/workflows/release.yml rename .github/workflows/{go.yml => test.yml} (96%) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..e368327 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,28 @@ +name: build + +on: + pull_request: + push: + +permissions: + contents: read + +jobs: + goreleaser: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - uses: actions/setup-go@v5 + with: + go-version: "1.21" + cache: false + - name: build golines + uses: goreleaser/goreleaser-action@v5 + with: + distribution: goreleaser + version: latest + args: build --clean --snapshot --single-target + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/lint.yml similarity index 80% rename from .github/workflows/golangci-lint.yml rename to .github/workflows/lint.yml index 4c82035..43a7723 100644 --- a/.github/workflows/golangci-lint.yml +++ b/.github/workflows/lint.yml @@ -1,4 +1,4 @@ -name: golangci-lint +name: lint on: push: branches: @@ -11,15 +11,15 @@ permissions: jobs: golangci: - name: lint + name: golines lint runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: actions/setup-go@v5 with: go-version: "1.21" cache: false - - name: golangci-lint + - name: run golangci-lint uses: golangci/golangci-lint-action@v3 with: version: latest diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..c266274 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,29 @@ +name: release + +on: + push: + tags: + - "*" + +permissions: + contents: write + +jobs: + goreleaser: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - uses: actions/setup-go@v5 + with: + go-version: "1.21" + cache: false + - name: release golines + uses: goreleaser/goreleaser-action@v5 + with: + distribution: goreleaser + version: latest + args: release --clean + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/go.yml b/.github/workflows/test.yml similarity index 96% rename from .github/workflows/go.yml rename to .github/workflows/test.yml index 4f8f775..74e97cc 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/test.yml @@ -1,4 +1,4 @@ -name: golines test +name: test on: push: branches: diff --git a/Makefile b/Makefile index c92f4fa..29490d4 100644 --- a/Makefile +++ b/Makefile @@ -1,15 +1,11 @@ export GO111MODULE=on .PHONY: all -all: install test - -.PHONY: install -install: - go install . +all: build test .PHONY: build build: - go build . + goreleaser build --clean --snapshot --single-target .PHONY: test test: vet