-
Notifications
You must be signed in to change notification settings - Fork 37
161 lines (136 loc) · 5.03 KB
/
Copy pathpr-build.yml
File metadata and controls
161 lines (136 loc) · 5.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
name: PR Build
on:
pull_request:
branches: [main, develop]
jobs:
build:
strategy:
matrix:
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 }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: "1.23.10"
- name: Cache Go modules
uses: actions/cache@v4
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Download dependencies
run: go mod download
- name: Run tests (with nogui for CI)
run: go test -tags nogui -v ./...
- name: Generate PR 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 PR version: ${VERSION}"
- name: Build binary and create archives
env:
CGO_ENABLED: ${{ matrix.cgo }}
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
run: |
VERSION=${{ steps.version.outputs.version }}
LDFLAGS="-s -w -X mcpproxy-go/cmd/mcpproxy.version=${VERSION} -X main.version=${VERSION}"
# Determine clean binary name
if [ "${{ matrix.goos }}" = "windows" ]; then
CLEAN_BINARY="mcpproxy.exe"
else
CLEAN_BINARY="mcpproxy"
fi
# 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
# 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