Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
154 changes: 121 additions & 33 deletions .github/workflows/pr-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,66 +8,154 @@ jobs:
build:
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
go-version: ["1.22", "1.23.10"]
include:
- os: ubuntu-latest
goos: linux
goarch: amd64
cgo: "0"
name: mcpproxy-linux-amd64
archive_format: tar.gz
- os: ubuntu-latest
goos: windows
goarch: amd64
cgo: "0"
name: mcpproxy-windows-amd64.exe
archive_format: zip
- os: macos-latest
goos: darwin
goarch: amd64
cgo: "1"
name: mcpproxy-darwin-amd64
archive_format: tar.gz
- os: macos-latest
goos: darwin
goarch: arm64
cgo: "1"
name: mcpproxy-darwin-arm64
archive_format: tar.gz

runs-on: ${{ matrix.os }}

env:
GO111MODULE: "on"

steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go-version }}
go-version: "1.23.10"

- 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') }}
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-${{ matrix.go-version }}-
${{ runner.os }}-go-

- name: Download dependencies
run: go mod download

- name: Run tests (with nogui for CI)
run: go test -tags nogui -v ./...

- name: Build binary for Linux
if: runner.os == 'Linux'
- name: Generate PR version
id: version
shell: bash
run: |
VERSION=pr-${{ github.event.number }}-${{ github.sha }}
CGO_ENABLED=0 go build -ldflags "-X main.version=${VERSION}" -o mcpproxy ./cmd/mcpproxy
# 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 PR version: ${VERSION}"

- name: Build binary for macOS
if: runner.os == 'macOS'
shell: bash
- name: Build binary and create archives
env:
CGO_ENABLED: ${{ matrix.cgo }}
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
run: |
VERSION=pr-${{ github.event.number }}-${{ github.sha }}
go build -ldflags "-X main.version=${VERSION}" -o mcpproxy ./cmd/mcpproxy
VERSION=${{ steps.version.outputs.version }}
LDFLAGS="-s -w -X mcpproxy-go/cmd/mcpproxy.version=${VERSION} -X main.version=${VERSION}"

- name: Build binary for Windows
if: runner.os == 'Windows'
shell: bash
run: |
VERSION=pr-${{ github.event.number }}-${{ github.sha }}
CGO_ENABLED=0 go build -ldflags "-X main.version=${VERSION}" -o mcpproxy.exe ./cmd/mcpproxy
# Determine clean binary name
if [ "${{ matrix.goos }}" = "windows" ]; then
CLEAN_BINARY="mcpproxy.exe"
else
CLEAN_BINARY="mcpproxy"
fi

- name: Test version output
shell: bash
run: |
if [[ "${{ runner.os }}" == "Windows" ]]; then
./mcpproxy.exe --version
# Create clean binary for archive
go build -ldflags "${LDFLAGS}" -o ${CLEAN_BINARY} ./cmd/mcpproxy

# Ad-hoc sign macOS binaries (development only)
if [ "${{ matrix.goos }}" = "darwin" ]; then
echo "Ad-hoc signing macOS binary for development..."
codesign --force --deep --sign - --identifier "com.smartmcpproxy.mcpproxy.dev" ${CLEAN_BINARY}

# Verify signing
codesign --verify --verbose ${CLEAN_BINARY}
echo "Binary signed successfully (development)"
fi

# Create archive with version info
ARCHIVE_BASE="mcpproxy-${VERSION#v}-${{ matrix.goos }}-${{ matrix.goarch }}"

if [ "${{ matrix.archive_format }}" = "zip" ]; then
# Create archive
zip "${ARCHIVE_BASE}.zip" ${CLEAN_BINARY}
else
./mcpproxy --version
# Create archive
tar -czf "${ARCHIVE_BASE}.tar.gz" ${CLEAN_BINARY}
fi

- name: Create .icns icon (macOS)
if: matrix.goos == 'darwin'
run: |
chmod +x scripts/create-icns.sh
./scripts/create-icns.sh

