From 06eaade72bb7da149a744f4ecf2662bb03c84cd7 Mon Sep 17 00:00:00 2001 From: Evan Fiordeliso Date: Sat, 15 Apr 2023 18:24:23 -0400 Subject: [PATCH] Update goreleaser config --- .gitignore | 3 ++- .goreleaser.yaml | 48 ++++++++++++++++++++++++++++++++++++++++++++++ README.md | 22 +++++++++++++++++++-- Taskfile.yml | 6 +++++- version/version.go | 8 ++++++-- 5 files changed, 81 insertions(+), 6 deletions(-) create mode 100644 .goreleaser.yaml diff --git a/.gitignore b/.gitignore index 438d007..f3cd46d 100644 --- a/.gitignore +++ b/.gitignore @@ -5,4 +5,5 @@ /tmp/ # Deployment directory -.deploy \ No newline at end of file +.deploy +dist/ diff --git a/.goreleaser.yaml b/.goreleaser.yaml new file mode 100644 index 0000000..631ad32 --- /dev/null +++ b/.goreleaser.yaml @@ -0,0 +1,48 @@ +before: + hooks: + - go mod tidy +builds: + - env: + - CGO_ENABLED=0 + goos: + - linux + - windows + - darwin + ldflags: + - -X go.fifitido.net/ytdl-web/version.Version={{.Version}} + - -X go.fifitido.net/ytdl-web/version.Build={{.Commit}} + - -X go.fifitido.net/ytdl-web/version.BuildDate={{.Date}} + - -X go.fifitido.net/ytdl-web/version.BuiltBy=goreleaser + +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 +checksum: + name_template: checksums.txt +snapshot: + name_template: "{{ incpatch .Version }}-next" +changelog: + sort: asc + filters: + exclude: + - "^docs:" + - "^test:" + +gitea_urls: + api: https://git.fifitido.net/api/v1 + download: https://git.fifitido.net +# The lines beneath this are called `modelines`. See `:help modeline` +# Feel free to remove those if you don't want/use them. +# yaml-language-server: $schema=https://goreleaser.com/static/schema.json +# vim: set ts=2 sw=2 tw=0 fo=cnqoj diff --git a/README.md b/README.md index af30896..17d29b2 100644 --- a/README.md +++ b/README.md @@ -36,9 +36,27 @@ task deps task build ``` +## Releasing + +Prerequisites: + +- [go v1.20](https://go.dev/doc/install) +- [goreleaser](https://goreleaser.com/install/) +- [task cli](https://taskfile.dev/installation/) + +Steps: + +1. Ensure gitea access token is in `~/.config/goreleaser/gitea_token` + +2. Run release task + +```sh +task release +``` + ## Publishing Docker Image -Prerequsites: +Prerequisites: - [docker](https://docs.docker.com/engine/install/) - [task cli](https://taskfile.dev/installation/) @@ -59,7 +77,7 @@ task docker:publish ## Publishing Chart -Prerequsites: +Prerequisites: - [helm cli](https://helm.sh/docs/intro/install/) - [cm-push helm plugin](https://github.com/chartmuseum/helm-push/). diff --git a/Taskfile.yml b/Taskfile.yml index 43f9e50..ca1bd50 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -6,14 +6,18 @@ vars: VERSION_PKG: go.fifitido.net/ytdl-web/version BUILD: sh: git rev-parse --short HEAD + DATE: + sh: date DOCKER_IMAGE: git.fifitido.net/apps/ytdl-web DOCKER_IMAGE_TAG: latest tasks: deps: go mod download tidy: go mod tidy - build: go build -ldflags="-X {{.VERSION_PKG}}.Version={{.VERSION}} -X {{.VERSION_PKG}}.Build={{.BUILD}}" -o {{.OUT}} . + check: goreleaser check + build: goreleaser build --single-target dev: air + release: goreleaser release chart:publish: helm cm-push charts/ytdl-web/ gitea-apps diff --git a/version/version.go b/version/version.go index e40727f..c5789e1 100644 --- a/version/version.go +++ b/version/version.go @@ -1,4 +1,8 @@ package version -var Version string -var Build string +var ( + Version string + Build string + BuildDate string + BuiltBy string +)