Skip to content

Commit

Permalink
update releaser config
Browse files Browse the repository at this point in the history
  • Loading branch information
kulapard committed Dec 9, 2023
1 parent 6eb3e8a commit af98e06
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 21 deletions.
60 changes: 42 additions & 18 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -1,45 +1,69 @@
version: 1

before:
hooks:
- go mod tidy
- go generate ./...

builds:
- id: eatme
binary: eatme
main: ./cmd/eatme
ldflags:
- -s
- -w
- -X main.version={{.Summary}}
mod_timestamp: '{{ .CommitTimestamp }}'
dir: cmd/eatme
ldflags: "-s -w -X main.revision={{.Tag}}-{{.ShortCommit}}-{{.CommitDate}}"
env:
- CGO_ENABLED=0
goos:
- linux
- windows
- darwin
goarch:
- amd64
- arm
- arm64
ignore:
- goos: freebsd
goarch: arm
- goos: freebsd
goarch: arm64
- goos: windows
goarch: arm
- goos: windows
goarch: arm64

brews:
- name: eatme
goarm: "6"
goamd64: v3
- name: gol
repository:
owner: kulapard
name: homebrew-tap
branch: master
token: "{{ .Env.HOMEBREW_TAP_GITHUB_TOKEN }}"
url_template: "https://github.com/kulapard/go-eatme/releases/download/{{ .Tag }}/{{ .ArtifactName }}"
commit_author:
name: goreleaserbot
email: taras+goreleaserbot@drapalyuk.com
commit_msg_template: "Brew formula update for {{ .ProjectName }} version {{ .Tag }}"
name: Taras Drapalyuk
email: taras@drapalyuk.com
commit_msg_template: "Brew formula update for `{{ .ProjectName }}` version `{{ .Tag }}`"
folder: Formula
homepage: "https://github.com/kulapard/go-eatme"
description: "Simple tool to manage multiple git/hg repositories at once. It goes through all subdirectories recursively and concurrently execute specified command in all af them."
license: "MIT"
test: |
system "#{bin}/eatme branch"
checksum:
name_template: 'checksums.txt'
snapshot:
name_template: "{{ incpatch .Version }}-next"
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

changelog:
sort: asc

checksum:
name_template: 'checksums.txt'
35 changes: 35 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Get the latest commit branch, hash, and date
TAG=$(shell git describe --tags --abbrev=0 --exact-match 2>/dev/null)
BRANCH=$(if $(TAG),$(TAG),$(shell git rev-parse --abbrev-ref HEAD 2>/dev/null))
BRANCH_SAFE=$(shell echo $(BRANCH) | sed -e 's/[^a-zA-Z0-9-]/-/g')
HASH=$(shell git rev-parse --short=7 HEAD 2>/dev/null)
TIMESTAMP=$(shell git log -1 --format=%ct HEAD 2>/dev/null | xargs -I{} date -u -r {} +%Y%m%dT%H%M%S)
GIT_REV=$(shell printf "%s-%s-%s" "$(BRANCH_SAFE)" "$(HASH)" "$(TIMESTAMP)")
REV=$(if $(filter --,$(GIT_REV)),latest,$(GIT_REV)) # fallback to latest if not in git repo


all: lint test build release

build:
cd cmd/gol && go build -ldflags "-X main.revision=$(REV) -s -w" -o ../../.bin/gol.$(REV)
cp .bin/gol.$(REV) .bin/gol
.bin/gol --version

release:
@echo release to dist/
goreleaser --snapshot --clean

test:
go clean -testcache
go test -v -coverprofile=coverage.out -covermode=atomic ./...
go tool cover -func=coverage.out
rm coverage.out

lint:
golangci-lint run

version:
@echo "branch: $(BRANCH), hash: $(HASH), timestamp: $(TIMESTAMP)"
@echo "revision: $(REV)"

.PHONY: build release test lint version
4 changes: 2 additions & 2 deletions cmd/eatme/main.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package main

var (
version = "unknown-local-build"
revision = "unknown"
)

func main() {
Execute(version)
Execute(revision)
}
2 changes: 1 addition & 1 deletion internal/runner/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,5 +120,5 @@ func findRepositories(root string, pathChan chan vcsPath) {
}

// Walk the file tree.
filepath.Walk(root, visit)
filepath.Walk(root, visit) // nolint
}

0 comments on commit af98e06

Please sign in to comment.