Skip to content

Commit

Permalink
ci(github): update goreleaser job (#70)
Browse files Browse the repository at this point in the history
* fix: use `SERVICE_PORT` instead of `GO_PORT`
* chore(typos): ignore short words
* ci(deps): update pre-commit hooks
* ci(github): update `goreleaser` job
* ci(pre-commit): fix mixed line endings
* fix(deps): update module `github.com/labstack/echo/v4` to `v4.12.0`
  • Loading branch information
DeadNews committed May 9, 2024
1 parent f9b1e51 commit f703317
Show file tree
Hide file tree
Showing 10 changed files with 39 additions and 31 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 }}
8 changes: 5 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand All @@ -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

Expand Down
5 changes: 5 additions & 0 deletions .typos.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
[files]
extend-exclude = ["CHANGELOG.md"]

[default]
extend-ignore-re = [
"[a-z]{0,3}", # ignore short words
]
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ RUN --mount=type=cache,target=${GOCACHE} \
FROM gcr.io/distroless/static-debian12:latest@sha256:41972110a1c1a5c0b6adb283e8aa092c43c31f7c5d79b8656fbffff2c3e61f05 AS runtime
LABEL maintainer "DeadNews <deadnewsgit@gmail.com>"

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"]
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions cmd/deadnews-template-go/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion cmd/deadnews-template-go/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
}
5 changes: 2 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -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}
10 changes: 5 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
)

Expand All @@ -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
)
20 changes: 10 additions & 10 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand All @@ -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=
Expand Down

0 comments on commit f703317

Please sign in to comment.