From c4ed189f48b48d1fe59cef882bebc40170b807c8 Mon Sep 17 00:00:00 2001 From: Ed Zynda Date: Fri, 3 Jan 2025 07:08:49 +0300 Subject: [PATCH] Setup goreleaser --- .github/workflows/release.yml | 33 +++++++++++++++++++++++++ .gitignore | 3 ++- .goreleaser.yaml | 45 +++++++++++++++++++++++++++++++++++ main.go | 2 ++ 4 files changed, 82 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/release.yml create mode 100644 .goreleaser.yaml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..b14847fc --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,33 @@ +name: Release + +on: + push: + tags: + - "v*" + +permissions: + contents: write + +jobs: + goreleaser: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Set up Go + uses: actions/setup-go@v4 + with: + go-version: ">=1.21.0" + cache: true + + - name: Run GoReleaser + uses: goreleaser/goreleaser-action@v5 + with: + distribution: goreleaser + version: latest + args: release --clean + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.gitignore b/.gitignore index 79bed4da..3fa4cdb6 100644 --- a/.gitignore +++ b/.gitignore @@ -7,4 +7,5 @@ mcphost .idea test/ build/ -scripts/ \ No newline at end of file +scripts/ +dist/ diff --git a/.goreleaser.yaml b/.goreleaser.yaml new file mode 100644 index 00000000..c56db21f --- /dev/null +++ b/.goreleaser.yaml @@ -0,0 +1,45 @@ +before: + hooks: + - go mod tidy + +builds: + - env: + - CGO_ENABLED=0 + goos: + - linux + - windows + - darwin + goarch: + - amd64 + - arm64 + ignore: + - goos: windows + goarch: arm64 + binary: mcphost + ldflags: + - -s -w -X main.version={{.Version}} + +archives: + - format: tar.gz + name_template: >- + {{ .ProjectName }}_ + {{- title .Os }}_ + {{- if eq .Arch "amd64" }}x86_64 + {{- else }}{{ .Arch }}{{ end }} + {{- if .Arm }}v{{ .Arm }}{{ end }} + format_overrides: + - goos: windows + format: zip + +checksum: + name_template: "checksums.txt" + +changelog: + sort: asc + filters: + exclude: + - "^docs:" + - "^test:" + - "^ci:" + - Merge pull request + - Merge branch diff --git a/main.go b/main.go index ba868ad3..e6aec7c2 100644 --- a/main.go +++ b/main.go @@ -2,6 +2,8 @@ package main import "github.com/mark3labs/mcphost/cmd" +var version = "dev" + func main() { cmd.Execute() }