Skip to content

Commit aa2beed

Browse files
committed
Support for version command in smithyctl.
1 parent de49572 commit aa2beed

File tree

4 files changed

+24
-11
lines changed

4 files changed

+24
-11
lines changed

.github/workflows/publish-smithyctl.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232
3333
- name: Build Smithyctl
3434
run: |
35-
make smithyctl/bin
35+
make smithyctl/bin SMITHYCTL_VERSION=${{ steps.tag_info.outputs.version }}
3636
cd bin/smithyctl/cmd/linux/amd64/
3737
tar --create --file smithyctl-linux-amd64-${{ steps.tag_info.outputs.version }}.tar.gz --verbose --gzip smithyctl
3838

Makefile

+7-1
Original file line numberDiff line numberDiff line change
@@ -173,8 +173,14 @@ $(component_major_tags): check-branch check-tag-message
173173
smithyctl/bin:
174174
$(eval GOOS:=linux)
175175
$(eval GOARCH:=amd64)
176+
$(eval SMITHYCTL_VERSION:=development)
176177
@cd smithyctl && \
177-
GOOS=$(GOOS) GOARCH=$(GOARCH) go build -o ../bin/smithyctl/cmd/$(GOOS)/$(GOARCH)/smithyctl main.go
178+
GOOS=$(GOOS) \
179+
GOARCH=$(GOARCH) \
180+
go build \
181+
-ldflags "-X github.com/smithy-security/smithy/smithyctl/command/version.SmithyCTLVersion=${SMITHYCTL_VERSION} -s -w" \
182+
-trimpath \
183+
-o ../bin/smithyctl/cmd/$(GOOS)/$(GOARCH)/smithyctl main.go
178184

179185
component-sdk-version:
180186
@if [ -z "$(COMPONENT_DIR)" ]; then \

smithyctl/README.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@ smithyctl version
2323

2424
## Commands
2525

26-
| Command | Description | Status |
27-
|-------------|-------------------------------------------------------------|-----------------------|
28-
| `help` | will output how to use `smithyctl` | Implemented |
29-
| `version` | will output the version of the installed `smithyctl` binary | Not implemented yet |
30-
| `component` | allows to develop, run and distribute components | Not fully implemented |
31-
| `workflow` | allows to develop and run workflows | Implemented |
26+
| Command | Description |
27+
|-------------|-------------------------------------------------------------|
28+
| `help` | will output how to use `smithyctl` |
29+
| `version` | will output the version of the installed `smithyctl` binary |
30+
| `component` | allows to develop, run and distribute components |
31+
| `workflow` | allows to develop and run workflows |
3232

3333
### Component
3434

smithyctl/command/version/command.go

+10-3
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,21 @@
11
package version
22

3-
import "github.com/spf13/cobra"
3+
import (
4+
"log"
5+
6+
"github.com/spf13/cobra"
7+
)
8+
9+
// SmithyCTLVersion overridable smithyctl version.
10+
var SmithyCTLVersion = "development"
411

512
// NewCommand returns a new version command.
613
func NewCommand() *cobra.Command {
714
return &cobra.Command{
815
Use: "version",
916
Short: "Outputs smithyctl's version",
10-
// TODO: implement in https://linear.app/smithy/issue/OCU-481/version-command
11-
RunE: func(cmd *cobra.Command, args []string) error {
17+
RunE: func(_ *cobra.Command, _ []string) error {
18+
log.Println(SmithyCTLVersion)
1219
return nil
1320
},
1421
}

0 commit comments

Comments
 (0)