build

package
v0.0.0-...-bbe2ffc Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2018 License: MIT Imports: 22 Imported by: 1

Documentation

Index

Constants

View Source
const (
	// DefaultOutDir defines the default location for build packages
	DefaultOutDir = "./bin"
)

Variables

View Source
var (
	TargetLinux386     = PackageTarget{"linux", "386"}
	TargetLinuxAmd64   = PackageTarget{"linux", "amd64"}
	TargetWindows386   = PackageTarget{"windows", "386"}
	TargetWindowsAmd64 = PackageTarget{"windows", "amd64"}
	TargetDarwinAmd64  = PackageTarget{"darwin", "amd64"}
	TargetLocal        = PackageTarget{"", ""}

	DefaultPackageTargets = []PackageTarget{
		TargetLinux386,
		TargetLinuxAmd64,
		TargetWindows386,
		TargetWindowsAmd64,
	}

	ReleaserTemplate *template.Template
)

Functions

func BuildPackage

func BuildPackage(pkg Package, t PackageTarget) (string, error)

BuildPackage builds a package and returns the path to the output.

func BuildPackages

func BuildPackages(pkg Package, targets ...PackageTarget) error

BuildPackages performs a go build on the supplied package.

func BuildPlugin

func BuildPlugin(cfg PluginConfig) error

func CIBuildProblem

func CIBuildProblem(err error) error

CIBuildProblem reports an error in a way TeamCity can understand. If err is nil, this method does nothing. This method returns the error to support chaining.

func CIMessage

func CIMessage(messageType string, data interface{})

CIMessage writes a message out in a format TeamCity can understand. The data parameter can be a string or a map[string]string.

func CIProgress

func CIProgress(message string)

func CopyFile

func CopyFile(srcFile, dstFile string) error

func GitBranch

func GitBranch() (string, error)

func GitHash

func GitHash() (string, error)

func GitPush

func GitPush(target string) error

func GitPushToRemote

func GitPushToRemote(remote, target string) error

func GitShortHash

func GitShortHash() (string, error)

func GitTag

func GitTag(tag, msg string) error

func MakeExecutable

func MakeExecutable(file string) error

func MustGetGit

func MustGetGit() (branch, commit, shortCommit string)

func OnMasterBranch

func OnMasterBranch() bool

func OnReleaseBranch

func OnReleaseBranch() bool

func Release

func Release(pkg Package) error

Release executes a gorelease operation

func RunIntegrationTestsInDocker

func RunIntegrationTestsInDocker(name, dockerComposePath string) error

RunIntegrationTestsInDocker executes integration tests using docker-compose.

func RunSpecsWithReporting

func RunSpecsWithReporting(t *testing.T, suiteName string)

func RunUnitTests

func RunUnitTests(tags []string) error

RunUnitTests runs unit tests recursively

func RunningOnTeamCity

func RunningOnTeamCity() bool

func SetTeamCityBuildNumber

func SetTeamCityBuildNumber(version, buildNumber string)

func SetTeamCityParameter

func SetTeamCityParameter(name, value string)

func TagAndPushDockerImages

func TagAndPushDockerImages(sourceImage, imageName, imageTagPrefix, buildNumber, majorVersion, minorVersion string) ([]string, error)

TagAndPushDockerImages uses the environment parameters IMAGE_NAME, BUILD_NUMBER, MAJOR_VERSION, and MINOR_VERSION to create images with the following tags: IMAGE_NAME:MAJOR_VERSION.MINOR_VERSION-BUILD_NUMBER IMAGE_NAME:MAJOR_VERSION.MINOR_VERSION IMAGE_NAME:MAJOR_VERSION IMAGE_NAME:latest If IMAGE_TAG_PREFIX is set, it will be inserted at the beginning of the tag. This task expects there to be an existing image named IMAGE_NAME:git-commit-hash This task returns a slice containing the deployed images, in order from most specific to least specific.

func ToS3ReleasePath

func ToS3ReleasePath(pkgName, serviceID string, version semver.Version) string

ToS3ReleasePath returns a path for upload to S3 in the format 'releases/{serviceID}/{version.Major}.{version.Minor}.{version.Patch}/{pkgName}'.

func Unzip

func Unzip(src string, dest string) ([]string, error)

Unzip will decompress a zip archive, moving all files and folders within the zip file (parameter 1) to an output directory (parameter 2).

func UploadToS3

func UploadToS3(bucket, src, target string) (bool, error)

UploadToS3 uploads a file to an AWS S3 bucket

func ZipFiles

func ZipFiles(filename string, files []string) error

ZipFiles compresses one or many files into a single zip archive file. Param 1: filename is the output zip file's name. Param 2: files is a list of files to add to the zip.

Types

type Build

type Build struct {
	Package       Package
	PackageTarget PackageTarget
}

Build combines a Package and a PackageTarget

type Package

type Package struct {
	Name    string
	Version semver.Version
	// Alternative to setting Version, to avoid vendoring annoyances
	VersionString string
	PackagePath   string
	OutDir        string
	// If present, will be compiled into a template and passed a Build to construct the name of the compiled binary.
	OutTemplate string
	DockerRepo  string
	Shrink      bool
	Main        string // The path to main.go or build dir
	BuildArgs   []string
	CGOEnabled  bool
}

Package provides information for building a binary image

func NewPackage

func NewPackage(name string, version semver.Version) Package

NewPackage creates a new package with default values configured. The default values set by this operation are:

PackagePath: "github.com/naveegoinc/{name}"
OutDir: 	 "./bin"
DockerRepo:	 "docker.naveego.com:4333"
Main: 		 "main.go"

Given the variables name="helloworld" and version="v1.0.0", the return package would have the following values:

Name:		 "helloworld"
Version:	 "v1.0.0"
PackagePath: "github.com/naveegoinc/helloworld"
OutDir:		 "./bin"
DockerRepo:	 "docker.naveego.com:4333"
Main:		 "main.go"

type PackageTarget

type PackageTarget struct {
	OS   string
	Arch string
}

PackageTarget defines

func (PackageTarget) String

func (t PackageTarget) String() string

type PluginConfig

type PluginConfig struct {
	Package Package
	Targets []PackageTarget
	Files   []string
}

Jump to

Keyboard shortcuts

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