diff --git a/.github/workflows/release.lock.yml b/.github/workflows/release.lock.yml index 8838c6b9..d681b063 100644 --- a/.github/workflows/release.lock.yml +++ b/.github/workflows/release.lock.yml @@ -1257,19 +1257,23 @@ jobs: - name: Run tests run: make test - name: Build binary - run: make build - - name: Create release + run: | + RELEASE_TAG="${GITHUB_REF#refs/tags/}" + echo "Building multi-platform binaries for: $RELEASE_TAG" + chmod +x scripts/build-release.sh + ./scripts/build-release.sh "$RELEASE_TAG" + - name: Upload binaries to release run: | RELEASE_TAG="${GITHUB_REF#refs/tags/}" echo "Creating release for tag: $RELEASE_TAG" - # Create release with the binary + # Create release with all binaries and checksums gh release create "$RELEASE_TAG" \ --title "$RELEASE_TAG" \ --generate-notes \ - ./awmg + dist/* - echo "✓ Release created with binary" + echo "✓ Release created with all platform binaries and checksums" env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Get release ID diff --git a/.github/workflows/release.md b/.github/workflows/release.md index 029bcf98..19023850 100644 --- a/.github/workflows/release.md +++ b/.github/workflows/release.md @@ -60,22 +60,26 @@ jobs: run: make test - name: Build binary - run: make build + run: | + RELEASE_TAG="${GITHUB_REF#refs/tags/}" + echo "Building multi-platform binaries for: $RELEASE_TAG" + chmod +x scripts/build-release.sh + ./scripts/build-release.sh "$RELEASE_TAG" - - name: Create release + - name: Upload binaries to release env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | RELEASE_TAG="${GITHUB_REF#refs/tags/}" echo "Creating release for tag: $RELEASE_TAG" - # Create release with the binary + # Create release with all binaries and checksums gh release create "$RELEASE_TAG" \ --title "$RELEASE_TAG" \ --generate-notes \ - ./awmg + dist/* - echo "✓ Release created with binary" + echo "✓ Release created with all platform binaries and checksums" - name: Get release ID id: get_release diff --git a/internal/cmd/root.go b/internal/cmd/root.go index ee6a30a6..b82b95f2 100644 --- a/internal/cmd/root.go +++ b/internal/cmd/root.go @@ -26,11 +26,13 @@ var ( envFile string enableDIFC bool debugLog = logger.New("cmd:root") + version = "dev" // Default version, overridden by SetVersion ) var rootCmd = &cobra.Command{ - Use: "awmg", - Short: "MCPG MCP proxy server", + Use: "awmg", + Short: "MCPG MCP proxy server", + Version: version, Long: `MCPG is a proxy server for Model Context Protocol (MCP) servers. It provides routing, aggregation, and management of multiple MCP backend servers.`, RunE: run, @@ -193,3 +195,9 @@ func Execute() { os.Exit(1) } } + +// SetVersion sets the version string for the CLI +func SetVersion(v string) { + version = v + rootCmd.Version = v +} diff --git a/main.go b/main.go index 7bb6f6a3..8a6c9101 100644 --- a/main.go +++ b/main.go @@ -3,5 +3,6 @@ package main import "github.com/githubnext/gh-aw-mcpg/internal/cmd" func main() { + cmd.SetVersion(Version) cmd.Execute() } diff --git a/scripts/build-release.sh b/scripts/build-release.sh new file mode 100755 index 00000000..a77be2c7 --- /dev/null +++ b/scripts/build-release.sh @@ -0,0 +1,78 @@ +#!/bin/bash +# Custom build script for multi-platform builds of awmg +# This script is called during the release process to build binaries for all platforms +set -e + +VERSION="$1" + +if [ -z "$VERSION" ]; then + echo "error: VERSION argument is required" >&2 + exit 1 +fi + +platforms=( + darwin-amd64 + darwin-arm64 + freebsd-386 + freebsd-amd64 + freebsd-arm64 + linux-386 + linux-amd64 + linux-arm + linux-arm64 + windows-386 + windows-amd64 + windows-arm64 +) + +echo "Building binaries with version: $VERSION" + +# Create dist directory if it doesn't exist +mkdir -p dist + +IFS=$'\n' read -d '' -r -a supported_platforms < <(go tool dist list) || true + +for p in "${platforms[@]}"; do + goos="${p%-*}" + goarch="${p#*-}" + + # Check if platform is supported + if [[ " ${supported_platforms[*]} " != *" ${goos}/${goarch} "* ]]; then + echo "warning: skipping unsupported platform $p" >&2 + continue + fi + + ext="" + if [ "$goos" = "windows" ]; then + ext=".exe" + fi + + echo "Building awmg for $p..." + GOOS="$goos" GOARCH="$goarch" go build \ + -trimpath \ + -ldflags="-s -w -X main.Version=${VERSION}" \ + -o "dist/awmg-${p}${ext}" \ + . + +done + +echo "Build complete. Binaries:" +ls -lh dist/ + +# Generate checksums file +echo "" +echo "Generating checksums..." +cd dist +# Use sha256sum if available (Linux), otherwise use shasum (macOS) +if command -v sha256sum &> /dev/null; then + sha256sum * > checksums.txt +elif command -v shasum &> /dev/null; then + shasum -a 256 * > checksums.txt +else + echo "error: neither sha256sum nor shasum is available" >&2 + exit 1 +fi +cd .. + +echo "Checksums generated:" +cat dist/checksums.txt diff --git a/version.go b/version.go new file mode 100644 index 00000000..91da8bc0 --- /dev/null +++ b/version.go @@ -0,0 +1,8 @@ +package main + +// Build-time variables set during release builds +var ( + // Version is the semantic version of the binary (e.g., "v1.0.0") + // Set via -ldflags "-X main.Version=" during build + Version = "dev" +)