dist

package
v0.0.0-...-97a3edb Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2024 License: BSD-3-Clause Imports: 17 Imported by: 0

Documentation

Overview

Package dist is a release artifact builder library.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Build

type Build struct {
	// Repo is a path to the root Go module for the build.
	Repo string
	// Out is where build artifacts are written.
	Out string
	// Verbose is whether to print all command output, rather than just failed
	// commands.
	Verbose bool
	// WebClientSource is a path to the source for the web client.
	// If non-empty, web client assets will be built.
	WebClientSource string

	// Tmp is a temporary directory that gets deleted when the Builder is closed.
	Tmp string
	// Go is the path to the Go binary to use for building.
	Go string
	// Yarn is the path to the yarn binary to use for building the web client assets.
	Yarn string
	// Version is the version info of the build.
	Version mkversion.VersionInfo
	// Time is the timestamp of the build.
	Time time.Time
	// contains filtered or unexported fields
}

A Build is a build context for Targets.

func NewBuild

func NewBuild(repo, out string) (*Build, error)

NewBuild creates a new Build rooted at repo, and writing artifacts to out.

func (*Build) Build

func (b *Build) Build(targets []Target) (files []string, err error)

Build builds all targets concurrently.

func (*Build) BuildGoBinary

func (b *Build) BuildGoBinary(path string, env map[string]string) (string, error)

BuildGoBinary builds the Go binary at path and returns the path to the binary. Builds are cached by path and env, so each build only happens once per process execution.

func (*Build) BuildGoBinaryWithTags

func (b *Build) BuildGoBinaryWithTags(path string, env map[string]string, tags []string) (string, error)

BuildGoBinaryWithTags builds the Go binary at path and returns the path to the binary. Builds are cached by path, env and tags, so each build only happens once per process execution.

The passed in tags override gocross's automatic selection of build tags, so you will have to figure out and specify all the tags relevant to your build.

func (*Build) BuildWebClientAssets

func (b *Build) BuildWebClientAssets() error

BuildWebClientAssets builds the JS and CSS assets used by the web client. If b.WebClientSource is non-empty, assets are built in a "build" sub-directory of that path. Otherwise, no assets are built.

func (*Build) Close

func (b *Build) Close() error

Close ends the build and cleans up temporary files.

func (*Build) Command

func (b *Build) Command(dir, cmd string, args ...string) *Command

Command prepares an exec.Cmd to run [cmd, args...] in dir.

func (*Build) Extra

func (b *Build) Extra(key any, constructor func() any) any

Extra returns a value from the build's extra state, creating it if necessary.

func (*Build) GoPkg

func (b *Build) GoPkg(pkg string) (string, error)

GoPkg returns the path on disk of pkg. The module of pkg must be imported in b.Repo's go.mod.

func (*Build) Once

func (b *Build) Once(name string, fn func() error) error

Once runs fn if Once hasn't been called with name before.

func (*Build) TmpDir

func (b *Build) TmpDir() string

TmpDir creates and returns a new empty temporary directory. The caller does not need to clean up the directory after use, it will get deleted by b.Close().

type Command

type Command struct {
	Cmd    *exec.Cmd
	Output bytes.Buffer
}

Command runs an exec.Cmd and returns its exit status. If the command fails, its output is printed to os.Stdout, otherwise it's suppressed.

func (*Command) CombinedOutput

func (c *Command) CombinedOutput() (string, error)

CombinedOutput is like c.Cmd.CombinedOutput, but returns the output as a string instead of a byte slice.

func (*Command) Run

func (c *Command) Run() error

Run is like c.Cmd.Run, but if the command fails, its output is printed to os.Stdout before returning the error.

type Memoize

type Memoize[O any] struct {
	// contains filtered or unexported fields
}

Memoize runs MemoizedFns and remembers their results.

func (*Memoize[O]) Do

func (m *Memoize[O]) Do(key any, fn MemoizedFn[O]) (ret O, err error)

Do runs fn and returns its result. fn is only run once per unique key. Subsequent Do calls with the same key return the memoized result of the first call, even if fn is a different function.

type MemoizedFn

type MemoizedFn[T any] func() (T, error)

MemoizedFn is a function that memoize.Do can call.

type Signer

type Signer func(io.Reader) ([]byte, error)

Signer is pluggable signer for a Target.

func (Signer) SignFile

func (s Signer) SignFile(filePath, sigPath string) error

SignFile signs the file at filePath with s and writes the signature to sigPath.

type Target

type Target interface {
	String() string
	Build(build *Build) ([]string, error)
}

A Target is something that can be build in a Build.

func FilterTargets

func FilterTargets(targets []Target, filters []string) ([]Target, error)

FilterTargets returns the subset of targets that match any of the filters. If filters is empty, returns all targets.

Directories

Path Synopsis
Package cli provides the skeleton of a CLI for building release packages.
Package cli provides the skeleton of a CLI for building release packages.
Package synology contains dist Targets for building Synology Tailscale packages.
Package synology contains dist Targets for building Synology Tailscale packages.
Package unixpkgs contains dist Targets for building unix Tailscale packages.
Package unixpkgs contains dist Targets for building unix Tailscale packages.

Jump to

Keyboard shortcuts

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