Skip to content

Commit 190019b

Browse files
committed
chore(project): make it more DRY
1 parent bc9f97c commit 190019b

File tree

2 files changed

+21
-18
lines changed

2 files changed

+21
-18
lines changed

.goreleaser.yml

+19-16
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ builds:
2222
- goos: darwin
2323
goarch: 386
2424
ldflags:
25-
- -w -X github.com/zackijack/go-project/internal/version.Version={{ .Version }} -X github.com/zackijack/go-project/internal/version.GitCommit={{ .Commit }} -X github.com/zackijack/go-project/internal/version.BuildDate={{ .Date }}
25+
- -w -X github.com/zackijack/{{ .ProjectName }}/internal/version.Version={{ .Prerelease }} -X github.com/zackijack/{{ .ProjectName }}/internal/version.GitCommit={{ .FullCommit }} -X github.com/zackijack/{{ .ProjectName }}/internal/version.BuildDate={{ .Date }}
2626

2727
archives:
2828
- name_template: "{{ .ProjectName }}_{{ .Os }}_{{ .Arch }}"
@@ -47,6 +47,9 @@ changelog:
4747
filters:
4848
exclude:
4949
- "^docs"
50+
- "^chore"
51+
- "^style"
52+
- "^refactor"
5053
- "^test"
5154
- Merge pull request
5255
- Merge branch
@@ -57,40 +60,40 @@ brews:
5760
owner: zackijack
5861
name: homebrew-tap
5962
folder: Formula
60-
homepage: https://github.com/zackijack/go-project
63+
homepage: https://github.com/zackijack/{{ .ProjectName }}
6164
description: Go project template
6265
install: |
63-
bin.install "go-project"
66+
bin.install "{{ .ProjectName }}"
6467
65-
output = Utils.safe_popen_read({ "SHELL" => "bash" }, bin/"go-project", "completion", "bash")
66-
(bash_completion/"go-project").write output
68+
output = Utils.safe_popen_read({ "SHELL" => "bash" }, bin/"{{ .ProjectName }}", "completion", "bash")
69+
(bash_completion/"{{ .ProjectName }}").write output
6770
68-
output = Utils.safe_popen_read({ "SHELL" => "zsh" }, bin/"go-project", "completion", "zsh")
69-
(zsh_completion/"_go-project").write output
71+
output = Utils.safe_popen_read({ "SHELL" => "zsh" }, bin/"{{ .ProjectName }}", "completion", "zsh")
72+
(zsh_completion/"_{{ .ProjectName }}").write output
7073
test: |
71-
system "#{bin}/go-project version"
74+
system "#{bin}/{{ .ProjectName }} version"
7275
7376
scoop:
7477
bucket:
7578
owner: zackijack
7679
name: scoop-bucket
77-
homepage: https://github.com/zackijack/go-project
80+
homepage: https://github.com/zackijack/{{ .ProjectName }}
7881
description: Go project template
7982

8083
nfpms:
8184
- file_name_template: "{{ .ProjectName }}_{{ .Arch }}"
82-
homepage: https://github.com/zackijack/go-project
85+
homepage: https://github.com/zackijack/{{ .ProjectName }}
8386
description: Go project template
8487
formats:
8588
- deb
8689
- rpm
8790

8891
dockers:
8992
- image_templates:
90-
- "zackijack/go-project:{{ .Tag }}"
91-
- "zackijack/go-project:v{{ .Major }}"
92-
- "zackijack/go-project:v{{ .Major }}.{{ .Minor }}"
93-
- "zackijack/go-project:latest"
93+
- "zackijack/{{ .ProjectName }}:{{ .Tag }}"
94+
- "zackijack/{{ .ProjectName }}:v{{ .Major }}"
95+
- "zackijack/{{ .ProjectName }}:v{{ .Major }}.{{ .Minor }}"
96+
- "zackijack/{{ .ProjectName }}:latest"
9497
dockerfile: Dockerfile
9598
use_buildx: true
9699
build_flag_templates:
@@ -100,8 +103,8 @@ dockers:
100103
- "--label=org.opencontainers.image.title={{ .ProjectName }}"
101104
- "--label=org.opencontainers.image.revision={{ .FullCommit }}"
102105
- "--label=org.opencontainers.image.description={{ .ProjectName }}"
103-
- "--label=org.opencontainers.image.url=https://github.com/zackijack/go-project"
104-
- "--label=org.opencontainers.image.source=https://github.com/zackijack/go-project"
106+
- "--label=org.opencontainers.image.url=https://github.com/zackijack/{{ .ProjectName }}"
107+
- "--label=org.opencontainers.image.source=https://github.com/zackijack/{{ .ProjectName }}"
105108
- "--label=org.opencontainers.image.version={{ .Version }}"
106109
- "--cache-from=type=local,src=/tmp/.buildx-cache"
107110
- "--cache-to=type=local,dest=/tmp/.buildx-cache"

Makefile

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
SHELL = /bin/bash
22

33
APP_NAME = go-project
4-
VERSION := $(shell git describe --always --tags)
4+
VERSION := $(shell git describe --tags --abbrev=0 --exact-match 2>/dev/null)
55
GIT_COMMIT = $(shell git rev-parse HEAD)
66
BUILD_DATE = $(shell date '+%Y-%m-%d-%H:%M:%S')
77

@@ -23,7 +23,7 @@ help:
2323
.PHONY: build
2424
build:
2525
@echo "Building ${APP_NAME} ${VERSION}"
26-
go build -ldflags "-w -X github.com/zackijack/go-project/internal/version.Version=${VERSION} -X github.com/zackijack/go-project/internal/version.GitCommit=${GIT_COMMIT} -X github.com/zackijack/go-project/internal/version.BuildDate=${BUILD_DATE}" -o bin/${APP_NAME}
26+
go build -ldflags "-w -X github.com/zackijack/${APP_NAME}/internal/version.Version=${VERSION} -X github.com/zackijack/${APP_NAME}/internal/version.GitCommit=${GIT_COMMIT} -X github.com/zackijack/${APP_NAME}/internal/version.BuildDate=${BUILD_DATE}" -o bin/${APP_NAME}
2727

2828
.PHONY: run
2929
run: build

0 commit comments

Comments
 (0)