feat: extract build/, release/, sdk/ from go-devops
Build system (8 builders, signing, archiving), release pipeline
(7 publishers, versioning, changelog), and SDK generation
(OpenAPI diff, code gen). 18K LOC, all tests pass except Go
builder workspace isolation (pre-existing).
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-09 12:37:36 +00:00
|
|
|
// cmd_project.go implements the main project build logic.
|
|
|
|
|
//
|
2026-04-01 11:10:27 +00:00
|
|
|
// This handles auto-detection of project types (Go, Wails, Node, PHP, Docs, Docker, LinuxKit, Taskfile)
|
feat: extract build/, release/, sdk/ from go-devops
Build system (8 builders, signing, archiving), release pipeline
(7 publishers, versioning, changelog), and SDK generation
(OpenAPI diff, code gen). 18K LOC, all tests pass except Go
builder workspace isolation (pre-existing).
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-09 12:37:36 +00:00
|
|
|
// and orchestrates the build process including signing, archiving, and checksums.
|
|
|
|
|
|
|
|
|
|
package buildcmd
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"context"
|
|
|
|
|
"runtime"
|
|
|
|
|
|
2026-03-26 17:41:53 +00:00
|
|
|
"dappco.re/go/core"
|
|
|
|
|
"dappco.re/go/core/build/internal/ax"
|
2026-04-01 09:46:42 +00:00
|
|
|
"dappco.re/go/core/build/internal/projectdetect"
|
2026-03-22 01:53:16 +00:00
|
|
|
"dappco.re/go/core/build/pkg/build"
|
|
|
|
|
"dappco.re/go/core/build/pkg/build/builders"
|
|
|
|
|
"dappco.re/go/core/build/pkg/build/signing"
|
2026-04-01 15:17:41 +00:00
|
|
|
"dappco.re/go/core/build/pkg/release"
|
2026-03-22 01:53:16 +00:00
|
|
|
"dappco.re/go/core/i18n"
|
|
|
|
|
"dappco.re/go/core/io"
|
|
|
|
|
coreerr "dappco.re/go/core/log"
|
2026-03-26 17:41:53 +00:00
|
|
|
"forge.lthn.ai/core/cli/pkg/cli"
|
feat: extract build/, release/, sdk/ from go-devops
Build system (8 builders, signing, archiving), release pipeline
(7 publishers, versioning, changelog), and SDK generation
(OpenAPI diff, code gen). 18K LOC, all tests pass except Go
builder workspace isolation (pre-existing).
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-09 12:37:36 +00:00
|
|
|
)
|
|
|
|
|
|
2026-04-01 23:10:18 +00:00
|
|
|
// ProjectBuildRequest groups the inputs for the main `core build` command.
|
|
|
|
|
//
|
|
|
|
|
// req := ProjectBuildRequest{
|
|
|
|
|
// Context: cmd.Context(),
|
|
|
|
|
// BuildType: "go",
|
|
|
|
|
// TargetsFlag: "linux/amd64,linux/arm64",
|
|
|
|
|
// }
|
|
|
|
|
type ProjectBuildRequest struct {
|
|
|
|
|
Context context.Context
|
|
|
|
|
BuildType string
|
|
|
|
|
CIMode bool
|
|
|
|
|
TargetsFlag string
|
|
|
|
|
OutputDir string
|
|
|
|
|
ArchiveOutput bool
|
|
|
|
|
ChecksumOutput bool
|
|
|
|
|
ArchiveFormat string
|
|
|
|
|
ConfigPath string
|
|
|
|
|
Format string
|
|
|
|
|
Push bool
|
|
|
|
|
ImageName string
|
|
|
|
|
NoSign bool
|
|
|
|
|
Notarize bool
|
|
|
|
|
Verbose bool
|
|
|
|
|
}
|
|
|
|
|
|
feat: extract build/, release/, sdk/ from go-devops
Build system (8 builders, signing, archiving), release pipeline
(7 publishers, versioning, changelog), and SDK generation
(OpenAPI diff, code gen). 18K LOC, all tests pass except Go
builder workspace isolation (pre-existing).
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-09 12:37:36 +00:00
|
|
|
// runProjectBuild handles the main `core build` command with auto-detection.
|
2026-04-01 23:10:18 +00:00
|
|
|
func runProjectBuild(req ProjectBuildRequest) error {
|
|
|
|
|
ctx := req.Context
|
|
|
|
|
if ctx == nil {
|
|
|
|
|
ctx = context.Background()
|
|
|
|
|
}
|
2026-03-31 18:37:59 +00:00
|
|
|
// Use local filesystem as the default medium.
|
|
|
|
|
filesystem := io.Local
|
feat: extract build/, release/, sdk/ from go-devops
Build system (8 builders, signing, archiving), release pipeline
(7 publishers, versioning, changelog), and SDK generation
(OpenAPI diff, code gen). 18K LOC, all tests pass except Go
builder workspace isolation (pre-existing).
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-09 12:37:36 +00:00
|
|
|
|
|
|
|
|
// Get current working directory as project root
|
2026-03-26 17:41:53 +00:00
|
|
|
projectDir, err := ax.Getwd()
|
feat: extract build/, release/, sdk/ from go-devops
Build system (8 builders, signing, archiving), release pipeline
(7 publishers, versioning, changelog), and SDK generation
(OpenAPI diff, code gen). 18K LOC, all tests pass except Go
builder workspace isolation (pre-existing).
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-09 12:37:36 +00:00
|
|
|
if err != nil {
|
2026-03-16 21:03:21 +00:00
|
|
|
return coreerr.E("build.Run", "failed to get working directory", err)
|
feat: extract build/, release/, sdk/ from go-devops
Build system (8 builders, signing, archiving), release pipeline
(7 publishers, versioning, changelog), and SDK generation
(OpenAPI diff, code gen). 18K LOC, all tests pass except Go
builder workspace isolation (pre-existing).
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-09 12:37:36 +00:00
|
|
|
}
|
|
|
|
|
|
2026-04-01 17:49:22 +00:00
|
|
|
// PWA builds use the dedicated local web-app pipeline rather than the
|
|
|
|
|
// project-type builder registry.
|
2026-04-01 23:10:18 +00:00
|
|
|
if req.BuildType == "pwa" {
|
2026-04-01 17:49:22 +00:00
|
|
|
return runLocalPwaBuild(ctx, projectDir)
|
|
|
|
|
}
|
|
|
|
|
|
feat: extract build/, release/, sdk/ from go-devops
Build system (8 builders, signing, archiving), release pipeline
(7 publishers, versioning, changelog), and SDK generation
(OpenAPI diff, code gen). 18K LOC, all tests pass except Go
builder workspace isolation (pre-existing).
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-09 12:37:36 +00:00
|
|
|
// Load configuration from .core/build.yaml (or defaults)
|
2026-04-01 12:10:38 +00:00
|
|
|
var buildConfig *build.BuildConfig
|
2026-04-01 23:10:18 +00:00
|
|
|
configPath := req.ConfigPath
|
2026-04-01 12:10:38 +00:00
|
|
|
if configPath != "" {
|
|
|
|
|
if !ax.IsAbs(configPath) {
|
|
|
|
|
configPath = ax.Join(projectDir, configPath)
|
|
|
|
|
}
|
|
|
|
|
if !filesystem.Exists(configPath) {
|
|
|
|
|
return coreerr.E("build.Run", "build config not found: "+configPath, nil)
|
|
|
|
|
}
|
|
|
|
|
buildConfig, err = build.LoadConfigAtPath(filesystem, configPath)
|
|
|
|
|
} else {
|
|
|
|
|
buildConfig, err = build.LoadConfig(filesystem, projectDir)
|
feat: extract build/, release/, sdk/ from go-devops
Build system (8 builders, signing, archiving), release pipeline
(7 publishers, versioning, changelog), and SDK generation
(OpenAPI diff, code gen). 18K LOC, all tests pass except Go
builder workspace isolation (pre-existing).
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-09 12:37:36 +00:00
|
|
|
}
|
2026-04-01 11:38:35 +00:00
|
|
|
if err != nil {
|
2026-04-01 12:10:38 +00:00
|
|
|
return coreerr.E("build.Run", "failed to load config", err)
|
2026-04-01 11:38:35 +00:00
|
|
|
}
|
|
|
|
|
|
2026-04-01 17:49:22 +00:00
|
|
|
if buildConfig.Build.Type == "pwa" {
|
|
|
|
|
return runLocalPwaBuild(ctx, projectDir)
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-01 12:24:03 +00:00
|
|
|
if err := build.SetupBuildCache(filesystem, projectDir, buildConfig); err != nil {
|
|
|
|
|
return coreerr.E("build.Run", "failed to set up build cache", err)
|
|
|
|
|
}
|
|
|
|
|
|
feat: extract build/, release/, sdk/ from go-devops
Build system (8 builders, signing, archiving), release pipeline
(7 publishers, versioning, changelog), and SDK generation
(OpenAPI diff, code gen). 18K LOC, all tests pass except Go
builder workspace isolation (pre-existing).
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-09 12:37:36 +00:00
|
|
|
// Detect project type if not specified
|
|
|
|
|
var projectType build.ProjectType
|
2026-04-01 23:10:18 +00:00
|
|
|
if req.BuildType != "" {
|
|
|
|
|
projectType = build.ProjectType(req.BuildType)
|
2026-03-31 18:37:59 +00:00
|
|
|
} else if buildConfig.Build.Type != "" {
|
2026-03-13 09:30:02 +00:00
|
|
|
// Use type from .core/build.yaml
|
2026-03-31 18:37:59 +00:00
|
|
|
projectType = build.ProjectType(buildConfig.Build.Type)
|
feat: extract build/, release/, sdk/ from go-devops
Build system (8 builders, signing, archiving), release pipeline
(7 publishers, versioning, changelog), and SDK generation
(OpenAPI diff, code gen). 18K LOC, all tests pass except Go
builder workspace isolation (pre-existing).
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-09 12:37:36 +00:00
|
|
|
} else {
|
2026-04-01 09:46:42 +00:00
|
|
|
projectType, err = projectdetect.DetectProjectType(filesystem, projectDir)
|
feat: extract build/, release/, sdk/ from go-devops
Build system (8 builders, signing, archiving), release pipeline
(7 publishers, versioning, changelog), and SDK generation
(OpenAPI diff, code gen). 18K LOC, all tests pass except Go
builder workspace isolation (pre-existing).
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-09 12:37:36 +00:00
|
|
|
if err != nil {
|
2026-03-16 21:03:21 +00:00
|
|
|
return coreerr.E("build.Run", "failed to detect project type", err)
|
feat: extract build/, release/, sdk/ from go-devops
Build system (8 builders, signing, archiving), release pipeline
(7 publishers, versioning, changelog), and SDK generation
(OpenAPI diff, code gen). 18K LOC, all tests pass except Go
builder workspace isolation (pre-existing).
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-09 12:37:36 +00:00
|
|
|
}
|
|
|
|
|
if projectType == "" {
|
2026-03-16 21:03:21 +00:00
|
|
|
return coreerr.E("build.Run", "no buildable project type found in "+projectDir, nil)
|
feat: extract build/, release/, sdk/ from go-devops
Build system (8 builders, signing, archiving), release pipeline
(7 publishers, versioning, changelog), and SDK generation
(OpenAPI diff, code gen). 18K LOC, all tests pass except Go
builder workspace isolation (pre-existing).
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-09 12:37:36 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Determine targets
|
|
|
|
|
var buildTargets []build.Target
|
2026-04-01 23:10:18 +00:00
|
|
|
if req.TargetsFlag != "" {
|
feat: extract build/, release/, sdk/ from go-devops
Build system (8 builders, signing, archiving), release pipeline
(7 publishers, versioning, changelog), and SDK generation
(OpenAPI diff, code gen). 18K LOC, all tests pass except Go
builder workspace isolation (pre-existing).
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-09 12:37:36 +00:00
|
|
|
// Parse from command line
|
2026-04-01 23:10:18 +00:00
|
|
|
buildTargets, err = parseTargets(req.TargetsFlag)
|
feat: extract build/, release/, sdk/ from go-devops
Build system (8 builders, signing, archiving), release pipeline
(7 publishers, versioning, changelog), and SDK generation
(OpenAPI diff, code gen). 18K LOC, all tests pass except Go
builder workspace isolation (pre-existing).
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-09 12:37:36 +00:00
|
|
|
if err != nil {
|
|
|
|
|
return err
|
|
|
|
|
}
|
2026-03-31 18:37:59 +00:00
|
|
|
} else if len(buildConfig.Targets) > 0 {
|
feat: extract build/, release/, sdk/ from go-devops
Build system (8 builders, signing, archiving), release pipeline
(7 publishers, versioning, changelog), and SDK generation
(OpenAPI diff, code gen). 18K LOC, all tests pass except Go
builder workspace isolation (pre-existing).
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-09 12:37:36 +00:00
|
|
|
// Use config targets
|
2026-03-31 18:37:59 +00:00
|
|
|
buildTargets = buildConfig.ToTargets()
|
feat: extract build/, release/, sdk/ from go-devops
Build system (8 builders, signing, archiving), release pipeline
(7 publishers, versioning, changelog), and SDK generation
(OpenAPI diff, code gen). 18K LOC, all tests pass except Go
builder workspace isolation (pre-existing).
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-09 12:37:36 +00:00
|
|
|
} else {
|
|
|
|
|
// Fall back to current OS/arch
|
|
|
|
|
buildTargets = []build.Target{
|
|
|
|
|
{OS: runtime.GOOS, Arch: runtime.GOARCH},
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Determine output directory
|
2026-04-01 23:10:18 +00:00
|
|
|
outputDir := req.OutputDir
|
feat: extract build/, release/, sdk/ from go-devops
Build system (8 builders, signing, archiving), release pipeline
(7 publishers, versioning, changelog), and SDK generation
(OpenAPI diff, code gen). 18K LOC, all tests pass except Go
builder workspace isolation (pre-existing).
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-09 12:37:36 +00:00
|
|
|
if outputDir == "" {
|
|
|
|
|
outputDir = "dist"
|
|
|
|
|
}
|
2026-03-26 17:41:53 +00:00
|
|
|
if !ax.IsAbs(outputDir) {
|
|
|
|
|
outputDir = ax.Join(projectDir, outputDir)
|
feat: extract build/, release/, sdk/ from go-devops
Build system (8 builders, signing, archiving), release pipeline
(7 publishers, versioning, changelog), and SDK generation
(OpenAPI diff, code gen). 18K LOC, all tests pass except Go
builder workspace isolation (pre-existing).
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-09 12:37:36 +00:00
|
|
|
}
|
2026-03-26 17:41:53 +00:00
|
|
|
outputDir = ax.Clean(outputDir)
|
feat: extract build/, release/, sdk/ from go-devops
Build system (8 builders, signing, archiving), release pipeline
(7 publishers, versioning, changelog), and SDK generation
(OpenAPI diff, code gen). 18K LOC, all tests pass except Go
builder workspace isolation (pre-existing).
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-09 12:37:36 +00:00
|
|
|
|
|
|
|
|
// Determine binary name
|
2026-03-31 18:37:59 +00:00
|
|
|
binaryName := buildConfig.Project.Binary
|
feat: extract build/, release/, sdk/ from go-devops
Build system (8 builders, signing, archiving), release pipeline
(7 publishers, versioning, changelog), and SDK generation
(OpenAPI diff, code gen). 18K LOC, all tests pass except Go
builder workspace isolation (pre-existing).
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-09 12:37:36 +00:00
|
|
|
if binaryName == "" {
|
2026-03-31 18:37:59 +00:00
|
|
|
binaryName = buildConfig.Project.Name
|
feat: extract build/, release/, sdk/ from go-devops
Build system (8 builders, signing, archiving), release pipeline
(7 publishers, versioning, changelog), and SDK generation
(OpenAPI diff, code gen). 18K LOC, all tests pass except Go
builder workspace isolation (pre-existing).
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-09 12:37:36 +00:00
|
|
|
}
|
|
|
|
|
if binaryName == "" {
|
2026-03-26 17:41:53 +00:00
|
|
|
binaryName = ax.Base(projectDir)
|
feat: extract build/, release/, sdk/ from go-devops
Build system (8 builders, signing, archiving), release pipeline
(7 publishers, versioning, changelog), and SDK generation
(OpenAPI diff, code gen). 18K LOC, all tests pass except Go
builder workspace isolation (pre-existing).
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-09 12:37:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Print build info (verbose mode only)
|
2026-04-01 23:10:18 +00:00
|
|
|
if req.Verbose && !req.CIMode {
|
2026-03-26 17:41:53 +00:00
|
|
|
cli.Print("%s %s\n", buildHeaderStyle.Render(i18n.T("cmd.build.label.build")), i18n.T("cmd.build.building_project"))
|
|
|
|
|
cli.Print(" %s %s\n", i18n.T("cmd.build.label.type"), buildTargetStyle.Render(string(projectType)))
|
|
|
|
|
cli.Print(" %s %s\n", i18n.T("cmd.build.label.output"), buildTargetStyle.Render(outputDir))
|
|
|
|
|
cli.Print(" %s %s\n", i18n.T("cmd.build.label.binary"), buildTargetStyle.Render(binaryName))
|
|
|
|
|
cli.Print(" %s %s\n", i18n.T("cmd.build.label.targets"), buildTargetStyle.Render(formatTargets(buildTargets)))
|
|
|
|
|
cli.Blank()
|
feat: extract build/, release/, sdk/ from go-devops
Build system (8 builders, signing, archiving), release pipeline
(7 publishers, versioning, changelog), and SDK generation
(OpenAPI diff, code gen). 18K LOC, all tests pass except Go
builder workspace isolation (pre-existing).
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-09 12:37:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Get the appropriate builder
|
|
|
|
|
builder, err := getBuilder(projectType)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Create build config for the builder
|
2026-04-01 15:17:41 +00:00
|
|
|
version, err := resolveBuildVersion(ctx, projectDir)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return coreerr.E("build.Run", "failed to determine build version", err)
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-01 23:10:18 +00:00
|
|
|
cfg := buildRuntimeConfig(filesystem, projectDir, outputDir, binaryName, buildConfig, req.Push, req.ImageName, version)
|
2026-04-01 12:10:38 +00:00
|
|
|
discovery, err := build.DiscoverFull(filesystem, projectDir)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return coreerr.E("build.Run", "failed to inspect project for build options", err)
|
feat: extract build/, release/, sdk/ from go-devops
Build system (8 builders, signing, archiving), release pipeline
(7 publishers, versioning, changelog), and SDK generation
(OpenAPI diff, code gen). 18K LOC, all tests pass except Go
builder workspace isolation (pre-existing).
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-09 12:37:36 +00:00
|
|
|
}
|
2026-04-01 11:38:35 +00:00
|
|
|
build.ApplyOptions(cfg, build.ComputeOptions(buildConfig, discovery))
|
feat: extract build/, release/, sdk/ from go-devops
Build system (8 builders, signing, archiving), release pipeline
(7 publishers, versioning, changelog), and SDK generation
(OpenAPI diff, code gen). 18K LOC, all tests pass except Go
builder workspace isolation (pre-existing).
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-09 12:37:36 +00:00
|
|
|
|
|
|
|
|
// Parse formats for LinuxKit
|
2026-04-01 23:10:18 +00:00
|
|
|
if req.Format != "" {
|
|
|
|
|
cfg.Formats = core.Split(req.Format, ",")
|
feat: extract build/, release/, sdk/ from go-devops
Build system (8 builders, signing, archiving), release pipeline
(7 publishers, versioning, changelog), and SDK generation
(OpenAPI diff, code gen). 18K LOC, all tests pass except Go
builder workspace isolation (pre-existing).
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-09 12:37:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Execute build
|
|
|
|
|
artifacts, err := builder.Build(ctx, cfg, buildTargets)
|
|
|
|
|
if err != nil {
|
2026-04-01 23:10:18 +00:00
|
|
|
if !req.CIMode {
|
2026-03-26 17:41:53 +00:00
|
|
|
cli.Print("%s %v\n", buildErrorStyle.Render(i18n.T("common.label.error")), err)
|
feat: extract build/, release/, sdk/ from go-devops
Build system (8 builders, signing, archiving), release pipeline
(7 publishers, versioning, changelog), and SDK generation
(OpenAPI diff, code gen). 18K LOC, all tests pass except Go
builder workspace isolation (pre-existing).
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-09 12:37:36 +00:00
|
|
|
}
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-01 23:10:18 +00:00
|
|
|
if req.Verbose && !req.CIMode {
|
2026-03-26 17:41:53 +00:00
|
|
|
cli.Print("%s %s\n", buildSuccessStyle.Render(i18n.T("common.label.success")), i18n.T("cmd.build.built_artifacts", map[string]any{"Count": len(artifacts)}))
|
|
|
|
|
cli.Blank()
|
feat: extract build/, release/, sdk/ from go-devops
Build system (8 builders, signing, archiving), release pipeline
(7 publishers, versioning, changelog), and SDK generation
(OpenAPI diff, code gen). 18K LOC, all tests pass except Go
builder workspace isolation (pre-existing).
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-09 12:37:36 +00:00
|
|
|
for _, artifact := range artifacts {
|
2026-03-26 17:41:53 +00:00
|
|
|
relPath, err := ax.Rel(projectDir, artifact.Path)
|
feat: extract build/, release/, sdk/ from go-devops
Build system (8 builders, signing, archiving), release pipeline
(7 publishers, versioning, changelog), and SDK generation
(OpenAPI diff, code gen). 18K LOC, all tests pass except Go
builder workspace isolation (pre-existing).
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-09 12:37:36 +00:00
|
|
|
if err != nil {
|
|
|
|
|
relPath = artifact.Path
|
|
|
|
|
}
|
2026-03-26 17:41:53 +00:00
|
|
|
cli.Print(" %s %s %s\n",
|
feat: extract build/, release/, sdk/ from go-devops
Build system (8 builders, signing, archiving), release pipeline
(7 publishers, versioning, changelog), and SDK generation
(OpenAPI diff, code gen). 18K LOC, all tests pass except Go
builder workspace isolation (pre-existing).
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-09 12:37:36 +00:00
|
|
|
buildSuccessStyle.Render("*"),
|
|
|
|
|
buildTargetStyle.Render(relPath),
|
2026-03-26 17:41:53 +00:00
|
|
|
buildDimStyle.Render(core.Sprintf("(%s/%s)", artifact.OS, artifact.Arch)),
|
feat: extract build/, release/, sdk/ from go-devops
Build system (8 builders, signing, archiving), release pipeline
(7 publishers, versioning, changelog), and SDK generation
(OpenAPI diff, code gen). 18K LOC, all tests pass except Go
builder workspace isolation (pre-existing).
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-09 12:37:36 +00:00
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-01 10:53:02 +00:00
|
|
|
// Sign binaries if enabled.
|
2026-03-31 18:37:59 +00:00
|
|
|
signCfg := buildConfig.Sign
|
2026-04-01 23:10:18 +00:00
|
|
|
if req.Notarize {
|
feat: extract build/, release/, sdk/ from go-devops
Build system (8 builders, signing, archiving), release pipeline
(7 publishers, versioning, changelog), and SDK generation
(OpenAPI diff, code gen). 18K LOC, all tests pass except Go
builder workspace isolation (pre-existing).
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-09 12:37:36 +00:00
|
|
|
signCfg.MacOS.Notarize = true
|
|
|
|
|
}
|
2026-04-01 23:10:18 +00:00
|
|
|
if req.NoSign {
|
feat: extract build/, release/, sdk/ from go-devops
Build system (8 builders, signing, archiving), release pipeline
(7 publishers, versioning, changelog), and SDK generation
(OpenAPI diff, code gen). 18K LOC, all tests pass except Go
builder workspace isolation (pre-existing).
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-09 12:37:36 +00:00
|
|
|
signCfg.Enabled = false
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-01 10:53:02 +00:00
|
|
|
if signCfg.Enabled && (runtime.GOOS == "darwin" || runtime.GOOS == "windows") {
|
2026-04-01 23:10:18 +00:00
|
|
|
if req.Verbose && !req.CIMode {
|
2026-03-26 17:41:53 +00:00
|
|
|
cli.Blank()
|
|
|
|
|
cli.Print("%s %s\n", buildHeaderStyle.Render(i18n.T("cmd.build.label.sign")), i18n.T("cmd.build.signing_binaries"))
|
feat: extract build/, release/, sdk/ from go-devops
Build system (8 builders, signing, archiving), release pipeline
(7 publishers, versioning, changelog), and SDK generation
(OpenAPI diff, code gen). 18K LOC, all tests pass except Go
builder workspace isolation (pre-existing).
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-09 12:37:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Convert build.Artifact to signing.Artifact
|
|
|
|
|
signingArtifacts := make([]signing.Artifact, len(artifacts))
|
|
|
|
|
for i, a := range artifacts {
|
|
|
|
|
signingArtifacts[i] = signing.Artifact{Path: a.Path, OS: a.OS, Arch: a.Arch}
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-31 18:37:59 +00:00
|
|
|
if err := signing.SignBinaries(ctx, filesystem, signCfg, signingArtifacts); err != nil {
|
2026-04-01 23:10:18 +00:00
|
|
|
if !req.CIMode {
|
2026-03-26 17:41:53 +00:00
|
|
|
cli.Print("%s %s: %v\n", buildErrorStyle.Render(i18n.T("common.label.error")), i18n.T("cmd.build.error.signing_failed"), err)
|
feat: extract build/, release/, sdk/ from go-devops
Build system (8 builders, signing, archiving), release pipeline
(7 publishers, versioning, changelog), and SDK generation
(OpenAPI diff, code gen). 18K LOC, all tests pass except Go
builder workspace isolation (pre-existing).
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-09 12:37:36 +00:00
|
|
|
}
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-01 10:53:02 +00:00
|
|
|
if runtime.GOOS == "darwin" && signCfg.MacOS.Notarize {
|
2026-03-31 18:37:59 +00:00
|
|
|
if err := signing.NotarizeBinaries(ctx, filesystem, signCfg, signingArtifacts); err != nil {
|
2026-04-01 23:10:18 +00:00
|
|
|
if !req.CIMode {
|
2026-03-26 17:41:53 +00:00
|
|
|
cli.Print("%s %s: %v\n", buildErrorStyle.Render(i18n.T("common.label.error")), i18n.T("cmd.build.error.notarization_failed"), err)
|
feat: extract build/, release/, sdk/ from go-devops
Build system (8 builders, signing, archiving), release pipeline
(7 publishers, versioning, changelog), and SDK generation
(OpenAPI diff, code gen). 18K LOC, all tests pass except Go
builder workspace isolation (pre-existing).
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-09 12:37:36 +00:00
|
|
|
}
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Archive artifacts if enabled
|
|
|
|
|
var archivedArtifacts []build.Artifact
|
2026-04-01 23:10:18 +00:00
|
|
|
if req.ArchiveOutput && len(artifacts) > 0 {
|
|
|
|
|
if req.Verbose && !req.CIMode {
|
2026-03-26 17:41:53 +00:00
|
|
|
cli.Blank()
|
|
|
|
|
cli.Print("%s %s\n", buildHeaderStyle.Render(i18n.T("cmd.build.label.archive")), i18n.T("cmd.build.creating_archives"))
|
feat: extract build/, release/, sdk/ from go-devops
Build system (8 builders, signing, archiving), release pipeline
(7 publishers, versioning, changelog), and SDK generation
(OpenAPI diff, code gen). 18K LOC, all tests pass except Go
builder workspace isolation (pre-existing).
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-09 12:37:36 +00:00
|
|
|
}
|
|
|
|
|
|
2026-04-01 23:10:18 +00:00
|
|
|
archiveFormatValue, err := resolveArchiveFormat(buildConfig.Build.ArchiveFormat, req.ArchiveFormat)
|
2026-04-01 13:58:56 +00:00
|
|
|
if err != nil {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-01 20:06:42 +00:00
|
|
|
archivedArtifacts, err = build.ArchiveAllWithFormat(filesystem, artifacts, archiveFormatValue)
|
feat: extract build/, release/, sdk/ from go-devops
Build system (8 builders, signing, archiving), release pipeline
(7 publishers, versioning, changelog), and SDK generation
(OpenAPI diff, code gen). 18K LOC, all tests pass except Go
builder workspace isolation (pre-existing).
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-09 12:37:36 +00:00
|
|
|
if err != nil {
|
2026-04-01 23:10:18 +00:00
|
|
|
if !req.CIMode {
|
2026-03-26 17:41:53 +00:00
|
|
|
cli.Print("%s %s: %v\n", buildErrorStyle.Render(i18n.T("common.label.error")), i18n.T("cmd.build.error.archive_failed"), err)
|
feat: extract build/, release/, sdk/ from go-devops
Build system (8 builders, signing, archiving), release pipeline
(7 publishers, versioning, changelog), and SDK generation
(OpenAPI diff, code gen). 18K LOC, all tests pass except Go
builder workspace isolation (pre-existing).
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-09 12:37:36 +00:00
|
|
|
}
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-01 23:10:18 +00:00
|
|
|
if req.Verbose && !req.CIMode {
|
feat: extract build/, release/, sdk/ from go-devops
Build system (8 builders, signing, archiving), release pipeline
(7 publishers, versioning, changelog), and SDK generation
(OpenAPI diff, code gen). 18K LOC, all tests pass except Go
builder workspace isolation (pre-existing).
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-09 12:37:36 +00:00
|
|
|
for _, artifact := range archivedArtifacts {
|
2026-03-26 17:41:53 +00:00
|
|
|
relPath, err := ax.Rel(projectDir, artifact.Path)
|
feat: extract build/, release/, sdk/ from go-devops
Build system (8 builders, signing, archiving), release pipeline
(7 publishers, versioning, changelog), and SDK generation
(OpenAPI diff, code gen). 18K LOC, all tests pass except Go
builder workspace isolation (pre-existing).
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-09 12:37:36 +00:00
|
|
|
if err != nil {
|
|
|
|
|
relPath = artifact.Path
|
|
|
|
|
}
|
2026-03-26 17:41:53 +00:00
|
|
|
cli.Print(" %s %s %s\n",
|
feat: extract build/, release/, sdk/ from go-devops
Build system (8 builders, signing, archiving), release pipeline
(7 publishers, versioning, changelog), and SDK generation
(OpenAPI diff, code gen). 18K LOC, all tests pass except Go
builder workspace isolation (pre-existing).
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-09 12:37:36 +00:00
|
|
|
buildSuccessStyle.Render("*"),
|
|
|
|
|
buildTargetStyle.Render(relPath),
|
2026-03-26 17:41:53 +00:00
|
|
|
buildDimStyle.Render(core.Sprintf("(%s/%s)", artifact.OS, artifact.Arch)),
|
feat: extract build/, release/, sdk/ from go-devops
Build system (8 builders, signing, archiving), release pipeline
(7 publishers, versioning, changelog), and SDK generation
(OpenAPI diff, code gen). 18K LOC, all tests pass except Go
builder workspace isolation (pre-existing).
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-09 12:37:36 +00:00
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Compute checksums if enabled
|
|
|
|
|
var checksummedArtifacts []build.Artifact
|
2026-04-01 23:10:18 +00:00
|
|
|
if req.ChecksumOutput && len(archivedArtifacts) > 0 {
|
|
|
|
|
checksummedArtifacts, err = computeAndWriteChecksums(ctx, filesystem, projectDir, outputDir, archivedArtifacts, signCfg, req.CIMode, req.Verbose)
|
feat: extract build/, release/, sdk/ from go-devops
Build system (8 builders, signing, archiving), release pipeline
(7 publishers, versioning, changelog), and SDK generation
(OpenAPI diff, code gen). 18K LOC, all tests pass except Go
builder workspace isolation (pre-existing).
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-09 12:37:36 +00:00
|
|
|
if err != nil {
|
|
|
|
|
return err
|
|
|
|
|
}
|
2026-04-01 23:10:18 +00:00
|
|
|
} else if req.ChecksumOutput && len(artifacts) > 0 && !req.ArchiveOutput {
|
feat: extract build/, release/, sdk/ from go-devops
Build system (8 builders, signing, archiving), release pipeline
(7 publishers, versioning, changelog), and SDK generation
(OpenAPI diff, code gen). 18K LOC, all tests pass except Go
builder workspace isolation (pre-existing).
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-09 12:37:36 +00:00
|
|
|
// Checksum raw binaries if archiving is disabled
|
2026-04-01 23:10:18 +00:00
|
|
|
checksummedArtifacts, err = computeAndWriteChecksums(ctx, filesystem, projectDir, outputDir, artifacts, signCfg, req.CIMode, req.Verbose)
|
feat: extract build/, release/, sdk/ from go-devops
Build system (8 builders, signing, archiving), release pipeline
(7 publishers, versioning, changelog), and SDK generation
(OpenAPI diff, code gen). 18K LOC, all tests pass except Go
builder workspace isolation (pre-existing).
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-09 12:37:36 +00:00
|
|
|
if err != nil {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Output results
|
2026-04-01 23:10:18 +00:00
|
|
|
if req.CIMode {
|
2026-04-01 15:47:32 +00:00
|
|
|
// Determine which artifacts to output (prefer checksummed > archived > raw).
|
|
|
|
|
outputArtifacts := selectOutputArtifacts(artifacts, archivedArtifacts, checksummedArtifacts)
|
|
|
|
|
if err := writeArtifactMetadata(filesystem, binaryName, outputArtifacts); err != nil {
|
|
|
|
|
return err
|
feat: extract build/, release/, sdk/ from go-devops
Build system (8 builders, signing, archiving), release pipeline
(7 publishers, versioning, changelog), and SDK generation
(OpenAPI diff, code gen). 18K LOC, all tests pass except Go
builder workspace isolation (pre-existing).
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-09 12:37:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// JSON output for CI
|
2026-03-26 17:41:53 +00:00
|
|
|
output, err := ax.JSONMarshal(outputArtifacts)
|
feat: extract build/, release/, sdk/ from go-devops
Build system (8 builders, signing, archiving), release pipeline
(7 publishers, versioning, changelog), and SDK generation
(OpenAPI diff, code gen). 18K LOC, all tests pass except Go
builder workspace isolation (pre-existing).
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-09 12:37:36 +00:00
|
|
|
if err != nil {
|
2026-03-16 21:03:21 +00:00
|
|
|
return coreerr.E("build.Run", "failed to marshal artifacts", err)
|
feat: extract build/, release/, sdk/ from go-devops
Build system (8 builders, signing, archiving), release pipeline
(7 publishers, versioning, changelog), and SDK generation
(OpenAPI diff, code gen). 18K LOC, all tests pass except Go
builder workspace isolation (pre-existing).
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-09 12:37:36 +00:00
|
|
|
}
|
2026-03-26 17:41:53 +00:00
|
|
|
cli.Print("%s\n", output)
|
2026-04-01 23:10:18 +00:00
|
|
|
} else if !req.Verbose {
|
feat: extract build/, release/, sdk/ from go-devops
Build system (8 builders, signing, archiving), release pipeline
(7 publishers, versioning, changelog), and SDK generation
(OpenAPI diff, code gen). 18K LOC, all tests pass except Go
builder workspace isolation (pre-existing).
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-09 12:37:36 +00:00
|
|
|
// Minimal output: just success with artifact count
|
2026-03-26 17:41:53 +00:00
|
|
|
cli.Print("%s %s %s\n",
|
feat: extract build/, release/, sdk/ from go-devops
Build system (8 builders, signing, archiving), release pipeline
(7 publishers, versioning, changelog), and SDK generation
(OpenAPI diff, code gen). 18K LOC, all tests pass except Go
builder workspace isolation (pre-existing).
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-09 12:37:36 +00:00
|
|
|
buildSuccessStyle.Render(i18n.T("common.label.success")),
|
|
|
|
|
i18n.T("cmd.build.built_artifacts", map[string]any{"Count": len(artifacts)}),
|
2026-03-26 17:41:53 +00:00
|
|
|
buildDimStyle.Render(core.Sprintf("(%s)", outputDir)),
|
feat: extract build/, release/, sdk/ from go-devops
Build system (8 builders, signing, archiving), release pipeline
(7 publishers, versioning, changelog), and SDK generation
(OpenAPI diff, code gen). 18K LOC, all tests pass except Go
builder workspace isolation (pre-existing).
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-09 12:37:36 +00:00
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-01 15:47:32 +00:00
|
|
|
// selectOutputArtifacts chooses the final artifact list for CI output.
|
|
|
|
|
//
|
|
|
|
|
// output := selectOutputArtifacts(rawArtifacts, archivedArtifacts, checksummedArtifacts)
|
|
|
|
|
func selectOutputArtifacts(rawArtifacts, archivedArtifacts, checksummedArtifacts []build.Artifact) []build.Artifact {
|
|
|
|
|
if len(checksummedArtifacts) > 0 {
|
|
|
|
|
return checksummedArtifacts
|
|
|
|
|
}
|
|
|
|
|
if len(archivedArtifacts) > 0 {
|
|
|
|
|
return archivedArtifacts
|
|
|
|
|
}
|
|
|
|
|
return rawArtifacts
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-01 13:37:31 +00:00
|
|
|
// writeArtifactMetadata writes artifact_meta.json files next to built artifacts when CI metadata is available.
|
|
|
|
|
func writeArtifactMetadata(filesystem io.Medium, buildName string, artifacts []build.Artifact) error {
|
|
|
|
|
ci := build.DetectCI()
|
2026-04-01 21:19:50 +00:00
|
|
|
if ci == nil {
|
|
|
|
|
ci = build.DetectGitHubMetadata()
|
|
|
|
|
}
|
2026-04-01 13:37:31 +00:00
|
|
|
if ci == nil {
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for _, artifact := range artifacts {
|
|
|
|
|
metaPath := ax.Join(ax.Dir(artifact.Path), "artifact_meta.json")
|
|
|
|
|
if err := build.WriteArtifactMeta(filesystem, metaPath, buildName, build.Target{OS: artifact.OS, Arch: artifact.Arch}, ci); err != nil {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-01 12:29:48 +00:00
|
|
|
// buildRuntimeConfig maps persisted build configuration onto the runtime builder config.
|
2026-04-01 15:17:41 +00:00
|
|
|
func buildRuntimeConfig(filesystem io.Medium, projectDir, outputDir, binaryName string, buildConfig *build.BuildConfig, push bool, imageName string, version string) *build.Config {
|
2026-04-01 12:29:48 +00:00
|
|
|
buildDefaults := buildConfig.Build
|
|
|
|
|
cfg := &build.Config{
|
|
|
|
|
FS: filesystem,
|
|
|
|
|
Project: buildConfig.Project,
|
|
|
|
|
ProjectDir: projectDir,
|
|
|
|
|
OutputDir: outputDir,
|
|
|
|
|
Name: binaryName,
|
2026-04-01 15:17:41 +00:00
|
|
|
Version: version,
|
2026-04-01 12:29:48 +00:00
|
|
|
LDFlags: append([]string{}, buildDefaults.LDFlags...),
|
|
|
|
|
Flags: append([]string{}, buildDefaults.Flags...),
|
2026-04-01 18:04:26 +00:00
|
|
|
BuildTags: append([]string{}, buildDefaults.BuildTags...),
|
2026-04-01 12:29:48 +00:00
|
|
|
Env: append([]string{}, buildDefaults.Env...),
|
2026-04-01 12:59:08 +00:00
|
|
|
Cache: buildDefaults.Cache,
|
2026-04-01 12:29:48 +00:00
|
|
|
CGO: buildDefaults.CGO,
|
|
|
|
|
Obfuscate: buildDefaults.Obfuscate,
|
|
|
|
|
NSIS: buildDefaults.NSIS,
|
|
|
|
|
WebView2: buildDefaults.WebView2,
|
|
|
|
|
Dockerfile: buildDefaults.Dockerfile,
|
|
|
|
|
Registry: buildDefaults.Registry,
|
|
|
|
|
Image: buildDefaults.Image,
|
|
|
|
|
Tags: append([]string{}, buildDefaults.Tags...),
|
2026-04-01 19:52:42 +00:00
|
|
|
BuildArgs: build.CloneStringMap(buildDefaults.BuildArgs),
|
2026-04-01 12:29:48 +00:00
|
|
|
Push: buildDefaults.Push || push,
|
2026-04-01 15:24:33 +00:00
|
|
|
Load: buildDefaults.Load,
|
2026-04-01 12:29:48 +00:00
|
|
|
LinuxKitConfig: buildDefaults.LinuxKitConfig,
|
|
|
|
|
Formats: append([]string{}, buildDefaults.Formats...),
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if imageName != "" {
|
|
|
|
|
cfg.Image = imageName
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return cfg
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-01 20:06:42 +00:00
|
|
|
// resolveArchiveFormat selects the archive format from CLI overrides or config defaults.
|
|
|
|
|
func resolveArchiveFormat(configFormat, cliFormat string) (build.ArchiveFormat, error) {
|
|
|
|
|
if cliFormat != "" {
|
|
|
|
|
return build.ParseArchiveFormat(cliFormat)
|
|
|
|
|
}
|
|
|
|
|
return build.ParseArchiveFormat(configFormat)
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-01 15:17:41 +00:00
|
|
|
// resolveBuildVersion determines the version string embedded into build artifacts.
|
|
|
|
|
//
|
|
|
|
|
// version, err := resolveBuildVersion(ctx, ".")
|
|
|
|
|
func resolveBuildVersion(ctx context.Context, projectDir string) (string, error) {
|
|
|
|
|
return release.DetermineVersionWithContext(ctx, projectDir)
|
|
|
|
|
}
|
|
|
|
|
|
feat: extract build/, release/, sdk/ from go-devops
Build system (8 builders, signing, archiving), release pipeline
(7 publishers, versioning, changelog), and SDK generation
(OpenAPI diff, code gen). 18K LOC, all tests pass except Go
builder workspace isolation (pre-existing).
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-09 12:37:36 +00:00
|
|
|
// computeAndWriteChecksums computes checksums for artifacts and writes CHECKSUMS.txt.
|
2026-03-31 18:37:59 +00:00
|
|
|
func computeAndWriteChecksums(ctx context.Context, filesystem io.Medium, projectDir, outputDir string, artifacts []build.Artifact, signCfg signing.SignConfig, ciMode bool, verbose bool) ([]build.Artifact, error) {
|
feat: extract build/, release/, sdk/ from go-devops
Build system (8 builders, signing, archiving), release pipeline
(7 publishers, versioning, changelog), and SDK generation
(OpenAPI diff, code gen). 18K LOC, all tests pass except Go
builder workspace isolation (pre-existing).
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-09 12:37:36 +00:00
|
|
|
if verbose && !ciMode {
|
2026-03-26 17:41:53 +00:00
|
|
|
cli.Blank()
|
|
|
|
|
cli.Print("%s %s\n", buildHeaderStyle.Render(i18n.T("cmd.build.label.checksum")), i18n.T("cmd.build.computing_checksums"))
|
feat: extract build/, release/, sdk/ from go-devops
Build system (8 builders, signing, archiving), release pipeline
(7 publishers, versioning, changelog), and SDK generation
(OpenAPI diff, code gen). 18K LOC, all tests pass except Go
builder workspace isolation (pre-existing).
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-09 12:37:36 +00:00
|
|
|
}
|
|
|
|
|
|
2026-03-31 18:37:59 +00:00
|
|
|
checksummedArtifacts, err := build.ChecksumAll(filesystem, artifacts)
|
feat: extract build/, release/, sdk/ from go-devops
Build system (8 builders, signing, archiving), release pipeline
(7 publishers, versioning, changelog), and SDK generation
(OpenAPI diff, code gen). 18K LOC, all tests pass except Go
builder workspace isolation (pre-existing).
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-09 12:37:36 +00:00
|
|
|
if err != nil {
|
|
|
|
|
if !ciMode {
|
2026-03-26 17:41:53 +00:00
|
|
|
cli.Print("%s %s: %v\n", buildErrorStyle.Render(i18n.T("common.label.error")), i18n.T("cmd.build.error.checksum_failed"), err)
|
feat: extract build/, release/, sdk/ from go-devops
Build system (8 builders, signing, archiving), release pipeline
(7 publishers, versioning, changelog), and SDK generation
(OpenAPI diff, code gen). 18K LOC, all tests pass except Go
builder workspace isolation (pre-existing).
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-09 12:37:36 +00:00
|
|
|
}
|
|
|
|
|
return nil, err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Write CHECKSUMS.txt
|
2026-03-26 17:41:53 +00:00
|
|
|
checksumPath := ax.Join(outputDir, "CHECKSUMS.txt")
|
2026-03-31 18:37:59 +00:00
|
|
|
if err := build.WriteChecksumFile(filesystem, checksummedArtifacts, checksumPath); err != nil {
|
feat: extract build/, release/, sdk/ from go-devops
Build system (8 builders, signing, archiving), release pipeline
(7 publishers, versioning, changelog), and SDK generation
(OpenAPI diff, code gen). 18K LOC, all tests pass except Go
builder workspace isolation (pre-existing).
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-09 12:37:36 +00:00
|
|
|
if !ciMode {
|
2026-03-26 17:41:53 +00:00
|
|
|
cli.Print("%s %s: %v\n", buildErrorStyle.Render(i18n.T("common.label.error")), i18n.T("common.error.failed", map[string]any{"Action": "write CHECKSUMS.txt"}), err)
|
feat: extract build/, release/, sdk/ from go-devops
Build system (8 builders, signing, archiving), release pipeline
(7 publishers, versioning, changelog), and SDK generation
(OpenAPI diff, code gen). 18K LOC, all tests pass except Go
builder workspace isolation (pre-existing).
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-09 12:37:36 +00:00
|
|
|
}
|
|
|
|
|
return nil, err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Sign checksums with GPG
|
|
|
|
|
if signCfg.Enabled {
|
2026-03-31 18:37:59 +00:00
|
|
|
if err := signing.SignChecksums(ctx, filesystem, signCfg, checksumPath); err != nil {
|
feat: extract build/, release/, sdk/ from go-devops
Build system (8 builders, signing, archiving), release pipeline
(7 publishers, versioning, changelog), and SDK generation
(OpenAPI diff, code gen). 18K LOC, all tests pass except Go
builder workspace isolation (pre-existing).
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-09 12:37:36 +00:00
|
|
|
if !ciMode {
|
2026-03-26 17:41:53 +00:00
|
|
|
cli.Print("%s %s: %v\n", buildErrorStyle.Render(i18n.T("common.label.error")), i18n.T("cmd.build.error.gpg_signing_failed"), err)
|
feat: extract build/, release/, sdk/ from go-devops
Build system (8 builders, signing, archiving), release pipeline
(7 publishers, versioning, changelog), and SDK generation
(OpenAPI diff, code gen). 18K LOC, all tests pass except Go
builder workspace isolation (pre-existing).
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-09 12:37:36 +00:00
|
|
|
}
|
|
|
|
|
return nil, err
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if verbose && !ciMode {
|
|
|
|
|
for _, artifact := range checksummedArtifacts {
|
2026-03-26 17:41:53 +00:00
|
|
|
relPath, err := ax.Rel(projectDir, artifact.Path)
|
feat: extract build/, release/, sdk/ from go-devops
Build system (8 builders, signing, archiving), release pipeline
(7 publishers, versioning, changelog), and SDK generation
(OpenAPI diff, code gen). 18K LOC, all tests pass except Go
builder workspace isolation (pre-existing).
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-09 12:37:36 +00:00
|
|
|
if err != nil {
|
|
|
|
|
relPath = artifact.Path
|
|
|
|
|
}
|
2026-03-26 17:41:53 +00:00
|
|
|
cli.Print(" %s %s\n",
|
feat: extract build/, release/, sdk/ from go-devops
Build system (8 builders, signing, archiving), release pipeline
(7 publishers, versioning, changelog), and SDK generation
(OpenAPI diff, code gen). 18K LOC, all tests pass except Go
builder workspace isolation (pre-existing).
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-09 12:37:36 +00:00
|
|
|
buildSuccessStyle.Render("*"),
|
|
|
|
|
buildTargetStyle.Render(relPath),
|
|
|
|
|
)
|
2026-03-26 17:41:53 +00:00
|
|
|
cli.Print(" %s\n", buildDimStyle.Render(artifact.Checksum))
|
feat: extract build/, release/, sdk/ from go-devops
Build system (8 builders, signing, archiving), release pipeline
(7 publishers, versioning, changelog), and SDK generation
(OpenAPI diff, code gen). 18K LOC, all tests pass except Go
builder workspace isolation (pre-existing).
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-09 12:37:36 +00:00
|
|
|
}
|
|
|
|
|
|
2026-03-26 17:41:53 +00:00
|
|
|
relChecksumPath, err := ax.Rel(projectDir, checksumPath)
|
feat: extract build/, release/, sdk/ from go-devops
Build system (8 builders, signing, archiving), release pipeline
(7 publishers, versioning, changelog), and SDK generation
(OpenAPI diff, code gen). 18K LOC, all tests pass except Go
builder workspace isolation (pre-existing).
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-09 12:37:36 +00:00
|
|
|
if err != nil {
|
|
|
|
|
relChecksumPath = checksumPath
|
|
|
|
|
}
|
2026-03-26 17:41:53 +00:00
|
|
|
cli.Print(" %s %s\n",
|
feat: extract build/, release/, sdk/ from go-devops
Build system (8 builders, signing, archiving), release pipeline
(7 publishers, versioning, changelog), and SDK generation
(OpenAPI diff, code gen). 18K LOC, all tests pass except Go
builder workspace isolation (pre-existing).
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-09 12:37:36 +00:00
|
|
|
buildSuccessStyle.Render("*"),
|
|
|
|
|
buildTargetStyle.Render(relChecksumPath),
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return checksummedArtifacts, nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// parseTargets parses a comma-separated list of OS/arch pairs.
|
|
|
|
|
func parseTargets(targetsFlag string) ([]build.Target, error) {
|
2026-03-26 17:41:53 +00:00
|
|
|
parts := core.Split(targetsFlag, ",")
|
feat: extract build/, release/, sdk/ from go-devops
Build system (8 builders, signing, archiving), release pipeline
(7 publishers, versioning, changelog), and SDK generation
(OpenAPI diff, code gen). 18K LOC, all tests pass except Go
builder workspace isolation (pre-existing).
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-09 12:37:36 +00:00
|
|
|
var targets []build.Target
|
|
|
|
|
|
|
|
|
|
for _, part := range parts {
|
2026-03-26 17:41:53 +00:00
|
|
|
part = core.Trim(part)
|
feat: extract build/, release/, sdk/ from go-devops
Build system (8 builders, signing, archiving), release pipeline
(7 publishers, versioning, changelog), and SDK generation
(OpenAPI diff, code gen). 18K LOC, all tests pass except Go
builder workspace isolation (pre-existing).
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-09 12:37:36 +00:00
|
|
|
if part == "" {
|
|
|
|
|
continue
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-26 17:41:53 +00:00
|
|
|
osArch := core.Split(part, "/")
|
feat: extract build/, release/, sdk/ from go-devops
Build system (8 builders, signing, archiving), release pipeline
(7 publishers, versioning, changelog), and SDK generation
(OpenAPI diff, code gen). 18K LOC, all tests pass except Go
builder workspace isolation (pre-existing).
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-09 12:37:36 +00:00
|
|
|
if len(osArch) != 2 {
|
2026-03-16 21:03:21 +00:00
|
|
|
return nil, coreerr.E("build.parseTargets", "invalid target format (expected os/arch): "+part, nil)
|
feat: extract build/, release/, sdk/ from go-devops
Build system (8 builders, signing, archiving), release pipeline
(7 publishers, versioning, changelog), and SDK generation
(OpenAPI diff, code gen). 18K LOC, all tests pass except Go
builder workspace isolation (pre-existing).
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-09 12:37:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
targets = append(targets, build.Target{
|
2026-03-26 17:41:53 +00:00
|
|
|
OS: core.Trim(osArch[0]),
|
|
|
|
|
Arch: core.Trim(osArch[1]),
|
feat: extract build/, release/, sdk/ from go-devops
Build system (8 builders, signing, archiving), release pipeline
(7 publishers, versioning, changelog), and SDK generation
(OpenAPI diff, code gen). 18K LOC, all tests pass except Go
builder workspace isolation (pre-existing).
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-09 12:37:36 +00:00
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if len(targets) == 0 {
|
2026-03-16 21:03:21 +00:00
|
|
|
return nil, coreerr.E("build.parseTargets", "no valid targets specified", nil)
|
feat: extract build/, release/, sdk/ from go-devops
Build system (8 builders, signing, archiving), release pipeline
(7 publishers, versioning, changelog), and SDK generation
(OpenAPI diff, code gen). 18K LOC, all tests pass except Go
builder workspace isolation (pre-existing).
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-09 12:37:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return targets, nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// formatTargets returns a human-readable string of targets.
|
|
|
|
|
func formatTargets(targets []build.Target) string {
|
|
|
|
|
var parts []string
|
|
|
|
|
for _, t := range targets {
|
|
|
|
|
parts = append(parts, t.String())
|
|
|
|
|
}
|
2026-03-26 17:41:53 +00:00
|
|
|
return core.Join(", ", parts...)
|
feat: extract build/, release/, sdk/ from go-devops
Build system (8 builders, signing, archiving), release pipeline
(7 publishers, versioning, changelog), and SDK generation
(OpenAPI diff, code gen). 18K LOC, all tests pass except Go
builder workspace isolation (pre-existing).
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-09 12:37:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// getBuilder returns the appropriate builder for the project type.
|
|
|
|
|
func getBuilder(projectType build.ProjectType) (build.Builder, error) {
|
|
|
|
|
switch projectType {
|
|
|
|
|
case build.ProjectTypeWails:
|
|
|
|
|
return builders.NewWailsBuilder(), nil
|
|
|
|
|
case build.ProjectTypeGo:
|
|
|
|
|
return builders.NewGoBuilder(), nil
|
|
|
|
|
case build.ProjectTypeDocker:
|
|
|
|
|
return builders.NewDockerBuilder(), nil
|
|
|
|
|
case build.ProjectTypeLinuxKit:
|
|
|
|
|
return builders.NewLinuxKitBuilder(), nil
|
|
|
|
|
case build.ProjectTypeTaskfile:
|
|
|
|
|
return builders.NewTaskfileBuilder(), nil
|
|
|
|
|
case build.ProjectTypeCPP:
|
|
|
|
|
return builders.NewCPPBuilder(), nil
|
|
|
|
|
case build.ProjectTypeNode:
|
2026-04-01 10:35:09 +00:00
|
|
|
return builders.NewNodeBuilder(), nil
|
feat: extract build/, release/, sdk/ from go-devops
Build system (8 builders, signing, archiving), release pipeline
(7 publishers, versioning, changelog), and SDK generation
(OpenAPI diff, code gen). 18K LOC, all tests pass except Go
builder workspace isolation (pre-existing).
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-09 12:37:36 +00:00
|
|
|
case build.ProjectTypePHP:
|
2026-04-01 10:41:59 +00:00
|
|
|
return builders.NewPHPBuilder(), nil
|
2026-04-01 11:31:10 +00:00
|
|
|
case build.ProjectTypePython:
|
|
|
|
|
return builders.NewPythonBuilder(), nil
|
2026-04-01 11:14:23 +00:00
|
|
|
case build.ProjectTypeRust:
|
|
|
|
|
return builders.NewRustBuilder(), nil
|
2026-04-01 11:10:27 +00:00
|
|
|
case build.ProjectTypeDocs:
|
|
|
|
|
return builders.NewDocsBuilder(), nil
|
feat: extract build/, release/, sdk/ from go-devops
Build system (8 builders, signing, archiving), release pipeline
(7 publishers, versioning, changelog), and SDK generation
(OpenAPI diff, code gen). 18K LOC, all tests pass except Go
builder workspace isolation (pre-existing).
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-09 12:37:36 +00:00
|
|
|
default:
|
2026-03-16 21:03:21 +00:00
|
|
|
return nil, coreerr.E("build.getBuilder", "unsupported project type: "+string(projectType), nil)
|
feat: extract build/, release/, sdk/ from go-devops
Build system (8 builders, signing, archiving), release pipeline
(7 publishers, versioning, changelog), and SDK generation
(OpenAPI diff, code gen). 18K LOC, all tests pass except Go
builder workspace isolation (pre-existing).
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-09 12:37:36 +00:00
|
|
|
}
|
|
|
|
|
}
|