releasebuild

package
v1.6.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 30, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package releasebuild drives the Dockyard release pipeline — the step the `.github/workflows/release.yml` workflow runs on a `v*` tag push to produce the cross-compile artifacts attached to the GitHub Release (Phase 30 — V1 release engineering, RFC §14).

It is a thin, deterministic wrapper over `internal/buildpkg.Build`:

  1. invoke Build with the full RFC §14 cross-compile matrix (DefaultMatrix) against the dockyard CLI project (cmd/dockyard);
  2. rename each produced artifact under its release-publish name — "dockyard-<version>-<os>-<arch>[.exe]" — so a downloaded binary's filename carries the version a user is auditing;
  3. write an aggregate "checksums.txt" alongside the artifacts, in the same `sha256sum -c`-compatible line shape buildpkg already emits per artifact.

The package is internal — it is the reusable, testable seam the `releasebuild` cmd (and the Phase 30 release workflow) consume. Release holds no shared mutable state; it is safe to invoke concurrently with distinct Options.

Why a separate package rather than a new buildpkg knob: buildpkg's surface is the per-project "dockyard build" pipeline a developer runs against their own project. The release driver is dockyard's own project + a tag-shaped artifact-naming convention + the aggregate checksums sidecar — the same primitives, a different audience. Two packages keep each one's surface honest.

Index

Constants

This section is empty.

Variables

View Source
var ErrRelease = errors.New("dockyard/internal/releasebuild: release failed")

ErrRelease is the sentinel wrapping a release driver failure. A failure inside `go build` propagates wrapped in ErrRelease; an IO fault on publish does the same. Callers branch with errors.Is(err, ErrRelease).

Functions

This section is empty.

Types

type Artifact

type Artifact struct {
	// Target is the GOOS/GOARCH this artifact was built for.
	Target buildpkg.Target
	// Path is the absolute path of the published binary.
	Path string
	// ChecksumPath is the absolute path of the binary's .sha256 sidecar.
	ChecksumPath string
	// SHA256 is the binary's lowercase hex SHA-256 digest — convenient
	// for the aggregate checksums writer and any direct caller.
	SHA256 string
}

Artifact describes one published binary + its checksum sidecar.

type Options

type Options struct {
	// Version is the release version (e.g. "v1.0.0" or "1.0.0"). Required.
	// The driver canonicalises the form once: every produced artifact
	// embeds the "v"-prefixed shape so the published filename matches
	// the GitHub Release tag.
	Version string
	// ProjectDir is the Dockyard repository root — the directory holding
	// go.mod. Empty means the current working directory.
	ProjectDir string
	// OutputDir is the directory release artifacts land in. Required —
	// the release workflow points at a fresh tempdir under runner.temp
	// so a re-run does not see a previous run's stale files.
	OutputDir string
	// CmdPath overrides the Go-import path of the dockyard CLI main
	// package. Defaults to "./cmd/dockyard". Tests use this to point
	// at a fixture main package.
	CmdPath string
	// Targets overrides the cross-compile matrix; empty means the RFC §14
	// DefaultMatrix (darwin/linux/windows × amd64/arm64). Tests use this
	// to narrow the matrix to the host-only target so a release dry-run
	// stays fast and CGo-free on any GitHub runner.
	Targets []buildpkg.Target
	// BinaryBase overrides the published artifact stem. Defaults to
	// "dockyard". Tests pass a unique name to keep parallel runs
	// untangled.
	BinaryBase string
	// Logger receives structured progress output. A nil Logger falls
	// back to a discarding handler so Release never panics on a missing
	// logger.
	Logger *slog.Logger
}

Options configures one Release invocation.

type Result

type Result struct {
	// Version is the canonicalised release version (always "v"-prefixed).
	Version string
	// OutputDir is the absolute path of the directory artifacts landed in.
	OutputDir string
	// Artifacts is every published binary + checksum, in matrix order.
	Artifacts []Artifact
	// ChecksumsFile is the absolute path of the aggregate checksums.txt.
	ChecksumsFile string
}

Result describes what Release produced.

func Release

func Release(ctx context.Context, opts Options) (Result, error)

Release runs the V1 release pipeline against the dockyard CLI source at opts.ProjectDir and publishes the artifacts under opts.OutputDir.

For each target in opts.Targets (or the RFC §14 DefaultMatrix when the slice is empty), Release runs `go build ./cmd/dockyard` with CGO_ENABLED=0 + GOOS/GOARCH set, names the resulting binary "dockyard-<version>-<os>-<arch>[.exe]", writes the per-artifact .sha256 sidecar, and finally writes the aggregate `checksums.txt`.

A failure wraps `ErrRelease` (with the stderr buffered into the error message so a CI log surfaces it without artifact upload).

Release does not run `make preflight` — that gate runs as a separate step in `.github/workflows/release.yml` *before* the release driver is invoked. Keeping the two steps separate makes it possible to dry-run the release packaging without re-running the full preflight, and lets `act` or a local run inspect the release artifacts on their own.

Release holds no shared mutable state; concurrent invocations with distinct Options are safe.

type Target

type Target = buildpkg.Target

Target re-exports buildpkg.Target so callers do not have to import both packages — the release driver and its tests almost always work with the build matrix as one unit.

func DefaultMatrix

func DefaultMatrix() []Target

DefaultMatrix re-exports buildpkg.DefaultMatrix for the same reason.

func HostTarget

func HostTarget() Target

HostTarget returns the GOOS/GOARCH of the runner the driver is on. The release dry-run uses this to narrow the matrix to one fast target.

Directories

Path Synopsis
cmd
releasebuild command
Command releasebuild drives Dockyard's V1 release pipeline — the step the `.github/workflows/release.yml` workflow runs on a `v*` tag push.
Command releasebuild drives Dockyard's V1 release pipeline — the step the `.github/workflows/release.yml` workflow runs on a `v*` tag push.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL