gorelease

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2026 License: MIT Imports: 9 Imported by: 0

README

gorelease

Create GitHub releases with cross-platform binaries for an existing tag.

gorelease is a release-only tool: it does not create tags or commits. It cross-compiles a Go project's cmd/ binaries for multiple platforms and uploads them as assets to a GitHub Release.

Installation

go install github.com/tinywasm/gorelease/cmd/gorelease@latest

Usage as GitHub Action

- uses: tinywasm/gorelease@v1
  with:
    tag: v1.2.3        # optional, defaults to latest tag
    version: v0.1.0    # optional, which gorelease version to download

See action.yml for all inputs.

Usage as CLI

gorelease [tag]
gorelease version

Documentation

  • GORELEASE.md — detailed CLI behavior, targets, requirements
  • Flow Diagram — visual representation of the process
  • action.yml — generated composite action (do not edit manually, edit action_data.go)

Development

go test ./...
# Regenerates action.yml if out of sync

Action generation:

  • action_data.go defines the action
  • action.go, render.go, sync.go render it to action.yml
  • tests/action_sync_test.go keeps them in sync

License

MIT

Documentation

Index

Constants

View Source
const (
	ActionFilePath     = "action.yml"
	ReleaseAssetURLFmt = "https://github.com/tinywasm/gorelease/releases/download/%s/%s"
)
View Source
const HeaderGenerated = `` /* 163-byte string literal not displayed */

Variables

View Source
var Version = "v0.0.0"

Version is injected at build time via -ldflags="-X main.Version=...". It is also used by `gorelease version` output.

Functions

func CrossCompile added in v0.1.0

func CrossCompile(tmpDir string, cmds []string, targets []CrossTarget, repoDir string) ([]string, error)

CrossCompile builds the specified commands for multiple platforms.

func LatestReleaseTag added in v0.1.0

func LatestReleaseTag() (string, error)

LatestReleaseTag returns the highest semver tag in the repository.

func ParseReleaseArgs added in v0.1.0

func ParseReleaseArgs(args []string) (tag string, isHelp bool)

ParseReleaseArgs parses gorelease CLI: gorelease [tag] Returns tag (may be empty) and isHelp.

func Sync added in v0.1.0

func Sync(path string, a Action) (changed bool, err error)

Sync writes a's YAML to path when it differs from what is already there.

Types

type Action added in v0.1.0

type Action struct {
	Name        string
	Description string
	Author      string
	Branding    Branding
	Header      string
	Inputs      []Input
	Outputs     []Output
	Steps       []Step
}

func GoreleaseAction added in v0.1.0

func GoreleaseAction(goreleaseVersion string) Action

GoreleaseAction builds the description of the gorelease action.

func (Action) Render added in v0.1.0

func (a Action) Render() []byte

Render produces the action YAML. It is deterministic.

type Branding added in v0.1.0

type Branding struct {
	Icon  string
	Color string
}

type CrossTarget added in v0.1.0

type CrossTarget struct{ GOOS, GOARCH string }

CrossTarget represents a compilation target platform.

func DefaultTargets added in v0.1.0

func DefaultTargets() []CrossTarget

DefaultTargets returns the standard set of platforms for release.

type GitClient added in v0.1.0

type GitClient interface {
	GetLatestTag() (string, error)
}

GitClient is the minimal git interface needed by ReleaseOnly.

type GitHubClient added in v0.1.0

type GitHubClient interface {
	RepoInfo(repoRef string) (owner, name, visibility string, err error)
	CreateRelease(tag string, assets []string, targetRepo string) (string, error)
}

GitHubClient is the minimal GitHub interface needed by ReleaseOnly.

type Gorelease

type Gorelease struct {
	// contains filtered or unexported fields
}

Gorelease orchestrates cross-compilation and GitHub Release creation.

func New

func New(git GitClient) (*Gorelease, error)

New creates a new Gorelease handler.

func (*Gorelease) CrossCompileWithTag added in v0.1.0

func (g *Gorelease) CrossCompileWithTag(tmpDir string, cmds []string, targets []CrossTarget, repoDir, tag string) ([]string, error)

CrossCompileWithTag builds the specified commands for multiple platforms with version injection.

func (*Gorelease) ReleaseOnly added in v0.1.0

func (g *Gorelease) ReleaseOnly(tag string, gh GitHubClient) error

ReleaseOnly creates a GitHub Release with cross-platform binaries for an existing tag. If tag is empty, it uses the latest tag from git.GetLatestTag().

func (*Gorelease) SetConsoleOutput added in v0.1.0

func (g *Gorelease) SetConsoleOutput(fn func(string))

SetConsoleOutput sets the function for console output.

func (*Gorelease) SetCrossCompileFn added in v0.1.0

func (g *Gorelease) SetCrossCompileFn(fn func(tmpDir string, cmds []string, targets []CrossTarget, repoDir string) ([]string, error))

SetCrossCompileFn sets a custom cross-compile function for testing.

func (*Gorelease) SetLog added in v0.1.0

func (g *Gorelease) SetLog(fn func(...any))

SetLog sets the logger function.

func (*Gorelease) SetRootDir added in v0.1.0

func (g *Gorelease) SetRootDir(path string)

SetRootDir sets the root directory for operations.

type Input added in v0.1.0

type Input struct {
	Name        string
	Description string
	Default     string
	Required    bool
}

type KeyValue added in v0.1.0

type KeyValue struct {
	Key   string
	Value string
}

KeyValue is an ordered key-value pair.

type Output added in v0.1.0

type Output struct {
	Name        string
	Description string
	Value       string
}

type Step added in v0.1.0

type Step struct {
	Name    string
	ID      string
	If      string
	Uses    string
	With    []KeyValue
	Shell   string
	Run     string
	Env     []KeyValue
	Comment string
}

Directories

Path Synopsis
cmd
gorelease command

Jump to

Keyboard shortcuts

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