Skip to content

Commit

Permalink
update gha build
Browse files Browse the repository at this point in the history
- build only tags on master
- go build vcs stamp
- and version as -v
- latest github actions versions
- entrypoint instead of command
  • Loading branch information
roelarents committed Dec 1, 2023
1 parent 12dda32 commit a644064
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 29 deletions.
37 changes: 14 additions & 23 deletions .github/workflows/build-and-publish-image.yml
Original file line number Diff line number Diff line change
@@ -1,54 +1,45 @@
---
name: build
env:
image: pdok/texel
on:
"on":
push:
tags:
- '*'
jobs:
docker:
runs-on: ubuntu-latest
steps:
- name: Ensure master # because master branch is protected and others not
if: "!endsWith(github.event.base_ref, 'master')"
run: exit -1
- name: Checkout # for go build -buildvcs to be able to read git info
uses: actions/checkout@v4
- name: Docker meta
id: docker_meta
uses: docker/metadata-action@v3
uses: docker/metadata-action@v5
with:
images: ${{ env.image }}
tags: |
type=semver,pattern={{major}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{version}}
- name: Login to PDOK Docker Hub
if: startsWith(env.image, 'pdok/')
uses: docker/login-action@v1
uses: docker/login-action@v3
with:
username: koalapdok
password: ${{ secrets.DOCKERHUB_PUSH }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Cache Docker layers
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
uses: docker/setup-buildx-action@v3
- name: Build and push
id: docker_build
uses: docker/build-push-action@v2
uses: docker/build-push-action@v5
with:
context: . # for go build -buildvcs to be able to read git info
push: true
tags: ${{ steps.docker_meta.outputs.tags }}
labels: ${{ steps.docker_meta.outputs.labels }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new
- # Temp fix to cleanup cache
# https://github.com/docker/build-push-action/issues/252
# https://github.com/moby/buildkit/issues/1896
name: Move cache
run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Build result notification
if: success() || failure()
uses: 8398a7/action-slack@v3
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ ENV GOOS=linux
# run tests
RUN go test ./... -covermode=atomic

RUN go build -v -ldflags='-s -w -linkmode auto' -a -installsuffix cgo -o /texel .
RUN go build -v -buildvcs=true -ldflags='-s -w -linkmode auto' -a -installsuffix cgo -o /texel .

# FROM scratch
FROM golang:1.21-bullseye
Expand All @@ -39,4 +39,4 @@ WORKDIR /
# Import from builder.
COPY --from=build-env /texel /

CMD ["/texel"]
ENTRYPOINT ["/texel"]
5 changes: 3 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@ require (
)

require (
github.com/carlmjohnson/versioninfo v0.22.5
github.com/go-playground/validator/v10 v10.16.0
github.com/iancoleman/strcase v0.3.0
github.com/perimeterx/marshmallow v1.1.5
github.com/stretchr/testify v1.8.4
gopkg.in/yaml.v3 v3.0.1
golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa
)

require (
Expand All @@ -25,10 +26,10 @@ require (
github.com/leodido/go-urn v1.2.4 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
golang.org/x/crypto v0.7.0 // indirect
golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa // indirect
golang.org/x/net v0.8.0 // indirect
golang.org/x/sys v0.14.0 // indirect
golang.org/x/text v0.8.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)

require (
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
github.com/arolek/p v0.0.0-20191103215535-df3c295ed582/go.mod h1:JPNItmi3yb44Q5QWM+Kh5n9oeRhfcJzPNS90mbLo25U=
github.com/carlmjohnson/versioninfo v0.22.5 h1:O00sjOLUAFxYQjlN/bzYTuZiS0y6fWDQjMRvwtKgwwc=
github.com/carlmjohnson/versioninfo v0.22.5/go.mod h1:QT9mph3wcVfISUKd0i9sZfVrPviHuSF+cUtLjm2WSf8=
github.com/cpuguy83/go-md2man/v2 v2.0.3 h1:qMCsGGgs+MAzDFyp9LpAe1Lqy/fY/qCovCm0qnXZOBM=
github.com/cpuguy83/go-md2man/v2 v2.0.3/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
github.com/creasty/defaults v1.7.0 h1:eNdqZvc5B509z18lD8yc212CAqJNvfT1Jq6L8WowdBA=
Expand Down Expand Up @@ -72,8 +74,6 @@ golang.org/x/net v0.8.0 h1:Zrh2ngAOFYneWTAIAPethzeaQLuHwhuBkuV6ZiRnUaQ=
golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.6.0 h1:MVltZSvRTcU2ljQOhs94SXPftV6DCNnZViHeQps87pQ=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.14.0 h1:Vz7Qs629MkJkGyHxUlRHizWJRG2j8fbQKjELVSNhy7Q=
golang.org/x/sys v0.14.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
Expand Down
3 changes: 3 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import (
"path"
"syscall"

"github.com/carlmjohnson/versioninfo"

"github.com/pdok/texel/processing"
"github.com/pdok/texel/tms20"

Expand All @@ -30,6 +32,7 @@ func main() {
app := cli.NewApp()
app.Name = "texel"
app.Usage = "A Golang Polygon Snapping application"
app.Version = versioninfo.Short()

app.Flags = []cli.Flag{
&cli.StringFlag{
Expand Down

0 comments on commit a644064

Please sign in to comment.