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/.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.* diff --git a/.goreleaser.yml b/.goreleaser.yml new file mode 100644 index 0000000..ab9e5dd --- /dev/null +++ b/.goreleaser.yml @@ -0,0 +1,57 @@ +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: [binary] + name_template: >- + {{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }} + +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=