diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..1f9a404 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,31 @@ +--- +name: Release + +on: + push: + tags: + - 'v*' + +permissions: + contents: write + +jobs: + + goreleaser: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Set up Go + uses: actions/setup-go@v4 + + - name: Run GoReleaser + uses: goreleaser/goreleaser-action@v4 + with: + distribution: goreleaser + version: latest + args: release --clean + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.gitignore b/.gitignore index 2dc6ef0..05b9c89 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,5 @@ *~ /.vscode/ *.code-workspace + +dist/ diff --git a/.goreleaser.yaml b/.goreleaser.yaml new file mode 100644 index 0000000..c3ab360 --- /dev/null +++ b/.goreleaser.yaml @@ -0,0 +1,54 @@ +before: + hooks: + - go mod tidy +builds: + - env: + - CGO_ENABLED=0 + goos: + - linux + - windows + - darwin + - freebsd + goarch: + - amd64 + - arm64 + ignore: + - goos: windows + goarch: arm + main: ./cmd/mercury + flags: + - -trimpath + ldflags: + - -s -w -X github.com/kgaughan/mercury/internal/version.Version={{.Version}} + tags: + - netgo + +archives: + - format: tar.xz + 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 + files: + - LICENSE + - README.md + - theme/* +checksum: + name_template: "checksums.txt" +snapshot: + name_template: "{{ incpatch .Version }}-next" +changelog: + sort: asc + filters: + exclude: + - "^docs:" + - "^test:" +# yaml-language-server: $schema=https://goreleaser.com/static/schema.json +# vim: set ts=2 sw=2 tw=0 fo=cnqoj diff --git a/Makefile b/Makefile index bac8c13..230207a 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,3 @@ -VERSION:=$(shell git describe --tags --always | sed s/^v//) - SOURCE:=$(wildcard internal/*.go internal/*/*.go cmd/mercury/*.go) build: go.mod mercury @@ -7,10 +5,10 @@ build: go.mod mercury tidy: go.mod clean: - rm -f mercury + rm -rf mercury dist mercury: $(SOURCE) go.sum - CGO_ENABLED=0 go build -trimpath -ldflags '-s -w -X github.com/kgaughan/mercury/internal/version.Version=$(VERSION)' -o mercury ./cmd/mercury + CGO_ENABLED=0 go build -tags netgo -trimpath -ldflags '-s -w' -o mercury ./cmd/mercury update: go get -u ./... diff --git a/internal/version/version.go b/internal/version/version.go index 112ac2c..b948307 100644 --- a/internal/version/version.go +++ b/internal/version/version.go @@ -2,7 +2,7 @@ package version import "fmt" -// Version contains the version (set during build). +// nolint: gochecknoglobals var Version string const repo = "https://github.com/kgaughan/mercury/" diff --git a/todo.md b/todo.md index 2ee2ec3..e92ac01 100644 --- a/todo.md +++ b/todo.md @@ -1,7 +1,5 @@ # TODO - [ ] If a cache miss causes an item to be fetched, keep the feed in memory rather than loading the copy saved to disc. -- [ ] Ensure fetched feeds are sorted from newest to oldest item. Could this be done lazily with container/heap? This would be more complicated than using the sort package, but would have the advantage of bubbling up only the required items in the feed. - [ ] Is there a good way to expose further feed/entry information in the template? -- [ ] Themes should include a BOM indicating which files should be copied across to the output directory. - [ ] Give a way to specify particular categories that should be included from the source feed. This would be useful for blogs that lack per-category feeds.