Skip to content

Commit

Permalink
goreleaser (#22)
Browse files Browse the repository at this point in the history
initial goreleaser config and `version` command tweaks
  • Loading branch information
srerickson authored Oct 2, 2024
1 parent 315eff9 commit 98c7ebf
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 5 deletions.
3 changes: 2 additions & 1 deletion .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
FROM mcr.microsoft.com/devcontainers/go:1.3.0-1.23-bookworm
RUN apt-get update && apt-get upgrade -y
RUN echo 'deb [trusted=yes] https://repo.goreleaser.com/apt/ /' | sudo tee /etc/apt/sources.list.d/goreleaser.list
RUN apt-get update && apt-get upgrade -y && apt-get install -y goreleaser
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.DS_Store
.tool-versions
cmd/ocfl/ocfl
cmd/ocfl/ocfl
dist/
51 changes: 51 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# This is an example .goreleaser.yml file with some sensible defaults.
# Make sure to check the documentation at https://goreleaser.com

# The lines below are called `modelines`. See `:help modeline`
# Feel free to remove those if you don't want/need to use them.
# yaml-language-server: $schema=https://goreleaser.com/static/schema.json
# vim: set ts=2 sw=2 tw=0 fo=cnqoj

version: 2

before:
hooks:
# You may remove this if you don't use go modules.
- go mod tidy

builds:
- binary: ocfl
main: ./cmd/ocfl
env:
- CGO_ENABLED=0
targets:
- linux_amd64_v1
- linux_arm64
- windows_amd64_v1
- darwin_arm64

ldflags:
- -X github.com/srerickson/ocfl-tools/cmd/ocfl/run.Version={{.Version}}
- -X github.com/srerickson/ocfl-tools/cmd/ocfl/run.BuildTime={{.Date}}

archives:
- format: tar.gz
# this name template makes the OS and Arch compatible with the results of `uname`.
name_template: >-
{{ .ProjectName }}_
{{- title .Os }}_
{{- if eq .Arch "amd64" }}x86_64
{{- else if eq .Arch "386" }}i386
{{- else }}{{ .Arch }}{{ end }}
{{- if .Arm }}v{{ .Arm }}{{ end }}
# use zip for windows archives
format_overrides:
- goos: windows
format: zip

changelog:
sort: asc
filters:
exclude:
- "^docs:"
- "^test:"
6 changes: 3 additions & 3 deletions cmd/ocfl/run/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -257,11 +257,11 @@ func codeRev() string {
}

func printVersion(stdout io.Writer) {
fmt.Fprintf(stdout, "ocfl %s, built: %s", Version, BuildTime)
fmt.Fprintln(stdout, "ocfl: v"+Version)
fmt.Fprintln(stdout, "date:", BuildTime)
if rev := codeRev(); rev != "" {
fmt.Fprintf(stdout, ", commit: [%s]", rev[:8])
fmt.Fprintln(stdout, "commit:", rev[:8])
}
fmt.Fprintln(stdout)
}

func newLogger(l log.Level, w io.Writer) *slog.Logger {
Expand Down

0 comments on commit 98c7ebf

Please sign in to comment.