Skip to content

Commit

Permalink
Support goreleaser (#35)
Browse files Browse the repository at this point in the history
I'm hoping this will help with release automation. Obviously, I've no
way of really testing it until I commit it, so fingers crossed...
  • Loading branch information
kgaughan authored Jun 3, 2023
1 parent 02963a7 commit 8aec636
Show file tree
Hide file tree
Showing 6 changed files with 90 additions and 7 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -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 }}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@
*~
/.vscode/
*.code-workspace

dist/
54 changes: 54 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -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
6 changes: 2 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
VERSION:=$(shell git describe --tags --always | sed s/^v//)

SOURCE:=$(wildcard internal/*.go internal/*/*.go cmd/mercury/*.go)

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 ./...
Expand Down
2 changes: 1 addition & 1 deletion internal/version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -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/"
Expand Down
2 changes: 0 additions & 2 deletions todo.md
Original file line number Diff line number Diff line change
@@ -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.

0 comments on commit 8aec636

Please sign in to comment.