|
| 1 | +name: Build and Push MCP DataFlow Server |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + paths: |
| 8 | + - 'mcp-dataflow/**' |
| 9 | + - '.github/workflows/mcp-dataflow.yml' |
| 10 | + tags: |
| 11 | + - 'mcp-v*' |
| 12 | + pull_request: |
| 13 | + branches: |
| 14 | + - main |
| 15 | + paths: |
| 16 | + - 'mcp-dataflow/**' |
| 17 | + - '.github/workflows/mcp-dataflow.yml' |
| 18 | + workflow_dispatch: |
| 19 | + |
| 20 | +env: |
| 21 | + REGISTRY: ghcr.io |
| 22 | + IMAGE_NAME: ilyario/mcp-dataflow |
| 23 | + GO_VERSION: '1.21' |
| 24 | + |
| 25 | +jobs: |
| 26 | + test: |
| 27 | + runs-on: ubuntu-latest |
| 28 | + steps: |
| 29 | + - name: Checkout repository |
| 30 | + uses: actions/checkout@v4 |
| 31 | + |
| 32 | + - name: Set up Go |
| 33 | + uses: actions/setup-go@v5 |
| 34 | + with: |
| 35 | + go-version: ${{ env.GO_VERSION }} |
| 36 | + |
| 37 | + - name: Install Task |
| 38 | + uses: arduino/setup-task@v1 |
| 39 | + with: |
| 40 | + version: 3.x |
| 41 | + |
| 42 | + - name: Download dependencies |
| 43 | + working-directory: ./mcp-dataflow |
| 44 | + run: task deps |
| 45 | + |
| 46 | + - name: Run tests |
| 47 | + working-directory: ./mcp-dataflow |
| 48 | + run: task test |
| 49 | + |
| 50 | + - name: Run linter |
| 51 | + working-directory: ./mcp-dataflow |
| 52 | + run: task lint || true |
| 53 | + |
| 54 | + build-binaries: |
| 55 | + runs-on: ubuntu-latest |
| 56 | + strategy: |
| 57 | + matrix: |
| 58 | + goos: [linux, darwin, windows] |
| 59 | + goarch: [amd64, arm64] |
| 60 | + exclude: |
| 61 | + - goos: windows |
| 62 | + goarch: arm64 |
| 63 | + steps: |
| 64 | + - name: Checkout repository |
| 65 | + uses: actions/checkout@v4 |
| 66 | + |
| 67 | + - name: Set up Go |
| 68 | + uses: actions/setup-go@v5 |
| 69 | + with: |
| 70 | + go-version: ${{ env.GO_VERSION }} |
| 71 | + |
| 72 | + - name: Install Task |
| 73 | + uses: arduino/setup-task@v1 |
| 74 | + with: |
| 75 | + version: 3.x |
| 76 | + |
| 77 | + - name: Download dependencies |
| 78 | + working-directory: ./mcp-dataflow |
| 79 | + run: task deps |
| 80 | + |
| 81 | + - name: Build binary |
| 82 | + working-directory: ./mcp-dataflow |
| 83 | + env: |
| 84 | + GOOS: ${{ matrix.goos }} |
| 85 | + GOARCH: ${{ matrix.goarch }} |
| 86 | + run: | |
| 87 | + OUTPUT="dist/mcp-dataflow-${GOOS}-${GOARCH}" |
| 88 | + if [ "$GOOS" = "windows" ]; then |
| 89 | + OUTPUT="${OUTPUT}.exe" |
| 90 | + fi |
| 91 | + CGO_ENABLED=0 GOOS=${GOOS} GOARCH=${GOARCH} go build -a -installsuffix cgo -o ${OUTPUT} cmd/server/main.go |
| 92 | +
|
| 93 | + - name: Upload binaries |
| 94 | + uses: actions/upload-artifact@v4 |
| 95 | + with: |
| 96 | + name: binaries-${{ matrix.goos }}-${{ matrix.goarch }} |
| 97 | + path: mcp-dataflow/dist/mcp-dataflow-${{ matrix.goos }}-${{ matrix.goarch }}* |
| 98 | + |
| 99 | + build-and-push: |
| 100 | + runs-on: ubuntu-latest |
| 101 | + needs: [test] |
| 102 | + permissions: |
| 103 | + contents: read |
| 104 | + packages: write |
| 105 | + |
| 106 | + steps: |
| 107 | + - name: Checkout repository |
| 108 | + uses: actions/checkout@v4 |
| 109 | + with: |
| 110 | + fetch-depth: 0 |
| 111 | + |
| 112 | + - name: Set up Docker Buildx |
| 113 | + uses: docker/setup-buildx-action@v3 |
| 114 | + |
| 115 | + - name: Log in to Container Registry |
| 116 | + uses: docker/login-action@v3 |
| 117 | + with: |
| 118 | + registry: ${{ env.REGISTRY }} |
| 119 | + username: ${{ github.actor }} |
| 120 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 121 | + |
| 122 | + - name: Extract metadata (tags, labels) for Docker |
| 123 | + id: meta |
| 124 | + uses: docker/metadata-action@v5 |
| 125 | + with: |
| 126 | + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} |
| 127 | + tags: | |
| 128 | + type=ref,event=branch |
| 129 | + type=ref,event=pr |
| 130 | + type=semver,pattern={{version}} |
| 131 | + type=semver,pattern={{major}}.{{minor}} |
| 132 | + type=semver,pattern={{major}} |
| 133 | + type=sha,prefix={{branch}}- |
| 134 | + type=raw,value=latest,enable={{is_default_branch}} |
| 135 | + type=raw,value=mcp-latest,enable={{is_default_branch}} |
| 136 | +
|
| 137 | + - name: Build and push Docker image |
| 138 | + uses: docker/build-push-action@v5 |
| 139 | + with: |
| 140 | + context: ./mcp-dataflow |
| 141 | + file: ./mcp-dataflow/Dockerfile |
| 142 | + push: ${{ github.event_name != 'pull_request' }} |
| 143 | + tags: ${{ steps.meta.outputs.tags }} |
| 144 | + labels: ${{ steps.meta.outputs.labels }} |
| 145 | + cache-from: type=gha |
| 146 | + cache-to: type=gha,mode=max |
| 147 | + |
| 148 | + create-release: |
| 149 | + needs: [build-binaries, build-and-push] |
| 150 | + runs-on: ubuntu-latest |
| 151 | + if: startsWith(github.ref, 'refs/tags/mcp-v') |
| 152 | + permissions: |
| 153 | + contents: write |
| 154 | + |
| 155 | + steps: |
| 156 | + - name: Checkout repository |
| 157 | + uses: actions/checkout@v4 |
| 158 | + with: |
| 159 | + fetch-depth: 0 |
| 160 | + |
| 161 | + - name: Get tag name |
| 162 | + id: tag |
| 163 | + run: echo "TAG_NAME=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT |
| 164 | + |
| 165 | + - name: Download all artifacts |
| 166 | + uses: actions/download-artifact@v4 |
| 167 | + with: |
| 168 | + path: dist |
| 169 | + |
| 170 | + - name: Prepare release assets |
| 171 | + run: | |
| 172 | + mkdir -p release-assets |
| 173 | + find dist -type f -executable -o -name "*.exe" | while read file; do |
| 174 | + cp "$file" release-assets/ |
| 175 | + done |
| 176 | +
|
| 177 | + - name: Generate release notes |
| 178 | + id: release_notes |
| 179 | + run: | |
| 180 | + PREVIOUS_TAG=$(git describe --tags --abbrev=0 HEAD^ 2>/dev/null || echo "") |
| 181 | + if [ -z "$PREVIOUS_TAG" ]; then |
| 182 | + NOTES=$(git log --pretty=format:"- %s (%h)" --no-merges) |
| 183 | + else |
| 184 | + NOTES=$(git log ${PREVIOUS_TAG}..HEAD --pretty=format:"- %s (%h)" --no-merges) |
| 185 | + fi |
| 186 | + echo "notes<<EOF" >> $GITHUB_OUTPUT |
| 187 | + echo "$NOTES" >> $GITHUB_OUTPUT |
| 188 | + echo "EOF" >> $GITHUB_OUTPUT |
| 189 | +
|
| 190 | + - name: Create Release |
| 191 | + uses: softprops/action-gh-release@v2 |
| 192 | + with: |
| 193 | + tag_name: ${{ steps.tag.outputs.TAG_NAME }} |
| 194 | + name: MCP DataFlow Server ${{ steps.tag.outputs.TAG_NAME }} |
| 195 | + body: | |
| 196 | + ## Что нового в ${{ steps.tag.outputs.TAG_NAME }} |
| 197 | +
|
| 198 | + ${{ steps.release_notes.outputs.notes }} |
| 199 | +
|
| 200 | + ## Docker образ |
| 201 | +
|
| 202 | + Docker образ доступен по адресу: |
| 203 | + ``` |
| 204 | + ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.tag.outputs.TAG_NAME }} |
| 205 | + ``` |
| 206 | +
|
| 207 | + ## Установка |
| 208 | +
|
| 209 | + ### Docker |
| 210 | + ```bash |
| 211 | + docker pull ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.tag.outputs.TAG_NAME }} |
| 212 | + ``` |
| 213 | +
|
| 214 | + ### Бинарник |
| 215 | +
|
| 216 | + Скачайте бинарник для вашей платформы из раздела Assets ниже. |
| 217 | + files: release-assets/* |
| 218 | + draft: false |
| 219 | + prerelease: false |
| 220 | + generate_release_notes: true |
0 commit comments