Skip to content

Commit 4c04751

Browse files
committed
Use goreleaer
1 parent 092fe76 commit 4c04751

File tree

8 files changed

+168
-3
lines changed

8 files changed

+168
-3
lines changed

.github/workflows/notify.yaml

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: Notify
2+
3+
on:
4+
discussion:
5+
types: [created, reopened]
6+
issues:
7+
types: [opened, reopened]
8+
9+
jobs:
10+
notify:
11+
runs-on: ubuntu-22.04
12+
steps:
13+
- name: Send notification
14+
uses: USA-RedDragon/telegram-notification@v1.0.0
15+
with:
16+
bot-token: ${{ secrets.TG_BOT_TOKEN }}
17+
chat-id: ${{ secrets.TG_CHAT_ID }}

.github/workflows/pr.yaml

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Static Checks
2+
on: pull_request
3+
4+
permissions:
5+
contents: read
6+
pull-requests: read
7+
8+
concurrency:
9+
group: '${{ github.workflow }} @ ${{ github.ref }}'
10+
cancel-in-progress: true
11+
12+
jobs:
13+
golangci:
14+
name: lint
15+
runs-on: ubuntu-22.04
16+
steps:
17+
- uses: actions/checkout@v4
18+
- uses: actions/setup-go@v5
19+
with:
20+
go-version-file: go.mod
21+
- name: golangci-lint
22+
uses: golangci/golangci-lint-action@v4
23+
with:
24+
version: latest
25+
skip-cache: true
26+
only-new-issues: true

.github/workflows/release.yaml

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*"
7+
8+
concurrency:
9+
group: '${{ github.workflow }} @ ${{ github.ref }}'
10+
cancel-in-progress: false
11+
12+
jobs:
13+
release:
14+
name: Release
15+
permissions:
16+
contents: write
17+
packages: write
18+
uses: USA-RedDragon/reusable-actions/.github/workflows/goreleaser.yaml@v1.0.21
19+
secrets:
20+
token: ${{ secrets.GITHUB_TOKEN }}

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
gba_bios.bin
22
*.sav
33
*.gba
4+
dist/

.golangci.yaml

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
run:
2+
timeout: 30m
3+
4+
skip-files:
5+
- ".*\\_gen\\.go$"
6+
- ".*\\_gen\\_test\\.go$"
7+
- ".*\\_test\\.go$"
8+
9+
linters:
10+
enable:
11+
- asasalint
12+
- asciicheck
13+
- bidichk
14+
- containedctx
15+
- contextcheck
16+
- decorder
17+
- dogsled
18+
- dupword
19+
- durationcheck
20+
- errchkjson
21+
- errname
22+
- errorlint
23+
- exhaustive
24+
- exportloopref
25+
- forcetypeassert
26+
- gci
27+
- gocheckcompilerdirectives
28+
- gochecknoglobals
29+
- gochecknoinits
30+
- goconst
31+
- gocritic
32+
- gocyclo
33+
- godox
34+
- gofmt
35+
- goheader
36+
- gomoddirectives
37+
- gosec
38+
- grouper
39+
- loggercheck
40+
- misspell
41+
- nilerr
42+
- nilnil
43+
- noctx
44+
- nosprintfhostport
45+
- paralleltest
46+
- prealloc
47+
- predeclared
48+
- reassign
49+
- revive
50+
- testpackage
51+
- tparallel
52+
- unconvert
53+
- unparam
54+
- usestdlibvars
55+
- wastedassign
56+
- whitespace

.goreleaser.yml

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
---
2+
project_name: go-gba
3+
4+
release:
5+
extra_files:
6+
- glob: ./LICENSE
7+
github:
8+
owner: USA-RedDragon
9+
name: "{{ .ProjectName }}"
10+
11+
builds:
12+
- main: .
13+
binary: "{{ .ProjectName }}"
14+
goos:
15+
- linux
16+
- windows
17+
- darwin
18+
goarch:
19+
- amd64
20+
- arm64
21+
env:
22+
- CGO_ENABLED=1
23+
ldflags:
24+
- -s -w
25+
- -X main.version={{ .Version }}
26+
- -X main.commit={{ .ShortCommit }}
27+
flags:
28+
- -trimpath
29+
30+
milestones:
31+
- close: true

cmd/go-gba.go

+8-2
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,14 @@ import (
1616
"github.com/spf13/cobra"
1717
)
1818

19-
func New() *cobra.Command {
19+
func New(version, commit string) *cobra.Command {
2020
cmd := &cobra.Command{
21-
Use: "go-gba [-b gba_bios.bin] [-r path to ROM]",
21+
Use: "go-gba [-b gba_bios.bin] [-r path to ROM]",
22+
Version: fmt.Sprintf("%s - %s", version, commit),
23+
Annotations: map[string]string{
24+
"version": version,
25+
"commit": commit,
26+
},
2227
RunE: run,
2328
SilenceErrors: true,
2429
DisableAutoGenTag: true,
@@ -88,6 +93,7 @@ func runComparer(cmd *cobra.Command) error {
8893
}
8994

9095
func run(cmd *cobra.Command, args []string) error {
96+
fmt.Printf("go-gba %s-%s\n", cmd.Annotations["version"], cmd.Annotations["commit"])
9197
diff, err := cmd.Flags().GetBool("diff")
9298
if err != nil {
9399
return err

main.go

+9-1
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,16 @@ import (
66
"github.com/USA-RedDragon/go-gba/cmd"
77
)
88

9+
// https://goreleaser.com/cookbooks/using-main.version/
10+
//
11+
//nolint:golint,gochecknoglobals
12+
var (
13+
version = "dev"
14+
commit = "none"
15+
)
16+
917
func main() {
10-
rootCmd := cmd.New()
18+
rootCmd := cmd.New(version, commit)
1119
rootCmd.Version = "next"
1220
if err := rootCmd.Execute(); err != nil {
1321
log.Fatal(err)

0 commit comments

Comments
 (0)