Skip to content

Commit 88bf677

Browse files
committed
chore(ci): Split build to allow for CLI only build
Signed-off-by: spbsoluble <1661003+spbsoluble@users.noreply.github.com>
1 parent ed6eaee commit 88bf677

4 files changed

Lines changed: 125 additions & 11 deletions

File tree

.goreleaser.yml

Lines changed: 52 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,29 +5,73 @@ before:
55
# this is just an example and not a requirement for provider building/publishing
66
- go mod tidy
77
builds:
8-
- env:
9-
# goreleaser does not work with CGO, it could also complicate
10-
# usage by users in CI/CD systems like Terraform Cloud where
11-
# they are unable to install libraries.
12-
- CGO_ENABLED=1
8+
# CLI-only build (no GUI, no CGO required) - builds for all platforms
9+
- id: kfutil-cli
10+
env:
11+
- CGO_ENABLED=0
1312
mod_timestamp: '{{ .CommitTimestamp }}'
1413
flags:
1514
- '-trimpath'
1615
ldflags:
1716
- "-s -w -X 'kfutil/pkg/version.VERSION={{ .Version }}' -X 'kfutil/pkg/version.COMMIT={{ .Commit }}' -X 'kfutil/pkg/version.BUILD_DATE={{ .CommitTimestamp }}'"
1817
goos:
19-
# - freebsd
20-
# - windows
2118
- linux
2219
- darwin
20+
- windows
21+
- freebsd
2322
goarch:
2423
- amd64
2524
- arm
2625
- arm64
26+
- '386'
27+
ignore:
28+
- goos: darwin
29+
goarch: '386'
30+
- goos: darwin
31+
goarch: arm
32+
- goos: windows
33+
goarch: arm
34+
- goos: windows
35+
goarch: arm64
36+
- goos: freebsd
37+
goarch: arm64
2738
binary: 'kfutil'
39+
40+
# GUI-enabled build (requires CGO) - limited platforms
41+
# Note: Cross-compilation with CGO is complex; these builds may need
42+
# platform-specific CI runners or docker images
43+
- id: kfutil-gui
44+
env:
45+
- CGO_ENABLED=1
46+
tags:
47+
- gui
48+
mod_timestamp: '{{ .CommitTimestamp }}'
49+
flags:
50+
- '-trimpath'
51+
ldflags:
52+
- "-s -w -X 'kfutil/pkg/version.VERSION={{ .Version }}' -X 'kfutil/pkg/version.COMMIT={{ .Commit }}' -X 'kfutil/pkg/version.BUILD_DATE={{ .CommitTimestamp }}'"
53+
goos:
54+
- linux
55+
- darwin
56+
# - windows # Windows GUI builds need special handling for CGO
57+
goarch:
58+
- amd64
59+
- arm64
60+
ignore:
61+
- goos: linux
62+
goarch: arm64 # Linux ARM64 CGO cross-compile is complex
63+
binary: 'kfutil-gui'
2864
archives:
29-
- format: zip
65+
- id: cli-archive
66+
builds:
67+
- kfutil-cli
68+
format: zip
3069
name_template: '{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}'
70+
- id: gui-archive
71+
builds:
72+
- kfutil-gui
73+
format: zip
74+
name_template: '{{ .ProjectName }}-gui_{{ .Version }}_{{ .Os }}_{{ .Arch }}'
3175
checksum:
3276
extra_files:
3377
- glob: 'integration-manifest.json'

GNUmakefile

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,16 @@ TEMP_TOC_FILE := temp_toc.md
2020

2121
default: build
2222

23+
# Build CLI-only version (no GUI, no CGO required)
2324
build: fmt
24-
go install
25+
CGO_ENABLED=0 go install
26+
27+
# Build GUI-enabled version (requires CGO)
28+
build-gui: fmt
29+
CGO_ENABLED=1 go install -tags gui
30+
31+
# Build both versions locally
32+
build-all: build build-gui
2533

2634
release:
2735
mkdir -p ./bin/${BINARY}_${VERSION}_darwin_amd64
@@ -44,8 +52,19 @@ release:
4452
GOOS=windows GOARCH=386 go build -o ./bin/${BINARY}_${VERSION}_windows_386
4553
GOOS=windows GOARCH=amd64 go build -o ./bin/${BINARY}_${VERSION}_windows_amd64
4654

55+
# Install CLI-only version
4756
install: fmt
48-
go build -o ${BINARY}
57+
CGO_ENABLED=0 go build -o ${BINARY}
58+
rm -rf ${INSTALLDIR}/${BINARY}
59+
mkdir -p ${INSTALLDIR}
60+
chmod oug+x ${BINARY}
61+
cp ${BINARY} ${INSTALLDIR}
62+
mkdir -p ${HOME}/.local/bin || true
63+
mv ${BINARY} ${HOME}/.local/bin/${BINARY}
64+
65+
# Install GUI-enabled version
66+
install-gui: fmt
67+
CGO_ENABLED=1 go build -tags gui -o ${BINARY}
4968
rm -rf ${INSTALLDIR}/${BINARY}
5069
mkdir -p ${INSTALLDIR}
5170
chmod oug+x ${BINARY}
@@ -84,4 +103,4 @@ generate_toc:
84103
markdown-toc -i $(MARKDOWN_FILE) --skip 'Table of Contents'
85104

86105

87-
.PHONY: build prerelease release install test fmt vendor version setversion
106+
.PHONY: build build-gui build-all prerelease release install install-gui test fmt vendor version setversion

cmd/gui.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//go:build gui
2+
13
// Copyright 2026 Keyfactor
24
//
35
// Licensed under the Apache License, Version 2.0 (the "License");

cmd/gui_stub.go

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
//go:build !gui
2+
3+
// Copyright 2026 Keyfactor
4+
//
5+
// Licensed under the Apache License, Version 2.0 (the "License");
6+
// you may not use this file except in compliance with the License.
7+
// You may obtain a copy of the License at
8+
//
9+
// http://www.apache.org/licenses/LICENSE-2.0
10+
//
11+
// Unless required by applicable law or agreed to in writing, software
12+
// distributed under the License is distributed on an "AS IS" BASIS,
13+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
// See the License for the specific language governing permissions and
15+
// limitations under the License.
16+
17+
package cmd
18+
19+
import (
20+
"fmt"
21+
22+
"github.com/spf13/cobra"
23+
)
24+
25+
// guiCmd represents the gui command (stub for CLI-only builds)
26+
var guiCmd = &cobra.Command{
27+
Use: "gui",
28+
Short: "Launch the graphical user interface (not available in this build)",
29+
Long: `The GUI is not available in this build of kfutil.
30+
31+
To use the graphical user interface, you need to install the GUI-enabled version:
32+
- Download 'kfutil-gui' from the releases page
33+
- Or build from source with: go build -tags gui
34+
35+
The GUI provides a visual interface for:
36+
- Configuring authentication to Keyfactor Command
37+
- Viewing and managing installed store types
38+
- Browsing and deploying store types from the internal catalog
39+
- Importing and exporting store type configurations
40+
`,
41+
RunE: func(cmd *cobra.Command, args []string) error {
42+
cmd.SilenceUsage = true
43+
return fmt.Errorf("GUI is not available in this build. Install 'kfutil-gui' or build with '-tags gui'")
44+
},
45+
}
46+
47+
func init() {
48+
RootCmd.AddCommand(guiCmd)
49+
}

0 commit comments

Comments
 (0)