diff --git a/.goreleaser.yml b/.goreleaser.yml index aaa9051..6e03188 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -16,51 +16,50 @@ # Make sure to check the documentation at https://goreleaser.com archives: - format: binary - wrap_in_directory: false + wrap_in_directory: "false" before: hooks: - make check builds: - - id: amd64 + - &build + id: arm64 env: - CGO_ENABLED=0 goarch: - - amd64 + - arm64 goos: - - linux - - windows - darwin + - linux hooks: post: upx -9 {{ .Path }} - ldflags: - - "-s -w" - - id: arm64 - env: - - CGO_ENABLED=0 + - <<: *build + id: amd64 goarch: - - arm64 + - amd64 goos: - - linux - darwin - hooks: - post: upx -9 {{ .Path }} - ldflags: - - "-s -w" + - linux + - windows checksum: name_template: 'checksums.txt' dockers: - build_flag_templates: + - "--label=org.opencontainers.image.authors=Clavin June" - "--label=org.opencontainers.image.created={{.Date}}" - - "--label=org.opencontainers.image.description={{.ReleaseNotes}}" + - "--label=org.opencontainers.image.description=A Lightweight HTTP Server Built on Top of Go" + - "--label=org.opencontainers.image.url=https://serve.clavinjune.dev" - "--label=org.opencontainers.image.revision={{.FullCommit}}" - "--label=org.opencontainers.image.source={{.GitURL}}" - "--label=org.opencontainers.image.title={{.ProjectName}}" - "--label=org.opencontainers.image.version={{.Version}}" + - "--label=org.opencontainers.image.base.name=gcr.io/distroless/static:latest-arm64@sha256:6017b5802f96702dd66066a351e6e84ab003b768042d83fdbfb5a1159824425a" image_templates: - "ghcr.io/clavinjune/serve:{{ .Version }}" - "ghcr.io/clavinjune/serve:{{ .ShortCommit }}" - "ghcr.io/clavinjune/serve:latest" skip_push: auto + goos: "linux" + goarch: "arm64" extra_files: - src/ changelog: diff --git a/Dockerfile b/Dockerfile index 2ec5cba..c2359e5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -FROM gcr.io/distroless/static:latest +FROM gcr.io/distroless/static:latest-arm64@sha256:6017b5802f96702dd66066a351e6e84ab003b768042d83fdbfb5a1159824425a WORKDIR /app COPY . . ENTRYPOINT [ "/app/serve", "-r", "/app/src" ] diff --git a/README.md b/README.md index f7d5ee3..0c57693 100644 --- a/README.md +++ b/README.md @@ -24,39 +24,39 @@ A Lightweight HTTP Server Built on Top of Go ```bash # chmod +x serve_{version}_{os}_{arch} -$ chmod +x serve_0.3.9_linux_amd64 -$ ./serve_0.3.9_linux_amd64 -v -serve v0.3.9 +$ chmod +x serve_1.0.0_linux_amd64 +$ ./serve_1.0.0_linux_amd64 -v +serve v1.0.0 ``` ### Via Go Install ```bash $ go install github.com/ClavinJune/serve@latest -go: downloading github.com/ClavinJune/serve v0.3.9 +go: downloading github.com/ClavinJune/serve v1.0.0 $ serve -v -serve v0.3.9 +serve v1.0.0 ``` ### Via Go Run ```bash $ go run github.com/ClavinJune/serve@latest -v -serve v0.3.9 +serve v1.0.0 ``` ### Via Docker ```bash $ docker run -it --rm ghcr.io/clavinjune/serve:latest -v -serve v0.3.9 +serve v1.0.0 ``` ### Via Podman ```bash $ podman run -it --rm ghcr.io/clavinjune/serve:latest -v -serve v0.3.9 +serve v1.0.0 ``` ## Usage diff --git a/main.go b/main.go index d6091e9..627226e 100644 --- a/main.go +++ b/main.go @@ -23,6 +23,7 @@ import ( "os" "os/signal" "path/filepath" + "runtime" "strings" "syscall" "time" @@ -30,8 +31,11 @@ import ( "github.com/ClavinJune/serve/internal" ) -const ( - version string = "v0.3.9" +var ( + version = "dev" + buildBy = "dev" + commit = "n/a" + date = "0001-01-01 00:00:00 +0000 UTC" ) var ( @@ -83,7 +87,10 @@ func mustGetServer(rootDir string, isSpa bool) *http.Server { func main() { if *versionFlag { - fmt.Println("serve", version) + fmt.Printf("serve %s-%s %s/%s BuildBy=%s BuildDate=%s", + version, commit, + runtime.GOOS, runtime.GOARCH, + buildBy, date) return }