Skip to content

Commit f2bc4fe

Browse files
committed
use go base image
1 parent 4e336ab commit f2bc4fe

File tree

5 files changed

+34
-11
lines changed

5 files changed

+34
-11
lines changed

.github/workflows/build_and_test.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,6 @@ jobs:
1313
fail-fast: false
1414
matrix:
1515
go:
16-
# Drop support of go 1.17
17-
- "1.18"
18-
- "1.19"
1916
- "1.20"
2017
- "1.21"
2118
name: run tests with go version ${{ matrix.go }}

.goreleaser.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ archives:
2121
2222
kos:
2323
- repository: abice/go-enum
24+
base_image: cgr.dev/chainguard/go # need the go binary for formatting 🔧 purposes 🫤
2425
tags:
2526
- "{{.Version}}"
2627
- latest

.ko.yaml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
defaultBaseImage: cgr.dev/chainguard/go # For now, we need the go binary in order to format go files.
2+
defaultPlatforms:
3+
- linux/arm64
4+
- linux/amd64
5+
6+
builds:
7+
- id: go-enum
8+
dir: . # default is .
9+
main: .
10+
flags:
11+
- -tags
12+
- netgo
13+
ldflags:
14+
- -s -w
15+
- -extldflags "-static"
16+
- -X "main.version={{.Env.VERSION}}"
17+
- -X "main.commit={{.Env.COMMIT}}"
18+
- -X "main.date={{.Env.DATE}}"
19+
- -X "main.builtBy={{.Env.BUILT_BY}}"

Makefile

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -99,28 +99,26 @@ bin/goveralls: go.sum
9999
$(call goinstall,github.com/mattn/goveralls)
100100

101101
# snapshots: snapshots_1.17
102-
snapshots: snapshots_1.20
102+
snapshots: snapshots_1.21
103103

104104
snapshots_%: clean
105105
echo "##### updating snapshots for golang $* #####"
106106
docker run -i -t -w /app -v $(shell pwd):/app --entrypoint /bin/sh golang:$* -c './update-snapshots.sh || true'
107107

108108
.PHONY: ci
109-
# ci: docker_1.16
110-
# ci: docker_1.17
111-
ci: docker_1.18
112-
ci: docker_1.19
113109
ci: docker_1.20
110+
ci: docker_1.21
114111

115112
docker_%:
116113
echo "##### testing golang $* #####"
117114
docker run -i -t -w /app -v $(shell pwd):/app --entrypoint /bin/sh golang:$* -c 'make clean && make'
118115

119116
.PHONY: pullimages
120-
pullimages: pullimage_1.17
121-
pullimages: pullimage_1.18
122-
pullimages: pullimage_1.19
123117
pullimages: pullimage_1.20
118+
pullimages: pullimage_1.21
124119

125120
pullimage_%:
126121
docker pull golang:$*
122+
123+
build_docker:
124+
KO_DOCKER_REPO=abice/go-enum VERSION=$(GITHUB_REF) COMMIT=$(GITHUB_SHA) DATE=$(DATE) BUILT_BY=$(USER) ko build --bare --local

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,14 @@ It's not perfect, but I think it's useful.
8888

8989
I took the output of the [Stringer](https://godoc.org/golang.org/x/tools/cmd/stringer) command as the `String()` method, and added a way to parse a string value.
9090

91+
## Docker image
92+
93+
You can now use a docker image directly for running the command if you do not wish to install anything!
94+
95+
```shell
96+
docker run -w /app -v $(pwd):/app abice/go-enum:$(GO_ENUM_VERSION)
97+
```
98+
9199
## Installation
92100

93101
You can now download a release directly from github and use that for generating your enums! (Thanks to [GoReleaser](https://github.com/goreleaser/goreleaser-action))

0 commit comments

Comments
 (0)