Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate to GoReleaser #116

Merged
merged 2 commits into from
Dec 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 28 additions & 12 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
lint:
name: "Lint"
if: ${{ github.event_name == 'pull_request' }}
runs-on: ubuntu-latest-8-cores
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
Expand All @@ -46,22 +46,38 @@ jobs:
run: CHECKONLY=1 script/format

build:
name: Build
runs-on: ubuntu-latest-8-cores
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
name: "Checkout"
with:
fetch-depth: 0
- uses: actions/setup-go@v5
name: "Set up Go"
with:
go-version-file: go.mod
- run: "make checksum"
- uses: ncipollo/release-action@v1
if: github.ref_type=='tag' && !contains(github.ref_name, '-')
- uses: goreleaser/goreleaser-action@v5
name: "Build Snapshot"
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
version: latest
args: build --clean --snapshot

release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
name: "Checkout"
with:
fetch-depth: 0
- uses: actions/setup-go@v5
name: "Set up Go"
with:
go-version-file: go.mod
- uses: goreleaser/goreleaser-action@v5
name: "Release"
if: startsWith(github.ref, 'refs/tags/')
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={{.ShortCommit}} -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
Loading