- name: Create DMG installer (macOS)
if: matrix.goos == 'darwin'
run: |
VERSION=${{ steps.version.outputs.version }}
chmod +x scripts/create-dmg.sh

# Determine binary name
CLEAN_BINARY="mcpproxy"

# Create DMG
./scripts/create-dmg.sh ${CLEAN_BINARY} ${VERSION} ${{ matrix.goarch }}

# Ad-hoc sign DMG (development only)
DMG_NAME="mcpproxy-${VERSION#v}-darwin-${{ matrix.goarch }}.dmg"
echo "Ad-hoc signing DMG for development: ${DMG_NAME}"
codesign --force --deep --sign - "${DMG_NAME}"

echo "DMG created and signed (development): ${DMG_NAME}"

- name: Skip notarization (PR Build)
if: matrix.goos == 'darwin'
run: |
echo "Skipping notarization for PR build - this is a development build"
echo "Production builds go through full notarization in release workflow"

- name: Upload archive artifact
uses: actions/upload-artifact@v4
with:
name: archive-${{ matrix.goos }}-${{ matrix.goarch }}
path: mcpproxy-*-${{ matrix.goos }}-${{ matrix.goarch }}.${{ matrix.archive_format }}
retention-days: 7

- name: Upload DMG installer (macOS)
if: matrix.goos == 'darwin'
uses: actions/upload-artifact@v4
with:
name: dmg-${{ matrix.goos }}-${{ matrix.goarch }}
path: mcpproxy-*-darwin-${{ matrix.goarch }}.dmg
retention-days: 7
80 changes: 79 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,13 @@ jobs:
- name: Download dependencies
run: go mod download

- name: Import Code-Signing Certificates (macOS)
if: matrix.goos == 'darwin'
uses: Apple-Actions/import-codesign-certs@v3
with:
p12-file-base64: ${{ secrets.APPLE_DEVELOPER_ID_CERT }}
p12-password: ${{ secrets.APPLE_DEVELOPER_ID_CERT_PASSWORD }}

- name: Build binary and create archives
env:
CGO_ENABLED: ${{ matrix.cgo }}
Expand All @@ -80,6 +87,16 @@ jobs:
# Create clean binary for archive
go build -ldflags "${LDFLAGS}" -o ${CLEAN_BINARY} ./cmd/mcpproxy

# Code sign macOS binaries
if [ "${{ matrix.goos }}" = "darwin" ]; then
echo "Code signing macOS binary..."
codesign --force --options runtime --entitlements scripts/entitlements.plist --sign "${{ secrets.APPLE_TEAM_ID }}" ${CLEAN_BINARY}

# Verify signing
codesign --verify --verbose ${CLEAN_BINARY}
echo "Binary signed successfully"
fi

# Create archive with version info
ARCHIVE_BASE="mcpproxy-${VERSION#v}-${{ matrix.goos }}-${{ matrix.goarch }}"
LATEST_ARCHIVE_BASE="mcpproxy-latest-${{ matrix.goos }}-${{ matrix.goarch }}"
Expand All @@ -96,6 +113,48 @@ jobs:
tar -czf "${LATEST_ARCHIVE_BASE}.tar.gz" ${CLEAN_BINARY}
fi

- name: Create .icns icon (macOS)
if: matrix.goos == 'darwin'
run: |
chmod +x scripts/create-icns.sh
./scripts/create-icns.sh

