Skip to content

Go Edition: goreleaser & cross-platform distribution #503

Description

@Zordrak

Summary

Set up goreleaser configuration for cross-platform compilation and distribution of the Go edition binary.

Parent Epic

Part of #488 — Go Edition: Full Feature Parity Implementation

Motivation

The Go edition's key advantage is single-binary distribution. This issue sets up goreleaser to produce platform binaries for every supported OS/architecture, with both tfenv and terraform entry points in each archive, plus Homebrew tap, .deb, .rpm, and .zip artifacts.

Clean-Room Constraint

This is a clean-room implementation. Contributors MUST NOT read, reference, copy, or adapt source code from tofuutils/tenv, hashicorp/hc-install, or any other third-party tfenv-like tool. The sole reference is tfenv's own Bash source code, documentation, and test suite.

Proposed Design

goreleaser Configuration

.goreleaser.yml at the repository root (or go/.goreleaser.yml):

  • Build targets:

    • linux/amd64, linux/arm64, linux/arm
    • darwin/amd64, darwin/arm64
    • windows/amd64, windows/arm64
    • freebsd/amd64 (stretch goal)
  • Binary name: tfenv

  • ldflags: -s -w -X main.version={{.Version}} -X main.commit={{.Commit}} -X main.date={{.Date}}

  • Archives: Each archive contains:

    • tfenv (or tfenv.exe) — the main binary
    • terraform (or terraform.exe) — hardlink/copy of the same binary
    • README.md and LICENSE
  • Package formats:

    • .tar.gz for Linux and macOS
    • .zip for Windows
    • .deb and .rpm for Linux package managers
  • Homebrew tap: Generate Homebrew formula for tfutils/homebrew-tap

  • Checksums: SHA256 checksums file for all artifacts

Post-Build Hook

A post-build hook or custom publisher that creates the terraform hardlink/copy alongside tfenv in each archive. goreleaser's extra_files or a custom hook script handles this.

CGo

CGo is disabled (CGO_ENABLED=0) for all builds to ensure static binaries with no system library dependencies.

Acceptance Criteria

  • goreleaser config exists and is valid (goreleaser check)
  • goreleaser build --snapshot produces binaries for all target platforms
  • Each archive contains both tfenv and terraform entry points
  • Version, commit, and date are embedded in the binary via ldflags
  • Linux archives are .tar.gz, Windows archives are .zip
  • .deb and .rpm packages are generated for Linux
  • Homebrew formula is generated
  • SHA256 checksums file is generated
  • All binaries are statically linked (CGO_ENABLED=0)
  • goreleaser release --snapshot --skip=publish completes without errors
  • Binary size is reasonable (target: under 20MB per platform)

Dependencies

Implementation Notes

  • goreleaser v2 is the current version — use the latest stable
  • The terraform entry point in archives can be created via goreleaser's extra_files with a post-hook that creates hardlinks, or via a custom script
  • On Windows, the terraform.exe copy must be a full copy (not symlink) to avoid privilege issues
  • Consider signing binaries (the ADR mentions Cosign as a future capability — not required now but the goreleaser config should be structured to make it easy to add)
  • The Homebrew formula should install both tfenv and terraform binaries
  • Coordinate with the CI issue (Go Edition: CI integration — acceptance test matrix (both editions x all platforms) #504) for release workflow integration

Labels

type:feature, priority:high, complexity:medium, category:platform

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions