Skip to content

Enhance macOS support in GitHub Actions workflow and add autostart functionality #28

Enhance macOS support in GitHub Actions workflow and add autostart functionality

Enhance macOS support in GitHub Actions workflow and add autostart functionality #28

Workflow file for this run

name: PR Build
on:
pull_request:
branches: [main, develop]
jobs:
build:
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
go-version: ["1.22", "1.23.10"]
runs-on: ${{ matrix.os }}
env:
GO111MODULE: "on"
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0 # Need full history for git describe
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go-version }}
- name: Cache Go modules
uses: actions/cache@v4
with:
path: |
~/.cache/go-build
~/go/pkg/mod
~/AppData/Local/go-build
key: ${{ runner.os }}-go-${{ matrix.go-version }}-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-${{ matrix.go-version }}-
- name: Download dependencies
run: go mod download
- name: Run tests (with nogui for CI)
run: go test -tags nogui -v ./...
- name: Generate version
id: version
shell: bash
run: |
# Get the latest tag
LATEST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "v0.0.0")
# Get short commit hash
COMMIT_HASH=$(git rev-parse --short HEAD)
# Create version: last-tag-dev-hash
VERSION="${LATEST_TAG}-dev-${COMMIT_HASH}"
echo "version=${VERSION}" >> $GITHUB_OUTPUT
echo "Generated version: ${VERSION}"
- name: Build binary for Linux
if: runner.os == 'Linux'
shell: bash
run: |
CGO_ENABLED=0 go build -ldflags "-X main.version=${{ steps.version.outputs.version }}" -o mcpproxy ./cmd/mcpproxy
- name: Build binary for macOS
if: runner.os == 'macOS'
shell: bash
run: |
go build -ldflags "-X main.version=${{ steps.version.outputs.version }}" -o mcpproxy ./cmd/mcpproxy
- name: Build binary for Windows
if: runner.os == 'Windows'
shell: bash
run: |
CGO_ENABLED=0 go build -ldflags "-X main.version=${{ steps.version.outputs.version }}" -o mcpproxy.exe ./cmd/mcpproxy
- name: Test version output
shell: bash
run: |
if [[ "${{ runner.os }}" == "Windows" ]]; then
./mcpproxy.exe --version
else
./mcpproxy --version
fi
- name: Create .icns icon (macOS)
if: runner.os == 'macOS'
run: |
chmod +x scripts/create-icns.sh
./scripts/create-icns.sh
- name: Create DMG installer (macOS)
if: runner.os == 'macOS'
run: |
chmod +x scripts/create-dmg.sh
# Determine binary name and architecture
CLEAN_BINARY="mcpproxy"
ARCH=$(uname -m)
if [ "$ARCH" = "x86_64" ]; then
ARCH="amd64"
elif [ "$ARCH" = "arm64" ]; then
ARCH="arm64"
fi
# Create DMG
./scripts/create-dmg.sh ${CLEAN_BINARY} ${{ steps.version.outputs.version }} ${ARCH}
- name: Upload DMG artifact (macOS)
if: runner.os == 'macOS'
uses: actions/upload-artifact@v4
with:
name: mcpproxy-dmg-${{ matrix.go-version }}-${{ runner.arch }}
path: mcpproxy-*-darwin-*.dmg
retention-days: 7
- name: Upload binary artifact
uses: actions/upload-artifact@v4
with:
name: mcpproxy-${{ runner.os }}-${{ matrix.go-version }}
path: |
mcpproxy*
!mcpproxy-*-darwin-*.dmg
retention-days: 7