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:
parent
d731afc298
commit
af9fd33b2a
3 changed files with 77 additions and 23 deletions
3
.github/workflows/dev-release.yml
vendored
3
.github/workflows/dev-release.yml
vendored
|
|
@ -44,7 +44,8 @@ jobs:
|
||||||
run: |
|
run: |
|
||||||
EXT=""
|
EXT=""
|
||||||
if [ "$GOOS" = "windows" ]; then EXT=".exe"; fi
|
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
|
- name: Upload artifact
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v4
|
||||||
|
|
|
||||||
90
.github/workflows/release.yml
vendored
90
.github/workflows/release.yml
vendored
|
|
@ -1,4 +1,4 @@
|
||||||
name: release
|
name: Release
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
|
|
@ -9,28 +9,78 @@ permissions:
|
||||||
contents: write
|
contents: write
|
||||||
|
|
||||||
jobs:
|
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
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Download all artifacts
|
||||||
|
uses: actions/download-artifact@v4
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
path: artifacts
|
||||||
- uses: actions/setup-go@v5
|
merge-multiple: true
|
||||||
with:
|
|
||||||
go-version: '1.25'
|
- name: Generate checksums
|
||||||
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)
|
|
||||||
run: |
|
run: |
|
||||||
go install github.com/wailsapp/wails/v3/cmd/wails3@latest || true
|
cd artifacts
|
||||||
- name: Run GoReleaser
|
sha256sum core-* > checksums.txt
|
||||||
uses: goreleaser/goreleaser-action@v6
|
cat checksums.txt
|
||||||
with:
|
|
||||||
distribution: goreleaser
|
- name: Create release
|
||||||
version: latest
|
|
||||||
args: release --clean
|
|
||||||
env:
|
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/*
|
||||||
|
|
|
||||||
|
|
@ -11,10 +11,13 @@ import (
|
||||||
const (
|
const (
|
||||||
// AppName is the CLI application name.
|
// AppName is the CLI application name.
|
||||||
AppName = "core"
|
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.
|
// Main initialises and runs the CLI application.
|
||||||
// This is the main entry point for the CLI.
|
// This is the main entry point for the CLI.
|
||||||
// Exits with code 1 on error.
|
// Exits with code 1 on error.
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue