Skip to content

Commit 94f9268

Browse files
authored
feat(version, licenses): Add version and licenses commands (#28)
* feat(version): Add version command * Version variables are injected by goreleaser on release Signed-off-by: Manuel Dewald <manuel@codesphere.com> * Add licenses command and update licenses Signed-off-by: Manuel Dewald <manuel@codesphere.com> * update docs Signed-off-by: Manuel Dewald <manuel@codesphere.com> * ref(docs): Ensure consistent ordering of docs Signed-off-by: Manuel Dewald <manuel@codesphere.com> * devx(gh-action): Add GitHub action to update licenses and docs Signed-off-by: Manuel Dewald <manuel@codesphere.com> * add description to version command Signed-off-by: Manuel Dewald <manuel@codesphere.com> --------- Signed-off-by: Manuel Dewald <manuel@codesphere.com>
1 parent da36124 commit 94f9268

31 files changed

+590
-84
lines changed

.github/workflows/tag-release.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,28 @@ on:
66
- main
77

88
jobs:
9+
docs:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v4
13+
with:
14+
fetch-tags: true
15+
fetch-depth: 0
16+
17+
- name: Set up Go
18+
uses: actions/setup-go@v5
19+
with:
20+
go-version: '1.24'
21+
22+
- name: Update docs & licenses
23+
run: hack/update-docs.sh
24+
925
tag:
1026
runs-on: ubuntu-latest
1127
steps:
1228
- uses: actions/checkout@v4
1329
with:
30+
ref: ${{ github.ref }}
1431
fetch-tags: true
1532
fetch-depth: 0
1633

.goreleaser.yaml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,13 @@ builds:
1818
- amd64
1919
- arm64
2020
- arm
21-
main: ./cmd/cs
21+
main: ./cli
22+
binary: cs
23+
ldflags:
24+
- -s -w
25+
- -X github.com/codesphere-cloud/cs-go/pkg/cs.version={{.Version}}
26+
- -X github.com/codesphere-cloud/cs-go/pkg/cs.commit={{.Commit}}
27+
- -X github.com/codesphere-cloud/cs-go/pkg/cs.date={{.Date}}
2228

2329
changelog:
2430
sort: asc

.mockery.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ require-template-schema-exists: true
1414
template: testify
1515
template-schema: '{{.Template}}.schema.json'
1616
packages:
17-
github.com/codesphere-cloud/cs-go/cmd:
17+
github.com/codesphere-cloud/cs-go/cli/cmd:
1818
interfaces:
1919
Client:
2020
Env:

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ file or class name and description of purpose be included on the
188188
same "printed page" as the copyright notice for easier
189189
identification within third-party archives.
190190

191-
Copyright [yyyy] [name of copyright owner]
191+
Copyright 2025 Codesphere Inc.
192192

193193
Licensed under the Apache License, Version 2.0 (the "License");
194194
you may not use this file except in compliance with the License.

Makefile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,9 @@ endif
4646
${OPENAPI_DIR}/test
4747
make generate
4848

49-
49+
release-binaries:
50+
goreleaser release --verbose --skip=validate --skip=publish --clean
51+
5052
generate-api: generate-client format
5153

5254
.PHONY: docs
@@ -56,7 +58,7 @@ docs:
5658
go run -ldflags="-X 'github.com/codesphere-cloud/cs-go/pkg/out.binName=cs'" hack/gendocs/main.go
5759
cp docs/{cs,README}.md
5860

59-
generate-license:
61+
generate-license: generate
6062
go-licenses report --template .NOTICE.template ./... > NOTICE
6163
copywrite headers apply
6264

NOTICE

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,18 @@ Copyright (c) Codesphere Inc.
33

44
This project includes code licensed under the following terms:
55

6+
----------
7+
Module: github.com/codesphere-cloud/cs-go/pkg/tmpl
8+
Version: Unknown
9+
License: Apache-2.0
10+
License URL: https://github.com/codesphere-cloud/cs-go/blob/HEAD/pkg/tmpl/LICENSE
11+
12+
----------
13+
Module: github.com/cpuguy83/go-md2man/v2/md2man
14+
Version: v2.0.6
15+
License: MIT
16+
License URL: https://github.com/cpuguy83/go-md2man/blob/v2.0.6/LICENSE.md
17+
618
----------
719
Module: github.com/davecgh/go-spew/spew
820
Version: v1.1.1
@@ -33,6 +45,12 @@ Version: v0.4.7
3345
License: MIT
3446
License URL: https://github.com/rivo/uniseg/blob/v0.4.7/LICENSE.txt
3547

48+
----------
49+
Module: github.com/russross/blackfriday/v2
50+
Version: v2.1.0
51+
License: BSD-2-Clause
52+
License URL: https://github.com/russross/blackfriday/blob/v2.1.0/LICENSE.txt
53+
3654
----------
3755
Module: github.com/spf13/cobra
3856
Version: v1.9.1

cli/cmd/licenses.go

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/*
2+
Copyright © 2025 NAME HERE <EMAIL ADDRESS>
3+
*/
4+
package cmd
5+
6+
import (
7+
_ "embed"
8+
"fmt"
9+
10+
"github.com/codesphere-cloud/cs-go/pkg/tmpl"
11+
"github.com/spf13/cobra"
12+
)
13+
14+
// LicensesCmd represents the licenses command
15+
type LicensesCmd struct {
16+
cmd *cobra.Command
17+
}
18+
19+
func (c *LicensesCmd) RunE(_ *cobra.Command, args []string) error {
20+
fmt.Println("Codesphere CLI License:")
21+
fmt.Println(tmpl.License())
22+
23+
fmt.Println("=================================")
24+
25+
fmt.Println("Codesphere CLI licenses included work:")
26+
fmt.Println(tmpl.Notice())
27+
28+
return nil
29+
}
30+
31+
func AddLicensesCmd(rootCmd *cobra.Command) {
32+
licenses := LicensesCmd{
33+
cmd: &cobra.Command{
34+
Use: "licenses",
35+
Short: "Print license information",
36+
Long: `Print information about the Codesphere CLI license and open source licenses of dependencies.`,
37+
},
38+
}
39+
rootCmd.AddCommand(licenses.cmd)
40+
licenses.cmd.RunE = licenses.RunE
41+
}

cli/cmd/list-teams.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ func addListTeamsCmd(p *cobra.Command, opts GlobalOptions) {
2424
Use: "teams",
2525
Short: "list teams",
2626
Long: `list teams available in Codesphere`,
27-
Example: out.FormatExampleCommands("list teams", map[string]string{
28-
"": "List all teams",
27+
Example: out.FormatExampleCommands("list teams", []out.Example{
28+
{Desc: "List all teams"},
2929
}),
3030
},
3131
opts: opts,

cli/cmd/list-workspaces.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ func addListWorkspacesCmd(p *cobra.Command, opts GlobalOptions) {
2424
Use: "workspaces",
2525
Short: "list workspaces",
2626
Long: `list workspaces available in Codesphere`,
27-
Example: out.FormatExampleCommands("list workspaces", map[string]string{
28-
"--team-id <team-id>": "List all workspaces",
27+
Example: out.FormatExampleCommands("list workspaces", []out.Example{
28+
{Cmd: "--team-id <team-id>", Desc: "List all workspaces"},
2929
}),
3030
},
3131
Opts: opts,

cli/cmd/list.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@ type ListCmd struct {
1212
cmd *cobra.Command
1313
}
1414

15-
func addListCmd(rootCmd *cobra.Command, opts GlobalOptions) {
15+
func AddListCmd(rootCmd *cobra.Command, opts GlobalOptions) {
1616
l := ListCmd{
1717
cmd: &cobra.Command{
1818
Use: "list",
1919
Short: "list resources",
2020
Long: `list resources available in Codesphere`,
21-
Example: out.FormatExampleCommands("list", map[string]string{
22-
"workspaces": "List all workspaces",
21+
Example: out.FormatExampleCommands("list", []out.Example{
22+
{Cmd: "workspaces", Desc: "List all workspaces"},
2323
}),
2424
},
2525
}

0 commit comments

Comments
 (0)