From e57239d963dcb2f7048ced7f570e5470f16e3ce9 Mon Sep 17 00:00:00 2001 From: buty4649 Date: Fri, 17 Apr 2026 12:39:30 +0900 Subject: [PATCH 1/3] Add goreleaser and tagpr for automated releases - .goreleaser.yml: builds for linux/amd64, darwin/arm64, windows/amd64 - .github/workflows/release.yml: runs goreleaser on tag push - .tagpr + .github/workflows/tagpr.yml: automates version PRs and tagging - cmd/root.go: expose version/commit/date via --version, injected via ldflags Co-Authored-By: Claude Opus 4.7 --- .github/workflows/release.yml | 30 ++++++++++++++++++ .github/workflows/tagpr.yml | 18 +++++++++++ .goreleaser.yml | 60 +++++++++++++++++++++++++++++++++++ .tagpr | 7 ++++ cmd/root.go | 7 ++++ go.sum | 1 - 6 files changed, 122 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/release.yml create mode 100644 .github/workflows/tagpr.yml create mode 100644 .goreleaser.yml create mode 100644 .tagpr diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..c3c1072 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,30 @@ +name: release + +on: + push: + tags: + - "v*.*.*" + +permissions: + contents: write + +jobs: + goreleaser: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + with: + fetch-depth: 0 + + - uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0 + with: + go-version-file: go.mod + cache: true + + - uses: goreleaser/goreleaser-action@ec59f474b9834571250b370d4735c50f8e2d1e29 # v7.0.0 + with: + distribution: goreleaser + version: "~> v2" + args: release --clean + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/tagpr.yml b/.github/workflows/tagpr.yml new file mode 100644 index 0000000..985ebdf --- /dev/null +++ b/.github/workflows/tagpr.yml @@ -0,0 +1,18 @@ +name: tagpr + +on: + push: + branches: + - main + +permissions: + contents: write + pull-requests: write + +jobs: + tagpr: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + + - uses: Songmu/tagpr@9bbb945b2fb025126186661e27d55485e3fc6df6 # v1.18.3 diff --git a/.goreleaser.yml b/.goreleaser.yml new file mode 100644 index 0000000..72113b8 --- /dev/null +++ b/.goreleaser.yml @@ -0,0 +1,60 @@ +version: 2 + +project_name: xpoint-cli + +before: + hooks: + - go mod tidy + +builds: + - id: xp + binary: xp + main: . + env: + - CGO_ENABLED=0 + flags: + - -trimpath + ldflags: + - -s -w + - -X github.com/pepabo/xpoint-cli/cmd.version={{.Version}} + - -X github.com/pepabo/xpoint-cli/cmd.commit={{.Commit}} + - -X github.com/pepabo/xpoint-cli/cmd.date={{.Date}} + goos: + - linux + - darwin + - windows + goarch: + - amd64 + - arm64 + ignore: + - goos: linux + goarch: arm64 + - goos: darwin + goarch: amd64 + - goos: windows + goarch: arm64 + +archives: + - formats: [tar.gz] + name_template: >- + {{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }} + format_overrides: + - goos: windows + formats: [zip] + +checksum: + name_template: checksums.txt + +changelog: + use: github + sort: asc + filters: + exclude: + - "^docs:" + - "^test:" + - "^chore:" + - "^ci:" + +release: + draft: false + prerelease: auto diff --git a/.tagpr b/.tagpr new file mode 100644 index 0000000..721084e --- /dev/null +++ b/.tagpr @@ -0,0 +1,7 @@ +[tagpr] + vPrefix = true + releaseBranch = main + versionFile = - + release = true + majorLabels = tagpr:major + minorLabels = tagpr:minor diff --git a/cmd/root.go b/cmd/root.go index ef8200e..e9e2a8f 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -17,11 +17,18 @@ var ( flagAPIAccessToken string ) +var ( + version = "dev" + commit = "none" + date = "unknown" +) + var rootCmd = &cobra.Command{ Use: "xp", Short: "X-point CLI", Long: "xp is a CLI client for X-point (https://atled-workflow.github.io/X-point-doc/api/).", SilenceUsage: true, + Version: fmt.Sprintf("%s (commit: %s, built: %s)", version, commit, date), } func Execute() { diff --git a/go.sum b/go.sum index 15001df..3de9430 100644 --- a/go.sum +++ b/go.sum @@ -8,7 +8,6 @@ github.com/itchyny/timefmt-go v0.1.8/go.mod h1:5E46Q+zj7vbTgWY8o5YkMeYb4I6GeWLFn github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/spf13/cobra v1.10.2 h1:DMTTonx5m65Ic0GOoRY2c16WCbHxOOw6xxezuLaBpcU= github.com/spf13/cobra v1.10.2/go.mod h1:7C1pvHqHw5A4vrJfjNwvOdzYu0Gml16OCs2GRiTUUS4= -github.com/spf13/pflag v1.0.9 h1:9exaQaMOCwffKiiiYk6/BndUBv+iRViNW+4lEMi0PvY= github.com/spf13/pflag v1.0.9/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= github.com/spf13/pflag v1.0.10 h1:4EBh2KAYBwaONj6b2Ye1GiHfwjqyROoF4RwYO+vPwFk= github.com/spf13/pflag v1.0.10/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= From f31ba49482b3e310c7473516ae71a4bbefe47998 Mon Sep 17 00:00:00 2001 From: buty4649 Date: Fri, 17 Apr 2026 12:42:24 +0900 Subject: [PATCH 2/3] Use binary archive format for releases Distribute raw executables (no tar.gz/zip wrapper) so users can download and run directly. Co-Authored-By: Claude Opus 4.7 --- .goreleaser.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.goreleaser.yml b/.goreleaser.yml index 72113b8..ab9e5dd 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -35,12 +35,9 @@ builds: goarch: arm64 archives: - - formats: [tar.gz] + - formats: [binary] name_template: >- {{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }} - format_overrides: - - goos: windows - formats: [zip] checksum: name_template: checksums.txt From 64ccc5f577e4452cb9ea8ecd9db91003ef70a672 Mon Sep 17 00:00:00 2001 From: buty4649 Date: Fri, 17 Apr 2026 12:43:21 +0900 Subject: [PATCH 3/3] Ignore GoReleaser dist directory Co-Authored-By: Claude Opus 4.7 --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index bf37466..7bc4bfa 100644 --- a/.gitignore +++ b/.gitignore @@ -14,6 +14,9 @@ # Built CLI binary /xp +# GoReleaser output +/dist/ + # Code coverage profiles and other test artifacts *.out coverage.*