Skip to content

Commit

Permalink
use go base image
Browse files Browse the repository at this point in the history
  • Loading branch information
abice committed Nov 13, 2023
1 parent 4e336ab commit f2bc4fe
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 11 deletions.
3 changes: 0 additions & 3 deletions .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@ jobs:
fail-fast: false
matrix:
go:
# Drop support of go 1.17
- "1.18"
- "1.19"
- "1.20"
- "1.21"
name: run tests with go version ${{ matrix.go }}
Expand Down
1 change: 1 addition & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ archives:
kos:
- repository: abice/go-enum
base_image: cgr.dev/chainguard/go # need the go binary for formatting 🔧 purposes 🫤
tags:
- "{{.Version}}"
- latest
Expand Down
19 changes: 19 additions & 0 deletions .ko.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
defaultBaseImage: cgr.dev/chainguard/go # For now, we need the go binary in order to format go files.
defaultPlatforms:
- linux/arm64
- linux/amd64

builds:
- id: go-enum
dir: . # default is .
main: .
flags:
- -tags
- netgo
ldflags:
- -s -w
- -extldflags "-static"
- -X "main.version={{.Env.VERSION}}"
- -X "main.commit={{.Env.COMMIT}}"
- -X "main.date={{.Env.DATE}}"
- -X "main.builtBy={{.Env.BUILT_BY}}"
14 changes: 6 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -99,28 +99,26 @@ bin/goveralls: go.sum
$(call goinstall,github.com/mattn/goveralls)

# snapshots: snapshots_1.17
snapshots: snapshots_1.20
snapshots: snapshots_1.21

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

.PHONY: ci
# ci: docker_1.16
# ci: docker_1.17
ci: docker_1.18
ci: docker_1.19
ci: docker_1.20
ci: docker_1.21

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

.PHONY: pullimages
pullimages: pullimage_1.17
pullimages: pullimage_1.18
pullimages: pullimage_1.19
pullimages: pullimage_1.20
pullimages: pullimage_1.21

pullimage_%:
docker pull golang:$*

build_docker:
KO_DOCKER_REPO=abice/go-enum VERSION=$(GITHUB_REF) COMMIT=$(GITHUB_SHA) DATE=$(DATE) BUILT_BY=$(USER) ko build --bare --local
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,14 @@ It's not perfect, but I think it's useful.

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.

## Docker image

You can now use a docker image directly for running the command if you do not wish to install anything!

```shell
docker run -w /app -v $(pwd):/app abice/go-enum:$(GO_ENUM_VERSION)
```

## Installation

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))
Expand Down

0 comments on commit f2bc4fe

Please sign in to comment.