Skip to content

Commit

Permalink
Add goreleaser, close #12
Browse files Browse the repository at this point in the history
  • Loading branch information
iBug committed Sep 7, 2024
1 parent 9bc32ac commit c769723
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 16 deletions.
26 changes: 10 additions & 16 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ jobs:
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: ^1.22
go-version: stable
check-latest: true
id: go

- name: Get dependencies
Expand All @@ -29,21 +30,14 @@ jobs:
run: |
go test -race ./... && go vet ./...
- name: Build
run: |
GOARCH=amd64 CGO_ENABLED=0 go build -o ayano-amd64 -v .
GOARCH=arm64 CGO_ENABLED=0 go build -o ayano-arm64 -v .
- uses: goreleaser/goreleaser-action@v6
with:
args: build

- name: Deploy - Create Release
if: startsWith(github.ref, 'refs/tags/')
id: create_release
uses: softprops/action-gh-release@v2
- uses: goreleaser/goreleaser-action@v6
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
with:
version: latest
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref_name }}
draft: false
files: |
ayano-amd64
ayano-arm64
prerelease: false
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ ayano-*
ayano.test
cpu.pprof
__debug_bin*
/dist/
43 changes: 43 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
version: 2

before:
hooks:
- go mod tidy

builds:
- id: ayano
binary: "{{ .ProjectName }}-{{ .Os }}-{{ .Arch }}{{ if .Amd64 }}-{{ .Amd64 }}{{ end }}"
env:
- CGO_ENABLED=0
goos:
- linux
goarch:
- amd64
- arm64
goarm:
- 7
goamd64:
- v2
- v3
flags:
- -trimpath
ldflags:
- -s -w -X github.com/taoky/ayano/pkg/info.Version={{.Version}} -X github.com/taoky/ayano/pkg/info.BuildDate={{.Date}} -X github.com/taoky/ayano/pkg/info.GitCommit={{.Commit}}
no_unique_dist_dir: true

archives:
- format: binary
name_template: "{{ .Binary }}"

checksum:
name_template: 'checksums.txt'

snapshot:
name_template: "{{ incpatch .Version }}-next"

changelog:
use: github-native

# modelines, 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
7 changes: 7 additions & 0 deletions pkg/info/info.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package info

var (
Version string
BuildDate string
GitCommit string
)

0 comments on commit c769723

Please sign in to comment.