- name: Create DMG installer (macOS)
if: matrix.goos == 'darwin'
run: |
VERSION=${GITHUB_REF#refs/tags/}
chmod +x scripts/create-dmg.sh

# Determine binary name
CLEAN_BINARY="mcpproxy"

# Create DMG
./scripts/create-dmg.sh ${CLEAN_BINARY} ${VERSION} ${{ matrix.goarch }}

# Sign DMG
DMG_NAME="mcpproxy-${VERSION#v}-darwin-${{ matrix.goarch }}.dmg"
echo "Signing DMG: ${DMG_NAME}"
codesign --force --sign "${{ secrets.APPLE_TEAM_ID }}" "${DMG_NAME}"

echo "DMG created and signed: ${DMG_NAME}"

- name: Notarize macOS artifacts
if: matrix.goos == 'darwin'
run: |
VERSION=${GITHUB_REF#refs/tags/}
DMG_NAME="mcpproxy-${VERSION#v}-darwin-${{ matrix.goarch }}.dmg"

echo "Submitting DMG for notarization..."
xcrun notarytool submit "${DMG_NAME}" --apple-id "${{ secrets.APPLE_ID_USERNAME }}" --password "${{ secrets.APPLE_ID_APP_PASSWORD }}" --team-id "${{ secrets.APPLE_TEAM_ID }}" --wait

echo "Stapling notarization to DMG..."
xcrun stapler staple "${DMG_NAME}"

echo "Verifying notarization..."
xcrun stapler validate "${DMG_NAME}"

echo "DMG notarized successfully"

- name: Upload versioned archive artifact
uses: actions/upload-artifact@v4
with:
Expand All @@ -108,6 +167,13 @@ jobs:
name: latest-${{ matrix.goos }}-${{ matrix.goarch }}
path: mcpproxy-latest-${{ matrix.goos }}-${{ matrix.goarch }}.${{ matrix.archive_format }}

- name: Upload DMG installer (macOS)
if: matrix.goos == 'darwin'
uses: actions/upload-artifact@v4
with:
name: dmg-${{ matrix.goos }}-${{ matrix.goarch }}
path: mcpproxy-*-darwin-${{ matrix.goarch }}.dmg

release:
needs: build
runs-on: ubuntu-latest
Expand All @@ -127,7 +193,7 @@ jobs:
run: |
# Create a flat structure to avoid duplicates
mkdir -p release-files
find dist -name "*.tar.gz" -o -name "*.zip" | while read file; do
find dist -name "*.tar.gz" -o -name "*.zip" -o -name "*.dmg" | while read file; do
filename=$(basename "$file")
cp "$file" "release-files/$filename"
done
Expand All @@ -154,6 +220,10 @@ jobs:
- [macOS AMD64](https://github.com/${{ github.repository }}/releases/latest/download/mcpproxy-latest-darwin-amd64.tar.gz)
- [macOS ARM64](https://github.com/${{ github.repository }}/releases/latest/download/mcpproxy-latest-darwin-arm64.tar.gz)

**macOS Installers (Recommended):**
- [macOS Universal DMG](https://github.com/${{ github.repository }}/releases/download/${{ github.ref_name }}/mcpproxy-${{ github.ref_name }}-darwin-arm64.dmg) (Apple Silicon)
- [macOS Intel DMG](https://github.com/${{ github.repository }}/releases/download/${{ github.ref_name }}/mcpproxy-${{ github.ref_name }}-darwin-amd64.dmg) (Intel)

**This Version (${{ github.ref_name }}):**
- [Linux AMD64](https://github.com/${{ github.repository }}/releases/download/${{ github.ref_name }}/mcpproxy-${{ github.ref_name }}-linux-amd64.tar.gz)
- [Windows AMD64](https://github.com/${{ github.repository }}/releases/download/${{ github.ref_name }}/mcpproxy-${{ github.ref_name }}-windows-amd64.zip)
Expand All @@ -162,6 +232,14 @@ jobs:

### Installation

**macOS (Recommended - DMG Installer):**
1. Download the appropriate DMG file for your Mac (Apple Silicon or Intel)
2. Double-click the DMG to mount it
3. Drag mcpproxy.app to Applications folder
4. Launch from Applications or Launchpad
5. The app will appear in your system tray with autostart capability

**Manual Installation (All Platforms):**
1. Download the appropriate archive for your platform using the links above
2. Extract the archive: `tar -xzf mcpproxy-*.tar.gz` (Linux/macOS) or unzip (Windows)
3. Make it executable: `chmod +x mcpproxy` (Linux/macOS)
Expand Down
Loading