Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,28 +10,36 @@ builds:
- CGO_ENABLED=0
goos:
- linux
- windows
- darwin
goarch:
- amd64
- arm64
- arm
main: ./cli
binary: oms-cli
ldflags:
- -s -w
- -X github.com/codesphere-cloud/oms/internal/version.version={{.Version}}
- -X github.com/codesphere-cloud/oms/internal/version.commit={{.Commit}}
- -X github.com/codesphere-cloud/oms/internal/version.date={{.Date}}

- id: service
env:
- CGO_ENABLED=0
goos:
- linux
- windows
- darwin
goarch:
- amd64
- arm64
- arm
main: ./service
binary: oms-service
ldflags:
- -s -w
- -X github.com/codesphere-cloud/oms/internal/version.version={{.Version}}
- -X github.com/codesphere-cloud/oms/internal/version.commit={{.Commit}}
- -X github.com/codesphere-cloud/oms/internal/version.date={{.Date}}

changelog:
sort: asc
Expand All @@ -43,7 +51,10 @@ changelog:
- "^chore"

archives:
- formats: binary
- formats:
- binary
- tar.gz
name_template: "{{.Os}}_{{.Arch}}"

release:
footer: >-
Expand Down
2 changes: 1 addition & 1 deletion cli/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func Execute() {
This command can be used to run common tasks related to managing codesphere installations,
like downloading new versions.`),
}
AddInstallCmd(rootCmd)
AddVersionCmd(rootCmd)
AddListCmd(rootCmd, opts)
AddDownloadCmd(rootCmd, opts)

Expand Down
35 changes: 35 additions & 0 deletions cli/cmd/version.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
Copyright © 2025 NAME HERE <EMAIL ADDRESS>
*/
package cmd

import (
"fmt"

"github.com/codesphere-cloud/oms/internal/version"
"github.com/spf13/cobra"
)

type VersionCmd struct {
cmd *cobra.Command
}

func (c *VersionCmd) RunE(_ *cobra.Command, args []string) error {
fmt.Printf("Codesphere CLI version: %s\n", version.Version())
fmt.Printf("Commit: %s\n", version.Commit())
fmt.Printf("Build Date: %s\n", version.BuildDate())

return nil
}

func AddVersionCmd(rootCmd *cobra.Command) {
version := VersionCmd{
cmd: &cobra.Command{
Use: "version",
Short: "Print version",
Long: `Print current version of OMS.`,
},
}
rootCmd.AddCommand(version.cmd)
version.cmd.RunE = version.RunE
}
6 changes: 0 additions & 6 deletions hack/tag-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,6 @@ echo "Triggering release of version $NEWTAG"
go install github.com/goreleaser/goreleaser/v2@latest
goreleaser release --clean

cd dist
for ARCH in darwin_arm64 darwin_amd64 linux_amd64 linux_arm64; do
tar cf $ARCH.tar.gz *$ARCH*/* CHANGELOG.md
done
cd ..

echo "RELEASE_VERSION=$NEWTAG" >> $GITHUB_ENV

# Hash length fixed to 10 characters to get deterministic folder names
Expand Down
22 changes: 22 additions & 0 deletions internal/version/version.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package version

// Variables are injected by goreleaser on release
var (
version string = "dev"
commit string = "none"
date string = "unknown"
)

type Build struct{}

func Version() string {
return version
}

func Commit() string {
return commit
}

func BuildDate() string {
return date
}