gorelease

package module
v0.1.1 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.

The CLI binary (cmd/gorelease) is for local developer use. The GitHub Action (tinywasm/gorelease@v1) is a pure-bash composite action generated from Go — no binary download, ~0MB overhead — that reuses the same DRY constants (DefaultTargets, VersionLdFlag, DistDir, etc.).

Installation (CLI)

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

Usage as GitHub Action (pure bash)

- uses: tinywasm/gorelease@v1
  with:
    tag: v1.2.3        # optional, defaults to latest tag (highest semver)
  env:
    GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} # required for gh CLI

Inputs: tag (optional), setup-go (default 'true', runs actions/setup-go@v6 Node 24). No version input — the action is bash and does not download a binary.

See action.yml for all inputs/outputs.

Usage as CLI

gorelease [tag]
gorelease version  # prints 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 (DRY: targets/ldflags from gorelease.go)

Action generation:

  • gorelease.go — DRY source of truth (DefaultTargets, VersionLdFlag, DistDir, ChecksumFile)
  • action_data.go — generates bash steps from those constants (no hard-coded strings)
  • action.go, render.go, sync.go render to action.yml
  • tests/action_sync_test.go keeps them in sync

Actions use Node 24: actions/checkout@v5, actions/setup-go@v6.

License

MIT

Documentation

Index

Constants

View Source
const (
	ChecksumFile = "checksums.txt"
	DistDir      = "dist"
)

DRY constants — single source of truth for both Go and generated bash action.

View Source
const (
	ActionFilePath = "action.yml"
)

Variables

View Source
var Version = "v0.0.0"

Version is injected at build time via -ldflags="-X github.com/tinywasm/gorelease.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 GoreleaseAction added in v0.1.0

func GoreleaseAction(_ string) ghaction.Action

GoreleaseAction builds the description of the gorelease action. It is a pure-bash composite action: no binary download, no extra weight. All cross-compile targets, ldflags and publish logic are derived from the DRY constants in gorelease.go (DefaultTargets, VersionLdFlag, etc.). Uses ghaction typed Action with presets for Node24 optimal defaults.

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 ReleaseWorkflow added in v0.1.1

func ReleaseWorkflow() ghaction.Workflow

ReleaseWorkflow returns the typed release workflow for gorelease self-release. It is pure Go, no hard-coded YAML strings — single source for action.yml + workflows. Uses ghaction presets for Node24 optimal defaults.

func TestWorkflow added in v0.1.1

func TestWorkflow() ghaction.Workflow

TestWorkflow returns the typed test workflow (PR guard, read-only).

func VersionLdFlag added in v0.1.1

func VersionLdFlag(tag string) string

VersionLdFlag returns the -ldflags value for version injection.

Types

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.

Directories

Path Synopsis
cmd
gorelease command

Jump to

Keyboard shortcuts

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