Skip to content

Commit

Permalink
Add goreleaser code
Browse files Browse the repository at this point in the history
  • Loading branch information
ross-spencer committed Jul 15, 2023
1 parent a1d6b6c commit 0dcdd26
Show file tree
Hide file tree
Showing 5 changed files with 89 additions and 3 deletions.
24 changes: 24 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: goreleaser
on:
push:
tags:
- '*'
jobs:
goreleaser:
runs-on: ubuntu-latest
steps:
- name: "checkout"
uses: actions/checkout@v2
- name: "fetch unshallow"
run: git fetch --prune --unshallow
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.20.2
- name: "run GoReleaser"
uses: goreleaser/goreleaser-action@v2
with:
version: latest
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
moonshine
dist/*
40 changes: 40 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
project_name: moonshine
builds:
- env: [CGO_ENABLED=0]
goos:
- linux
- windows
- darwin
- freebsd
ignore:
- goos: linux
goarch: arm64
- goos: darwin
goarch: arm64
- goos: freebsd
goarch: 386
- goos: freebsd
goarch: arm64
- goos: windows
goarch: arm64
archives:
- name_template: >-
{{ .ProjectName }}_{{ .Version }}_
{{- title .Os }}_
{{- if eq .Arch "amd64" }}x86_64
{{- else if eq .Arch "386" }}i386
{{- else if eq .Arch "arm64" }}arm64
{{- else }}{{ .Arch }}{{ end }}
format: tar.gz
format_overrides:
- goos: windows
format: zip
checksum:
name_template: 'checksums_sha256.txt'
algorithm: sha256
changelog:
sort: asc
filters:
exclude:
- '^docs:'
- '^test:'
17 changes: 16 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ or Warclight:
```./moonshine -warclight -gif | xargs wget```

Full usage:
```

```text
Usage of ./moonshine:
-ffb string
first four bytes of file to find (default "0baddeed")
Expand All @@ -28,3 +29,17 @@ Usage of ./moonshine:
-warclight
Use Warclight instead of Shine
```

## Developing moonshine

### Goreleaser

Testing goreleaser can be done as follows:

* `goreleaser release --skip-publish`

Valid semantic versioning looks as follows:

* `vMM.mm.pp-rc.n`

Where `-rc.n` are optional, e.g. used purely for release candidates.
10 changes: 8 additions & 2 deletions moonshine.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,13 @@ type shineRequest struct {
order string // order=asc
}

const agent string = "moonshine/1.0.0"
var (
version = "dev-0.0.0"
commit = "000000000000000000000000000000000baddeed"
date = "1970-01-01T00:00:01Z"
)

var agent string = fmt.Sprintf("moonshine/%s", version)

// Search result limits to be kind to Shine.
const solrMaxPages int = 1000
Expand Down Expand Up @@ -353,7 +359,7 @@ func getFile() {
func main() {
flag.Parse()
if vers {
fmt.Fprintf(os.Stderr, "%s \n", agent)
fmt.Fprintf(os.Stderr, "%s (%s) commit: %s date: %s\n", agent, version, commit, date)
os.Exit(0)
} else if flag.NFlag() < 0 { // can access args w/ len(os.Args[1:]) too
fmt.Fprintln(os.Stderr, "Usage: baddeed")
Expand Down

0 comments on commit 0dcdd26

Please sign in to comment.