diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..0bcd5d6 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,60 @@ +name: Release + +on: + workflow_dispatch: + release: + types: + - published + +permissions: + contents: write + +jobs: + release: + name: Release + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v6 + with: + fetch-depth: 0 + + - name: Set up Go + uses: actions/setup-go@v6 + with: + go-version-file: "go.mod" + check-latest: true + cache: true + + - name: Get build date + id: date + run: echo "date=$(date '+%F-%T')" >> "$GITHUB_OUTPUT" + + - name: Get build unix timestamp + id: timestamp + run: echo "timestamp=$(date '+%s')" >> "$GITHUB_OUTPUT" + + - name: Get git branch + id: branch + run: echo "branch=$(git rev-parse --abbrev-ref HEAD)" >> "$GITHUB_OUTPUT" + + - name: Get build platform + id: platform + run: echo "platform=$(go version | cut -d ' ' -f 4)" >> "$GITHUB_OUTPUT" + + - name: Get Go version + id: go + run: echo "go=$(go version | cut -d ' ' -f 3)" >> "$GITHUB_OUTPUT" + + - name: Run GoReleaser + uses: goreleaser/goreleaser-action@v6 + with: + version: v2.12.7 + args: release + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + BUILD_DATE: ${{ steps.date.outputs.date }} + BUILD_TS_UNIX: ${{ steps.timestamp.outputs.timestamp }} + GIT_BRANCH: ${{ steps.branch.outputs.branch }} + BUILD_PLATFORM: ${{ steps.platform.outputs.platform }} + GO_VERSION: ${{ steps.go.outputs.go }} diff --git a/.gitignore b/.gitignore index cf40acf..3c6e6cf 100644 --- a/.gitignore +++ b/.gitignore @@ -9,6 +9,7 @@ *.dylib /cloud-cli /temporal-cloud +dist/ # Test binary, built with `go test -c` *.test diff --git a/.goreleaser.yml b/.goreleaser.yml new file mode 100644 index 0000000..26f7d3c --- /dev/null +++ b/.goreleaser.yml @@ -0,0 +1,71 @@ +version: 2 + +before: + hooks: + - go mod download + +release: + prerelease: auto + draft: false + name_template: "v{{.Version}}" + +archives: + - <<: &archive_defaults + name_template: "temporal_cloud_cli_{{ .Version }}_{{ .Os }}_{{ .Arch }}" + id: nix + ids: + - nix + formats: + - tar.gz + files: + - LICENSE + + - <<: *archive_defaults + id: windows-zip + ids: + - windows + formats: + - zip + files: + - LICENSE + + # used by SDKs as zip cannot be used by rust https://github.com/zip-rs/zip/issues/108 + - <<: *archive_defaults + id: windows-targz + ids: + - windows + files: + - LICENSE + +builds: + - <<: &build_defaults + dir: cmd/temporal-cloud + binary: temporal-cloud + ldflags: + - -s -w -X github.com/temporalio/cloud-cli/temporalcloudcli.Version={{.Version}} + goarch: + - amd64 + - arm64 + env: + - CGO_ENABLED=0 + id: nix + goos: + - linux + - darwin + + - <<: *build_defaults + id: windows + goos: + - windows + hooks: + post: # TODO sign Windows release + +checksum: + name_template: "checksums.txt" + algorithm: sha256 + +changelog: + disable: true + +announce: + skip: "true" diff --git a/temporalcloudcli/cloud.go b/temporalcloudcli/cloud.go index 501fb29..8265b80 100644 --- a/temporalcloudcli/cloud.go +++ b/temporalcloudcli/cloud.go @@ -39,7 +39,9 @@ func (c *CloudCommand) GetAPIKey(ctx context.Context) (string, error) { } func newCloudClient(cctx *CommandContext) (*cloudclient.Client, error) { - opts := cloudclient.Options{} + opts := cloudclient.Options{ + UserAgent: fmt.Sprintf("temporalio-cloud-cli/%s", VersionString()), + } if cctx.RootCommand.Server != "" { opts.HostPort = cctx.RootCommand.Server } diff --git a/temporalcloudcli/commands.go b/temporalcloudcli/commands.go index ac8ea61..8926ec1 100644 --- a/temporalcloudcli/commands.go +++ b/temporalcloudcli/commands.go @@ -20,7 +20,6 @@ import ( "github.com/spf13/cobra" "github.com/spf13/pflag" "github.com/temporalio/cloud-cli/temporalcloudcli/internal/printer" - "github.com/temporalio/ui-server/v2/server/version" "go.temporal.io/api/common/v1" commonpb "go.temporal.io/api/common/v1" "go.temporal.io/api/failure/v1" @@ -28,7 +27,6 @@ import ( "go.temporal.io/sdk/contrib/envconfig" "go.temporal.io/sdk/converter" "go.temporal.io/sdk/temporal" - "go.temporal.io/server/common/headers" "golang.org/x/term" "google.golang.org/grpc" "google.golang.org/protobuf/proto" @@ -405,12 +403,12 @@ var buildInfo string func VersionString() string { // To add build-time information to the version string, use - // go build -ldflags "-X github.com/temporalio/cli/temporalcli.buildInfo=" + // go build -ldflags "-X github.com/temporalio/cloud-cli/temporalcloudcli.buildInfo=" var bi = buildInfo if bi != "" { bi = fmt.Sprintf(", %s", bi) } - return fmt.Sprintf("%s (Server %s, UI %s%s)", Version, headers.ServerVersion, version.UIVersion, bi) + return fmt.Sprintf("%s%s", Version, bi) } func (c *CloudCommand) preRun(cctx *CommandContext) error {