|
| 1 | +name: Build and Release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - 'v*' # Trigger on version tags like v1.0.0, v2.1.3, etc. |
| 7 | + workflow_dispatch: # Allow manual trigger |
| 8 | + |
| 9 | +permissions: |
| 10 | + contents: write |
| 11 | + |
| 12 | +jobs: |
| 13 | + build: |
| 14 | + name: Build Binaries |
| 15 | + runs-on: ${{ matrix.os }} |
| 16 | + strategy: |
| 17 | + matrix: |
| 18 | + include: |
| 19 | + # Linux builds |
| 20 | + - os: ubuntu-latest |
| 21 | + goos: linux |
| 22 | + goarch: amd64 |
| 23 | + binary_suffix: '' |
| 24 | + - os: ubuntu-latest |
| 25 | + goos: linux |
| 26 | + goarch: arm64 |
| 27 | + binary_suffix: '' |
| 28 | + |
| 29 | + # macOS builds |
| 30 | + - os: macos-latest |
| 31 | + goos: darwin |
| 32 | + goarch: amd64 |
| 33 | + binary_suffix: '' |
| 34 | + - os: macos-latest |
| 35 | + goos: darwin |
| 36 | + goarch: arm64 |
| 37 | + binary_suffix: '' |
| 38 | + |
| 39 | + # Windows builds |
| 40 | + - os: ubuntu-latest |
| 41 | + goos: windows |
| 42 | + goarch: amd64 |
| 43 | + binary_suffix: '.exe' |
| 44 | + - os: ubuntu-latest |
| 45 | + goos: windows |
| 46 | + goarch: arm64 |
| 47 | + binary_suffix: '.exe' |
| 48 | + |
| 49 | + steps: |
| 50 | + - name: Checkout code |
| 51 | + uses: actions/checkout@v4 |
| 52 | + |
| 53 | + - name: Set up Go |
| 54 | + uses: actions/setup-go@v5 |
| 55 | + with: |
| 56 | + go-version: '1.21' |
| 57 | + |
| 58 | + - name: Get version from tag |
| 59 | + id: get_version |
| 60 | + run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT |
| 61 | + |
| 62 | + - name: Build binary |
| 63 | + env: |
| 64 | + GOOS: ${{ matrix.goos }} |
| 65 | + GOARCH: ${{ matrix.goarch }} |
| 66 | + CGO_ENABLED: 0 |
| 67 | + run: | |
| 68 | + BINARY_NAME="mcp-code-api-${{ matrix.goos }}-${{ matrix.goarch }}${{ matrix.binary_suffix }}" |
| 69 | + go build -v -ldflags="-s -w -X 'main.Version=${{ steps.get_version.outputs.VERSION }}' -X 'main.Commit=${{ github.sha }}' -X 'main.BuildTime=$(date -u +%Y-%m-%dT%H:%M:%SZ)'" -o "$BINARY_NAME" . |
| 70 | +
|
| 71 | + # Create checksum |
| 72 | + if [ "${{ matrix.goos }}" = "windows" ]; then |
| 73 | + sha256sum "$BINARY_NAME" > "$BINARY_NAME.sha256" |
| 74 | + else |
| 75 | + shasum -a 256 "$BINARY_NAME" > "$BINARY_NAME.sha256" |
| 76 | + fi |
| 77 | +
|
| 78 | + ls -lh "$BINARY_NAME" |
| 79 | +
|
| 80 | + - name: Upload artifact |
| 81 | + uses: actions/upload-artifact@v4 |
| 82 | + with: |
| 83 | + name: mcp-code-api-${{ matrix.goos }}-${{ matrix.goarch }} |
| 84 | + path: | |
| 85 | + mcp-code-api-${{ matrix.goos }}-${{ matrix.goarch }}${{ matrix.binary_suffix }} |
| 86 | + mcp-code-api-${{ matrix.goos }}-${{ matrix.goarch }}${{ matrix.binary_suffix }}.sha256 |
| 87 | + retention-days: 7 |
| 88 | + |
| 89 | + release: |
| 90 | + name: Create Release |
| 91 | + needs: build |
| 92 | + runs-on: ubuntu-latest |
| 93 | + |
| 94 | + steps: |
| 95 | + - name: Checkout code |
| 96 | + uses: actions/checkout@v4 |
| 97 | + |
| 98 | + - name: Get version from tag |
| 99 | + id: get_version |
| 100 | + run: | |
| 101 | + echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT |
| 102 | + echo "VERSION_NUM=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT |
| 103 | +
|
| 104 | + - name: Download all artifacts |
| 105 | + uses: actions/download-artifact@v4 |
| 106 | + with: |
| 107 | + path: ./artifacts |
| 108 | + |
| 109 | + - name: Prepare release assets |
| 110 | + run: | |
| 111 | + mkdir -p release |
| 112 | + find ./artifacts -type f -exec mv {} ./release/ \; |
| 113 | + ls -lh ./release/ |
| 114 | +
|
| 115 | + # Create a combined checksums file |
| 116 | + cd release |
| 117 | + cat *.sha256 > SHA256SUMS.txt |
| 118 | + cd .. |
| 119 | +
|
| 120 | + - name: Generate release notes |
| 121 | + id: generate_notes |
| 122 | + run: | |
| 123 | + cat > release_notes.md << 'EOF' |
| 124 | + ## MCP Code API ${{ steps.get_version.outputs.VERSION }} |
| 125 | +
|
| 126 | + ### 📦 Installation |
| 127 | +
|
| 128 | + Download the binary for your platform and architecture: |
| 129 | +
|
| 130 | + **Linux:** |
| 131 | + ```bash |
| 132 | + # AMD64 |
| 133 | + curl -L https://github.com/cecil-the-coder/mcp-code-api/releases/download/${{ steps.get_version.outputs.VERSION }}/mcp-code-api-linux-amd64 -o mcp-code-api |
| 134 | + chmod +x mcp-code-api |
| 135 | + sudo mv mcp-code-api /usr/local/bin/ |
| 136 | +
|
| 137 | + # ARM64 |
| 138 | + curl -L https://github.com/cecil-the-coder/mcp-code-api/releases/download/${{ steps.get_version.outputs.VERSION }}/mcp-code-api-linux-arm64 -o mcp-code-api |
| 139 | + chmod +x mcp-code-api |
| 140 | + sudo mv mcp-code-api /usr/local/bin/ |
| 141 | + ``` |
| 142 | +
|
| 143 | + **macOS:** |
| 144 | + ```bash |
| 145 | + # Intel (AMD64) |
| 146 | + curl -L https://github.com/cecil-the-coder/mcp-code-api/releases/download/${{ steps.get_version.outputs.VERSION }}/mcp-code-api-darwin-amd64 -o mcp-code-api |
| 147 | + chmod +x mcp-code-api |
| 148 | + sudo mv mcp-code-api /usr/local/bin/ |
| 149 | +
|
| 150 | + # Apple Silicon (ARM64) |
| 151 | + curl -L https://github.com/cecil-the-coder/mcp-code-api/releases/download/${{ steps.get_version.outputs.VERSION }}/mcp-code-api-darwin-arm64 -o mcp-code-api |
| 152 | + chmod +x mcp-code-api |
| 153 | + sudo mv mcp-code-api /usr/local/bin/ |
| 154 | + ``` |
| 155 | +
|
| 156 | + **Windows:** |
| 157 | + ```powershell |
| 158 | + # AMD64 |
| 159 | + Invoke-WebRequest -Uri "https://github.com/cecil-the-coder/mcp-code-api/releases/download/${{ steps.get_version.outputs.VERSION }}/mcp-code-api-windows-amd64.exe" -OutFile "mcp-code-api.exe" |
| 160 | +
|
| 161 | + # ARM64 |
| 162 | + Invoke-WebRequest -Uri "https://github.com/cecil-the-coder/mcp-code-api/releases/download/${{ steps.get_version.outputs.VERSION }}/mcp-code-api-windows-arm64.exe" -OutFile "mcp-code-api.exe" |
| 163 | + ``` |
| 164 | +
|
| 165 | + ### ✅ Verify Installation |
| 166 | +
|
| 167 | + ```bash |
| 168 | + mcp-code-api --version |
| 169 | + ``` |
| 170 | +
|
| 171 | + ### 🔒 Verify Checksums |
| 172 | +
|
| 173 | + Download `SHA256SUMS.txt` and verify: |
| 174 | +
|
| 175 | + ```bash |
| 176 | + # Linux/macOS |
| 177 | + sha256sum -c SHA256SUMS.txt |
| 178 | +
|
| 179 | + # Or verify individual file |
| 180 | + sha256sum mcp-code-api-linux-amd64 |
| 181 | + cat mcp-code-api-linux-amd64.sha256 |
| 182 | + ``` |
| 183 | +
|
| 184 | + ### 📋 Supported Platforms |
| 185 | +
|
| 186 | + - **Linux**: AMD64, ARM64 |
| 187 | + - **macOS**: AMD64 (Intel), ARM64 (Apple Silicon) |
| 188 | + - **Windows**: AMD64, ARM64 |
| 189 | +
|
| 190 | + ### 🚀 Quick Start |
| 191 | +
|
| 192 | + ```bash |
| 193 | + # Run configuration wizard |
| 194 | + mcp-code-api config |
| 195 | +
|
| 196 | + # Start the server |
| 197 | + mcp-code-api server |
| 198 | + ``` |
| 199 | +
|
| 200 | + For detailed documentation, see the [README](https://github.com/cecil-the-coder/mcp-code-api#readme). |
| 201 | + EOF |
| 202 | +
|
| 203 | + - name: Create Release |
| 204 | + uses: softprops/action-gh-release@v1 |
| 205 | + with: |
| 206 | + name: Release ${{ steps.get_version.outputs.VERSION }} |
| 207 | + body_path: release_notes.md |
| 208 | + files: | |
| 209 | + release/* |
| 210 | + draft: false |
| 211 | + prerelease: false |
| 212 | + generate_release_notes: true |
| 213 | + env: |
| 214 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 215 | + |
| 216 | + - name: Release Summary |
| 217 | + run: | |
| 218 | + echo "## 🎉 Release ${{ steps.get_version.outputs.VERSION }} Created!" >> $GITHUB_STEP_SUMMARY |
| 219 | + echo "" >> $GITHUB_STEP_SUMMARY |
| 220 | + echo "### 📦 Binaries Built:" >> $GITHUB_STEP_SUMMARY |
| 221 | + echo "" >> $GITHUB_STEP_SUMMARY |
| 222 | + ls -lh release/ | grep -v "^total" | awk '{print "- " $9 " (" $5 ")"}' >> $GITHUB_STEP_SUMMARY |
| 223 | + echo "" >> $GITHUB_STEP_SUMMARY |
| 224 | + echo "### 🔗 Download:" >> $GITHUB_STEP_SUMMARY |
| 225 | + echo "https://github.com/cecil-the-coder/mcp-code-api/releases/tag/${{ steps.get_version.outputs.VERSION }}" >> $GITHUB_STEP_SUMMARY |
0 commit comments