fix(release): add proper release workflow with version injection

- Make AppVersion injectable via ldflags at build time
- Replace GoReleaser with simple GitHub Actions workflow
- Build for linux/darwin/windows on amd64/arm64
- Generate checksums.txt for integrity verification
- Inject version from git tag into binary

Fixes #37

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Snider 2026-02-01 06:21:12 +00:00
parent 92264f29f4
commit 6670ad7d2b
3 changed files with 77 additions and 23 deletions

View file

@ -44,7 +44,8 @@ jobs:
run: |
EXT=""
if [ "$GOOS" = "windows" ]; then EXT=".exe"; fi
go build -trimpath -ldflags="-s -w" -o core-${GOOS}-${GOARCH}${EXT} ./cmd/core
VERSION="dev-$(git rev-parse --short HEAD)"
go build -trimpath -ldflags="-s -w -X github.com/host-uk/core/pkg/cli.AppVersion=${VERSION}" -o core-${GOOS}-${GOARCH}${EXT} .
- name: Upload artifact
uses: actions/upload-artifact@v4

View file

@ -1,4 +1,4 @@
name: release
name: Release
on:
push:
@ -9,28 +9,78 @@ permissions:
contents: write
jobs:
goreleaser:
build:
runs-on: ubuntu-latest
strategy:
matrix:
include:
- goos: linux
goarch: amd64
- goos: linux
goarch: arm64
- goos: darwin
goarch: amd64
- goos: darwin
goarch: arm64
- goos: windows
goarch: amd64
- goos: windows
goarch: arm64
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.24'
check-latest: true
- name: Get version from tag
id: version
run: echo "VERSION=${GITHUB_REF_NAME}" >> $GITHUB_OUTPUT
- name: Build CLI
env:
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
CGO_ENABLED: '0'
run: |
EXT=""
if [ "$GOOS" = "windows" ]; then EXT=".exe"; fi
go build -trimpath \
-ldflags="-s -w -X github.com/host-uk/core/pkg/cli.AppVersion=${{ steps.version.outputs.VERSION }}" \
-o core-${GOOS}-${GOARCH}${EXT} .
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: core-${{ matrix.goos }}-${{ matrix.goarch }}
path: core-*
release:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
fetch-depth: 0
- uses: actions/setup-go@v5
with:
go-version: '1.25'
check-latest: true
- name: Set up Node (for GUI builds if needed)
uses: actions/setup-node@v4
with:
node-version: '22'
- name: Install Wails (optional)
path: artifacts
merge-multiple: true
- name: Generate checksums
run: |
go install github.com/wailsapp/wails/v3/cmd/wails3@latest || true
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v6
with:
distribution: goreleaser
version: latest
args: release --clean
cd artifacts
sha256sum core-* > checksums.txt
cat checksums.txt
- name: Create release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release create ${{ github.ref_name }} \
--title "${{ github.ref_name }}" \
--generate-notes \
artifacts/*

View file

@ -11,10 +11,13 @@ import (
const (
// AppName is the CLI application name.
AppName = "core"
// AppVersion is the CLI application version.
AppVersion = "0.1.0"
)
// AppVersion is set at build time via ldflags:
//
// go build -ldflags="-X github.com/host-uk/core/pkg/cli.AppVersion=v1.0.0"
var AppVersion = "dev"
// Main initialises and runs the CLI application.
// This is the main entry point for the CLI.
// Exits with code 1 on error.