Skip to content

Commit 750d601

Browse files
authored
Fix boolean input parsing, hide built-in help sub-command, and improve release action (#133)
* Fix boolean input processing and handle invalid inputs gracefully * Hide the built-in 'help' sub-command that shows up as a duplicate of the custom workflow help command in root command help * Set the CLI version on build via ldflags * Add Docker build and push job to release action * Add version build arg for Docker image versioning in release job
1 parent b64b6ab commit 750d601

File tree

5 files changed

+48
-3
lines changed

5 files changed

+48
-3
lines changed

.github/workflows/release.yaml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,41 @@ jobs:
3131
goos: ${{ matrix.goos }}
3232
goarch: ${{ matrix.goarch }}
3333
asset_name: '${{ env.REPOSITORY_NAME }}-${{ env.RELEASE_TAG }}-${{ env.OS_NAME }}-${{ matrix.goarch }}'
34+
ldflags: '-X github.com/trickest/trickest-cli/pkg/version.Version=v${{ env.RELEASE_TAG }}'
35+
docker:
36+
runs-on: ubuntu-latest
37+
steps:
38+
- name: Checkout
39+
uses: actions/checkout@v4
40+
41+
- name: Docker meta
42+
id: meta
43+
uses: docker/metadata-action@v5
44+
with:
45+
images: |
46+
quay.io/trickest/trickest-cli
47+
tags: |
48+
type=raw,value=latest
49+
type=semver,pattern={{version}}
50+
51+
- name: Login to Quay.io
52+
uses: docker/login-action@v3
53+
with:
54+
registry: quay.io
55+
username: ${{ secrets.QUAY_USERNAME }}
56+
password: ${{ secrets.QUAY_ROBOT_TOKEN }}
57+
58+
- name: Set up QEMU
59+
uses: docker/setup-qemu-action@v3
60+
61+
- name: Set up Docker Buildx
62+
uses: docker/setup-buildx-action@v3
63+
64+
- name: Build and push
65+
uses: docker/build-push-action@v6
66+
with:
67+
platforms: linux/amd64,linux/arm64
68+
push: true
69+
tags: ${{ steps.meta.outputs.tags }}
70+
build-args: |
71+
VERSION=v${{ env.RELEASE_TAG }}

Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ COPY . /app
66

77
WORKDIR /app
88

9-
RUN env GOOS=linux GOARCH=amd64 go build .
9+
ARG VERSION=dev
10+
RUN env GOOS=linux GOARCH=amd64 go build -ldflags "-X github.com/trickest/trickest-cli/pkg/version.Version=${VERSION}" .
1011

1112
FROM --platform=linux/amd64 alpine:3.21
1213

cmd/root.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,4 +65,5 @@ func init() {
6565
RootCmd.AddCommand(investigate.InvestigateCmd)
6666

6767
RootCmd.SetVersionTemplate(`{{printf "Trickest CLI %s\n" .Version}}`)
68+
RootCmd.SetHelpCommand(&cobra.Command{Hidden: true})
6869
}

pkg/version/version.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
package version
22

33
// Version is the current version of the CLI
4-
var Version = "v2.0.0"
4+
// This is set during build via ldflags in the Dockerfile and GitHub Actions release workflow
5+
var Version = "dev"

pkg/workflowbuilder/primitive.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ func setPrimitiveNodeValue(pNode *trickest.PrimitiveNode, value any) error {
113113
func processPrimitiveNodeValue(nodeType string, value any) (any, string, error) {
114114
var normalizedValue any
115115
var label string
116+
var err error
116117

117118
switch val := value.(type) {
118119
case string:
@@ -130,7 +131,10 @@ func processPrimitiveNodeValue(nodeType string, value any) (any, string, error)
130131
}
131132
normalizedValue = val
132133
case "BOOLEAN":
133-
normalizedValue = val
134+
normalizedValue, err = strconv.ParseBool(val)
135+
if err != nil {
136+
return nil, "", fmt.Errorf("invalid boolean value: %v", value)
137+
}
134138
}
135139
case int:
136140
normalizedValue = strconv.Itoa(val)

0 commit comments

Comments
 (0)