diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 9147dd6..ba7f16f 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -72,6 +72,8 @@ jobs: environment: github-releases permissions: contents: write + env: + DRAFT: ${{ contains(github.ref, 'alpha') || contains(github.ref, 'beta') }} runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -86,6 +88,6 @@ jobs: uses: goreleaser/goreleaser-action@7ec5c2b0c6cdda6e8bbb49444bc797dd33d74dd8 # v5.0.0 with: version: latest - args: release --clean + args: release --clean --draft ${{ env.DRAFT }} env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 48a277b..be34472 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -16,6 +16,8 @@ repos: - id: detect-private-key - id: end-of-file-fixer - id: trailing-whitespace + - id: mixed-line-ending + args: [--fix=lf] - repo: https://github.com/pre-commit/mirrors-prettier rev: v3.1.0 @@ -28,13 +30,13 @@ repos: - id: typos - repo: https://github.com/python-jsonschema/check-jsonschema - rev: 0.28.2 + rev: 0.28.3 hooks: - id: check-github-workflows - id: check-renovate - repo: https://github.com/rhysd/actionlint - rev: v1.6.27 + rev: v1.7.0 hooks: - id: actionlint @@ -49,7 +51,7 @@ repos: - id: gitleaks - repo: https://github.com/golangci/golangci-lint - rev: v1.58.0 + rev: v1.58.1 hooks: - id: golangci-lint diff --git a/.typos.toml b/.typos.toml index bf27f28..f904063 100644 --- a/.typos.toml +++ b/.typos.toml @@ -1,2 +1,7 @@ [files] extend-exclude = ["CHANGELOG.md"] + +[default] +extend-ignore-re = [ + "[a-z]{0,3}", # ignore short words +] diff --git a/Dockerfile b/Dockerfile index d8bbf9d..f7218e8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -15,12 +15,12 @@ RUN --mount=type=cache,target=${GOCACHE} \ FROM gcr.io/distroless/static-debian12:latest@sha256:41972110a1c1a5c0b6adb283e8aa092c43c31f7c5d79b8656fbffff2c3e61f05 AS runtime LABEL maintainer "DeadNews " -ENV GO_PORT=1271 +ENV SERVICE_PORT=8000 COPY --from=go-builder /app/dist/deadnews-template-go /usr/local/bin/deadnews-template-go USER nonroot:nonroot -EXPOSE ${GO_PORT} +EXPOSE ${SERVICE_PORT} HEALTHCHECK NONE CMD ["deadnews-template-go"] diff --git a/README.md b/README.md index ccc63b7..bcdb417 100644 --- a/README.md +++ b/README.md @@ -6,8 +6,8 @@ [![Docker: ghcr](https://img.shields.io/badge/docker-gray.svg?logo=docker&logoColor=white)](https://github.com/deadnews/deadnews-template-go/pkgs/container/deadnews-template-go) [![Go: Reference](https://pkg.go.dev/badge/github.com/DeadNews/deadnews-template-go.svg)](https://pkg.go.dev/github.com/DeadNews/deadnews-template-go/v2) [![Go: Report Card](https://goreportcard.com/badge/github.com/DeadNews/deadnews-template-go)](https://goreportcard.com/report/github.com/DeadNews/deadnews-template-go) -[![CI: Main](https://img.shields.io/github/actions/workflow/status/deadnews/deadnews-template-go/main.yml?branch=main&logo=github&logoColor=white&label=main)](https://github.com/deadnews/deadnews-template-go/actions/workflows/main.yml) [![CI: pre-commit](https://results.pre-commit.ci/badge/github/DeadNews/deadnews-template-go/main.svg)](https://results.pre-commit.ci/latest/github/deadnews/deadnews-template-go/main) +[![CI: Main](https://img.shields.io/github/actions/workflow/status/deadnews/deadnews-template-go/main.yml?branch=main&logo=github&logoColor=white&label=main)](https://github.com/deadnews/deadnews-template-go/actions/workflows/main.yml) [![CI: Coverage](https://img.shields.io/codecov/c/github/deadnews/deadnews-template-go?token=OCZDZIYPMC&logo=codecov&logoColor=white)](https://codecov.io/gh/deadnews/deadnews-template-go) ## Installation diff --git a/cmd/deadnews-template-go/main.go b/cmd/deadnews-template-go/main.go index 55141e4..6de6d61 100644 --- a/cmd/deadnews-template-go/main.go +++ b/cmd/deadnews-template-go/main.go @@ -10,16 +10,16 @@ import ( // This code is the main function of a Go program // that creates and starts a server using the Echo framework. -// It retrieves the value of the "GO_PORT" environment variable -// and if it is not set, it defaults to port 1271. +// It retrieves the value of the "SERVICE_PORT" environment variable +// and if it is not set, it defaults to port 8000. func main() { // Create a new Echo instance. e := makeServer() - // Get the value of the "GO_PORT" environment variable. - httpPort := os.Getenv("GO_PORT") + // Get the value of the "SERVICE_PORT" environment variable. + httpPort := os.Getenv("SERVICE_PORT") if httpPort == "" { - httpPort = "1271" + httpPort = "8000" } // Start the server on the specified port. diff --git a/cmd/deadnews-template-go/main_test.go b/cmd/deadnews-template-go/main_test.go index 8f167af..13d3417 100644 --- a/cmd/deadnews-template-go/main_test.go +++ b/cmd/deadnews-template-go/main_test.go @@ -63,6 +63,6 @@ func TestServerResponseHealth(t *testing.T) { assert.Equal(t, expectedBody, rec.Body.String()) // Check the response content type header. - contentType := "application/json; charset=UTF-8" + contentType := "application/json" assert.Equal(t, contentType, rec.Header().Get("Content-Type")) } diff --git a/docker-compose.yml b/docker-compose.yml index 68b65ee..bc68e5c 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,8 +1,7 @@ -version: "3" services: web: build: . ports: - - 127.0.0.1:${GO_PORT:-1271}:${GO_PORT:-1271} + - 127.0.0.1:${SERVICE_PORT:-8000}:${SERVICE_PORT:-8000} environment: - GO_PORT: ${GO_PORT:-1271} + SERVICE_PORT: ${SERVICE_PORT:-8000} diff --git a/go.mod b/go.mod index 22f03f2..444facb 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/DeadNews/deadnews-template-go/v2 go 1.21 require ( - github.com/labstack/echo/v4 v4.11.4 + github.com/labstack/echo/v4 v4.12.0 github.com/stretchr/testify v1.9.0 ) @@ -16,10 +16,10 @@ require ( github.com/pmezard/go-difflib v1.0.0 // indirect github.com/valyala/bytebufferpool v1.0.0 // indirect github.com/valyala/fasttemplate v1.2.2 // indirect - golang.org/x/crypto v0.22.0 // indirect - golang.org/x/net v0.24.0 // indirect - golang.org/x/sys v0.19.0 // indirect - golang.org/x/text v0.14.0 // indirect + golang.org/x/crypto v0.23.0 // indirect + golang.org/x/net v0.25.0 // indirect + golang.org/x/sys v0.20.0 // indirect + golang.org/x/text v0.15.0 // indirect golang.org/x/time v0.5.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/go.sum b/go.sum index e3e8347..723f2c8 100644 --- a/go.sum +++ b/go.sum @@ -2,8 +2,8 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/golang-jwt/jwt v3.2.2+incompatible h1:IfV12K8xAKAnZqdXVzCZ+TOjboZ2keLg81eXfW3O+oY= github.com/golang-jwt/jwt v3.2.2+incompatible/go.mod h1:8pz2t5EyA70fFQQSrl6XZXzqecmYZeUEB8OUGHkxJ+I= -github.com/labstack/echo/v4 v4.11.4 h1:vDZmA+qNeh1pd/cCkEicDMrjtrnMGQ1QFI9gWN1zGq8= -github.com/labstack/echo/v4 v4.11.4/go.mod h1:noh7EvLwqDsmh/X/HWKPUl1AjzJrhyptRyEbQJfxen8= +github.com/labstack/echo/v4 v4.12.0 h1:IKpw49IMryVB2p1a4dzwlhP1O2Tf2E0Ir/450lH+kI0= +github.com/labstack/echo/v4 v4.12.0/go.mod h1:UP9Cr2DJXbOK3Kr9ONYzNowSh7HP0aG0ShAyycHSJvM= github.com/labstack/gommon v0.4.2 h1:F8qTUNXgG1+6WQmqoUWnz8WiEU60mXVVw0P4ht1WRA0= github.com/labstack/gommon v0.4.2/go.mod h1:QlUFxVM+SNXhDL/Z7YhocGIBYOiwB0mXm1+1bAPHPyU= github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= @@ -19,16 +19,16 @@ github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6Kllzaw github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc= github.com/valyala/fasttemplate v1.2.2 h1:lxLXG0uE3Qnshl9QyaK6XJxMXlQZELvChBOCmQD0Loo= github.com/valyala/fasttemplate v1.2.2/go.mod h1:KHLXt3tVN2HBp8eijSv/kGJopbvo7S+qRAEEKiv+SiQ= -golang.org/x/crypto v0.22.0 h1:g1v0xeRhjcugydODzvb3mEM9SQ0HGp9s/nh3COQ/C30= -golang.org/x/crypto v0.22.0/go.mod h1:vr6Su+7cTlO45qkww3VDJlzDn0ctJvRgYbC2NvXHt+M= -golang.org/x/net v0.24.0 h1:1PcaxkF854Fu3+lvBIx5SYn9wRlBzzcnHZSiaFFAb0w= -golang.org/x/net v0.24.0/go.mod h1:2Q7sJY5mzlzWjKtYUEXSlBWCdyaioyXzRB2RtU8KVE8= +golang.org/x/crypto v0.23.0 h1:dIJU/v2J8Mdglj/8rJ6UUOM3Zc9zLZxVZwwxMooUSAI= +golang.org/x/crypto v0.23.0/go.mod h1:CKFgDieR+mRhux2Lsu27y0fO304Db0wZe70UKqHu0v8= +golang.org/x/net v0.25.0 h1:d/OCCoBEUq33pjydKrGQhw7IlUPI2Oylr+8qLx49kac= +golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.19.0 h1:q5f1RH2jigJ1MoAWp2KTp3gm5zAGFUTarQZ5U386+4o= -golang.org/x/sys v0.19.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= -golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= +golang.org/x/sys v0.20.0 h1:Od9JTbYCk261bKm4M/mw7AklTlFYIa0bIp9BgSm1S8Y= +golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/text v0.15.0 h1:h1V/4gjBv8v9cjcR6+AR5+/cIYK5N/WAgiv4xlsEtAk= +golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= golang.org/x/time v0.5.0 h1:o7cqy6amK/52YcAKIPlM3a+Fpj35zvRj2TP+e1xFSfk= golang.org/x/time v0.5.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=