Skip to content

Add multi-platform builds: Linux ARM64, macOS amd64, macOS ARM64 #151

Description

@mrhillsman

Summary

Add cross-compiled release binaries for three new platform/arch targets:

OS Arch Notes
Linux arm64 Servers, Raspberry Pi, Graviton
macOS amd64 (x86_64) Intel Macs
macOS arm64 Apple Silicon (M1+)

Currently only Linux amd64 is built.

Prerequisite

With CGO eliminated, GOOS/GOARCH cross-compilation works out of the box — no C cross-compilers or osxcross toolchains needed.

Implementation plan

1. Update .goreleaser.yaml — add build targets

Replace the single linux-amd64 build with multiple builds:

builds:
  - id: linux-amd64
    env:
      - CGO_ENABLED=0
    goos: [linux]
    goarch: [amd64]
    flags: [-trimpath]
    ldflags:
      - -s -w -X main.version={{ .Version }} -X main.commit={{ .Commit }} -X main.date={{ .CommitDate }}
    main: ./cmd/virtwork/

  - id: linux-arm64
    env:
      - CGO_ENABLED=0
    goos: [linux]
    goarch: [arm64]
    flags: [-trimpath]
    ldflags:
      - -s -w -X main.version={{ .Version }} -X main.commit={{ .Commit }} -X main.date={{ .CommitDate }}
    main: ./cmd/virtwork/

  - id: darwin-amd64
    env:
      - CGO_ENABLED=0
    goos: [darwin]
    goarch: [amd64]
    flags: [-trimpath]
    ldflags:
      - -s -w -X main.version={{ .Version }} -X main.commit={{ .Commit }} -X main.date={{ .CommitDate }}
    main: ./cmd/virtwork/

  - id: darwin-arm64
    env:
      - CGO_ENABLED=0
    goos: [darwin]
    goarch: [arm64]
    flags: [-trimpath]
    ldflags:
      - -s -w -X main.version={{ .Version }} -X main.commit={{ .Commit }} -X main.date={{ .CommitDate }}
    main: ./cmd/virtwork/

Alternatively, this can be consolidated into a single build entry with multiple GOOS/GOARCH values:

builds:
  - env:
      - CGO_ENABLED=0
    goos: [linux, darwin]
    goarch: [amd64, arm64]
    flags: [-trimpath]
    ldflags:
      - -s -w -X main.version={{ .Version }} -X main.commit={{ .Commit }} -X main.date={{ .CommitDate }}
    main: ./cmd/virtwork/

GoReleaser generates all valid combinations automatically.

2. Update .goreleaser.yaml — Docker image build IDs

The dockers section currently references ids: [linux-amd64]. If builds are consolidated into a single entry, remove the ids filter or update it to reference the new build ID. The Docker image only needs the linux/amd64 binary.

3. Update archive naming

The existing name_template already handles OS and Arch mapping correctly (Darwin, Linux, x86_64, arm64). No changes needed.

4. Verify release artifacts

After the next tag push, the GitHub release page should include:

  • virtwork_Linux_x86_64.tar.gz
  • virtwork_Linux_arm64.tar.gz
  • virtwork_Darwin_x86_64.tar.gz
  • virtwork_Darwin_arm64.tar.gz
  • checksums file

Acceptance criteria

  • goreleaser check passes (config validation)
  • goreleaser build --snapshot --clean produces all 4 binaries locally
  • Docker image section still builds correctly (linux/amd64 only)
  • Archive naming is correct for all platforms
  • Release page shows all 4 platform archives after tag push

Notes

  • No changes to CI workflow (release.yml) are needed — GoReleaser handles the matrix
  • macOS binaries are unsigned; users will need to xattr -d com.apple.quarantine or allow in System Settings on first run — this is standard for unsigned CLI tools distributed outside the App Store
  • Consider adding a multi-arch Docker image (linux/amd64 + linux/arm64) as a follow-up if there's demand

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions