The only tool you need to know what is happening and how to fix it.
Go alertingexception-trackerissue-trackinglogsmetricsmonitoringobservability-platformopen-telemetryotelsession-replaytelemetrytraces
feat: releasing cli when we release the backend
ddux4609247dc2c3
diff --git a/.github/workflows/release-cli.yml b/.github/workflows/release-cli.ymlindex 0e69e0a5..e01c4489 100644--- a/.github/workflows/release-cli.yml+++ b/.github/workflows/release-cli.yml@@ -1,32 +1,15 @@name: Release CLIon:+ push:+ tags:+ - 'backend/v*'workflow_dispatch:inputs:version:description: "Release version (X.Y.Z, no leading v)"required: truetype: string- change_1:- description: "Changelog item 1 (optional)"- required: false- type: string- change_2:- description: "Changelog item 2 (optional)"- required: false- type: string- change_3:- description: "Changelog item 3 (optional)"- required: false- type: string- change_4:- description: "Changelog item 4 (optional)"- required: false- type: string- change_5:- description: "Changelog item 5 (optional)"- required: false- type: stringpermissions:contents: write@@ -35,10 +18,20 @@ jobs:release:runs-on: ubuntu-lateststeps:+ - name: Determine version+ id: version+ run: |+ if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then+ echo "version=${{ inputs.version }}" >> "$GITHUB_OUTPUT"+ else+ TAG="${{ github.ref_name }}"+ echo "version=${TAG#backend/v}" >> "$GITHUB_OUTPUT"+ fi+- name: Validate version formatrun: |- if ! [[ "${{ inputs.version }}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then- echo "Error: version must be in X.Y.Z format (got '${{ inputs.version }}')"+ if ! [[ "${{ steps.version.outputs.version }}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then+ echo "Error: version must be in X.Y.Z format (got '${{ steps.version.outputs.version }}')"exit 1fi@@ -46,11 +39,10 @@ jobs:uses: actions/checkout@v4with:fetch-depth: 0- token: ${{ secrets.RELEASE_TOKEN }}- name: Check tag does not already existrun: |- TAG="cli/v${{ inputs.version }}"+ TAG="cli/v${{ steps.version.outputs.version }}"if git rev-parse "$TAG" >/dev/null 2>&1; thenecho "Error: tag $TAG already exists"exit 1@@ -65,7 +57,7 @@ jobs:- name: Build cross-platform binariesworking-directory: clienv:- VERSION: ${{ inputs.version }}+ VERSION: ${{ steps.version.outputs.version }}CGO_ENABLED: "0"run: |set -euo pipefail@@ -85,7 +77,7 @@ jobs:BIN="traceway"[[ "$OS" == "windows" ]] && BIN="traceway.exe"echo "Building $OS/$ARCH -> $STAGE/$BIN"- GOOS="$OS" GOARCH="$ARCH" go build -trimpath -o "$STAGE/$BIN" ./cmd/traceway+ GOOS="$OS" GOARCH="$ARCH" go build -trimpath -ldflags "-X main.version=${VERSION}" -o "$STAGE/$BIN" ./cmd/tracewaycp README.md "$STAGE/"cp ../LICENSE "$STAGE/"ARCHIVE_BASE="traceway_${VERSION}_${OS}_${LABEL}"@@ -104,36 +96,14 @@ jobs:sha256sum * > checksums.txtcat checksums.txt- - name: Configure git- run: |- git config user.name "github-actions[bot]"- git config user.email "41898282+github-actions[bot]@users.noreply.github.com"-- - name: Tag release- run: git tag "cli/v${{ inputs.version }}"-- - name: Push tag- run: git push origin "cli/v${{ inputs.version }}"-- name: Create GitHub Releaseenv:GH_TOKEN: ${{ github.token }}- C1: ${{ inputs.change_1 }}- C2: ${{ inputs.change_2 }}- C3: ${{ inputs.change_3 }}- C4: ${{ inputs.change_4 }}- C5: ${{ inputs.change_5 }}+ VERSION: ${{ steps.version.outputs.version }}run: |- NOTES=""- for C in "$C1" "$C2" "$C3" "$C4" "$C5"; do- if [ -n "$C" ]; then- NOTES="${NOTES}- ${C}"$'\n'- fi- done- if [ -z "$NOTES" ]; then- NOTES="CLI v${{ inputs.version }}"- fi- gh release create "cli/v${{ inputs.version }}" \- --title "CLI v${{ inputs.version }}" \+ NOTES="CLI v${VERSION}, released alongside [Backend v${VERSION}](https://github.com/${{ github.repository }}/releases/tag/backend/v${VERSION})."+ gh release create "cli/v${VERSION}" \+ --target "${{ github.sha }}" \+ --title "CLI v${VERSION}" \--notes "$NOTES" \cli/dist/*diff --git a/cli/README.md b/cli/README.mdindex 6d8bae21..ec0e7821 100644--- a/cli/README.md+++ b/cli/README.md@@ -4,7 +4,13 @@ A Go CLI for the [Traceway](https://github.com/tracewayapp/traceway) observabili## Install-This repo ships a Nix dev shell with Go 1.26, `just`, `gotestsum`, `golangci-lint`, `govulncheck`, and `gh`:+Prebuilt binaries are published with every release at+[github.com/tracewayapp/traceway/releases](https://github.com/tracewayapp/traceway/releases)+under the matching `CLI vX.Y.Z` tag — the CLI version tracks the backend release.+Download the archive for your platform (`traceway_<version>_<os>_<arch>.tar.gz`,+or `.zip` on Windows), extract it, and put `traceway` on your `PATH`.++Or build from source — this repo ships a Nix dev shell with Go 1.26, `just`, `gotestsum`, `golangci-lint`, `govulncheck`, and `gh`:```bashnix develop@@ -17,6 +23,8 @@ Or vanilla Go:go build -o bin/traceway ./cmd/traceway```+Check an installed binary with `traceway version` (or `traceway --version`). Source builds report `dev`.+## Quick start```bashdiff --git a/cli/cmd/traceway/root.go b/cli/cmd/traceway/root.goindex b76a31c2..8f36da9d 100644--- a/cli/cmd/traceway/root.go+++ b/cli/cmd/traceway/root.go@@ -17,6 +17,7 @@ func newRootCmd() *cobra.Command {cmd := &cobra.Command{Use: "traceway",Short: "CLI for the Traceway observability platform",+ Version: version,SilenceUsage: true, // we render our own error envelopesSilenceErrors: true,}@@ -36,6 +37,7 @@ func newRootCmd() *cobra.Command {cmd.AddCommand(newLogsCmd())cmd.AddCommand(newEndpointsCmd())cmd.AddCommand(newMetricsCmd())+ cmd.AddCommand(newVersionCmd())return cmd}diff --git a/cli/cmd/traceway/version.go b/cli/cmd/traceway/version.gonew file mode 100644index 00000000..b527aa6e--- /dev/null+++ b/cli/cmd/traceway/version.go@@ -0,0 +1,38 @@+package main++import (+ "fmt"++ "github.com/spf13/cobra"++ "github.com/tracewayapp/traceway/cli/internal/output"+)++var version = "dev"++type versionInfo struct {+ Version string `json:"version"`+}++func newVersionCmd() *cobra.Command {+ return &cobra.Command{+ Use: "version",+ Short: "Print the traceway CLI version",+ Args: cobra.NoArgs,+ RunE: runVersion,+ }+}++func runVersion(cmd *cobra.Command, _ []string) error {+ mode := output.ResolveMode(flagOutput, output.StdoutIsTerminal())+ info := versionInfo{Version: version}+ switch mode {+ case output.ModeJSON:+ return output.RenderJSON(cmd.OutOrStdout(), info, output.ParseFieldsFlag(flagFields))+ case output.ModeYAML:+ return output.RenderYAML(cmd.OutOrStdout(), info, output.ParseFieldsFlag(flagFields))+ default:+ _, err := fmt.Fprintf(cmd.OutOrStdout(), "traceway version %s\n", version)+ return err+ }+}diff --git a/cli/cmd/traceway/version_test.go b/cli/cmd/traceway/version_test.gonew file mode 100644index 00000000..951c3833--- /dev/null+++ b/cli/cmd/traceway/version_test.go@@ -0,0 +1,36 @@+package main++import (+ "strings"+ "testing"+)++func TestVersion_table(t *testing.T) {+ stdout, _, err := runCmd(t, "", "version", "--output", "table")+ if err != nil {+ t.Fatal(err)+ }+ if !strings.Contains(stdout.String(), "traceway version "+version) {+ t.Errorf("expected version line, got: %s", stdout.String())+ }+}++func TestVersion_json(t *testing.T) {+ stdout, _, err := runCmd(t, "", "version", "--output", "json")+ if err != nil {+ t.Fatal(err)+ }+ if !strings.Contains(stdout.String(), `"version"`) {+ t.Errorf("expected 'version' field in JSON, got: %s", stdout.String())+ }+}++func TestVersion_flag(t *testing.T) {+ stdout, _, err := runCmd(t, "", "--version")+ if err != nil {+ t.Fatal(err)+ }+ if !strings.Contains(stdout.String(), version) {+ t.Errorf("expected version in --version output, got: %s", stdout.String())+ }+}