Skip to content

Commit

Permalink
Migrate to GoReleaser
Browse files Browse the repository at this point in the history
Use goreleaser insead of `ncipollo/release-action@v1`

Closes: #109
  • Loading branch information
tempusfrangit committed Dec 12, 2023
1 parent f61c3f8 commit 8362cf1
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 12 deletions.
31 changes: 20 additions & 11 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ jobs:
run: CHECKONLY=1 script/format

build:
name: Build
name: "Build"
runs-on: ubuntu-latest-8-cores
steps:
- uses: actions/checkout@v4
Expand All @@ -55,13 +55,22 @@ jobs:
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
- run: "make checksum"
- uses: ncipollo/release-action@v1
if: github.ref_type=='tag' && !contains(github.ref_name, '-')
with:
artifacts: "pget, sha256sum.txt"
- uses: ncipollo/release-action@v1
if: github.ref_type=='tag' && contains(github.ref_name, '-')
with:
artifacts: "pget, sha256sum.txt"
prerelease: true
- run: make

release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-go@v4
with:
go-version-file: go.mod
- name: Build
run: make pget
- uses: goreleaser/goreleaser-action@v4
with:
version: latest
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
41 changes: 41 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
before:
hooks:
- go mod tidy
builds:
- binary: pget
id: pget
env:
- CGO_ENABLED=0
goos:
- darwin
- linux
goarch:
- amd64
- arm64
main: ./main.go
ldflags:
- "-s -w -X github.com/replicate/pget/pkg/version.Version={{.Version}} -X github.com/replicate/pget/pkg/version.CommitHash={{.Commit}} -X github.com/replicate/pget/pkg/version.BuildTime={{.Date}}"
archives:
- format: binary
name_template: >-
{{ .ProjectName }}_{{ .Os }}_
{{- if eq .Arch "amd64" }}x86_64
{{- else if eq .Arch "386" }}i386
{{- else }}{{ .Arch }}
{{end}}
checksum:
name_template: "checksums.txt"
snapshot:
name_template: "{{ .Tag }}-next"
changelog:
sort: asc
filters:
exclude:
- "^docs:"
- "^test:"
release:
# If set to auto, will mark the release as not ready for production
# in case there is an indicator for this in the tag e.g. v1.0.0-alpha
# If set to true, will mark the release as not ready for production.
# Default is false.
prerelease: auto
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ LD_FLAGS := -ldflags "-extldflags '-static' -X github.com/replicate/pget/pkg/ver
default: all

.PHONY: all
all: clean pget
all: clean pget checksum

pget:
CGO_ENABLED=0 $(GO) build -o $@ \
Expand Down

0 comments on commit 8362cf1

Please sign in to comment.