From 0a8d8c9fbfc721a2b6ec1533d2a28a1c518578e8 Mon Sep 17 00:00:00 2001 From: w3irdrobot Date: Mon, 20 Feb 2023 14:55:46 -0500 Subject: [PATCH] add release workflow on tags --- .github/workflows/golang_lint.yaml | 3 ++- .github/workflows/goreleaser.yaml | 27 ++++++++++++++++++++++++++ .github/workflows/push_tag.yaml | 11 +++++++++++ .goreleaser.yaml | 31 ++++++++++++++++++++++++++++++ 4 files changed, 71 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/goreleaser.yaml create mode 100644 .github/workflows/push_tag.yaml create mode 100644 .goreleaser.yaml diff --git a/.github/workflows/golang_lint.yaml b/.github/workflows/golang_lint.yaml index 3b16df5..80e0db5 100644 --- a/.github/workflows/golang_lint.yaml +++ b/.github/workflows/golang_lint.yaml @@ -10,7 +10,8 @@ jobs: steps: - uses: actions/setup-go@v3 with: - go-version: '1.20' + go-version: '1.20.1' + - uses: actions/checkout@v3 - name: golangci-lint diff --git a/.github/workflows/goreleaser.yaml b/.github/workflows/goreleaser.yaml new file mode 100644 index 0000000..af3fde6 --- /dev/null +++ b/.github/workflows/goreleaser.yaml @@ -0,0 +1,27 @@ +name: Goreleaser + +on: + workflow_call: + secrets: + GITHUB_TOKEN: + required: true + +jobs: + release: + runs-on: ubuntu-latest + steps: + - uses: actions/setup-go@v3 + with: + go-version: '1.20.1' + + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Run GoReleaser + uses: goreleaser/goreleaser-action@v4 + with: + version: latest + args: release --clean + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/push_tag.yaml b/.github/workflows/push_tag.yaml new file mode 100644 index 0000000..104bc9b --- /dev/null +++ b/.github/workflows/push_tag.yaml @@ -0,0 +1,11 @@ +name: Release + +on: + push: + tags: [ "*" ] + +jobs: + goreleaser: + uses: ./.github/workflows/goreleaser.yaml + secrets: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.goreleaser.yaml b/.goreleaser.yaml new file mode 100644 index 0000000..4c6dee0 --- /dev/null +++ b/.goreleaser.yaml @@ -0,0 +1,31 @@ +before: + hooks: + - go mod tidy +builds: +- env: + - CGO_ENABLED=0 + goos: + - linux + - windows + - darwin + +archives: +- format: tar.gz + # this name template makes the OS and Arch compatible with the results of uname. + name_template: >- + {{ .ProjectName }}_ + {{- title .Os }}_ + {{- if eq .Arch "amd64" }}x86_64 + {{- else if eq .Arch "386" }}i386 + {{- else }}{{ .Arch }}{{ end }} + {{- if .Arm }}v{{ .Arm }}{{ end }} + # use zip for windows archives + format_overrides: + - goos: windows + format: zip +checksum: + name_template: 'checksums.txt' +snapshot: + name_template: "{{ incpatch .Version }}-next" +changelog: + use: github-native