|
| 1 | +name: Build and Release MCP-1Panel |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + version: |
| 7 | + description: 'Release version (e.g. v1.0.0)' |
| 8 | + required: true |
| 9 | + type: string |
| 10 | + |
| 11 | +env: |
| 12 | + IMAGE_NAME: 1panel/1panel-mcp-server |
| 13 | + |
| 14 | +jobs: |
| 15 | + build: |
| 16 | + runs-on: ubuntu-latest |
| 17 | + strategy: |
| 18 | + matrix: |
| 19 | + include: |
| 20 | + - goos: linux |
| 21 | + goarch: amd64 |
| 22 | + - goos: linux |
| 23 | + goarch: arm64 |
| 24 | + - goos: linux |
| 25 | + goarch: arm |
| 26 | + goarm: 7 |
| 27 | + - goos: linux |
| 28 | + goarch: s390x |
| 29 | + - goos: linux |
| 30 | + goarch: ppc64le |
| 31 | + |
| 32 | + name: Build for ${{ matrix.goos }}-${{ matrix.goarch }} |
| 33 | + steps: |
| 34 | + - name: Checkout code |
| 35 | + uses: actions/checkout@v4 |
| 36 | + |
| 37 | + - name: Set up Go |
| 38 | + uses: actions/setup-go@v5 |
| 39 | + with: |
| 40 | + go-version: '1.23' |
| 41 | + |
| 42 | + - name: Build Binary |
| 43 | + run: | |
| 44 | + mkdir -p build |
| 45 | + FILE_NAME=mcp-1panel-${{ matrix.goos }}-${{ matrix.goarch }} |
| 46 | + if [ "${{ matrix.goarch }}" = "arm" ]; then |
| 47 | + FILE_NAME="${FILE_NAME}v${{ matrix.goarm }}" |
| 48 | + fi |
| 49 | + CGO_ENABLED=0 GOOS=${{ matrix.goos }} GOARCH=${{ matrix.goarch }} GOARM=${{ matrix.goarm || '' }} \ |
| 50 | + go build -trimpath -ldflags '-s -w' -o build/${FILE_NAME} ./main.go |
| 51 | + chmod +x build/${FILE_NAME} |
| 52 | +
|
| 53 | + - name: Upload binary artifact |
| 54 | + uses: actions/upload-artifact@v4 |
| 55 | + with: |
| 56 | + name: ${{ matrix.goos }}-${{ matrix.goarch }}-${{ matrix.goarm || 'default' }} |
| 57 | + path: build/* |
| 58 | + |
| 59 | + release: |
| 60 | + needs: build |
| 61 | + runs-on: ubuntu-latest |
| 62 | + name: Create GitHub Release |
| 63 | + steps: |
| 64 | + - name: Download all binary artifacts |
| 65 | + uses: actions/download-artifact@v4 |
| 66 | + with: |
| 67 | + path: ./release-assets |
| 68 | + |
| 69 | + - name: Move all binaries to one folder |
| 70 | + run: | |
| 71 | + mkdir -p final-release |
| 72 | + find ./release-assets -type f -exec mv {} final-release/ \; |
| 73 | +
|
| 74 | + - name: List final files |
| 75 | + run: ls -lh final-release |
| 76 | + |
| 77 | + - name: Create GitHub Release Draft |
| 78 | + uses: softprops/action-gh-release@v2 |
| 79 | + with: |
| 80 | + tag_name: ${{ github.event.inputs.version }} |
| 81 | + name: ${{ github.event.inputs.version }} |
| 82 | + draft: true |
| 83 | + files: final-release/* |
| 84 | + |
| 85 | + docker: |
| 86 | + needs: build |
| 87 | + runs-on: ubuntu-latest |
| 88 | + name: Build and Push Docker Image |
| 89 | + steps: |
| 90 | + - name: Checkout Code |
| 91 | + uses: actions/checkout@v4 |
| 92 | + |
| 93 | + - name: Set up QEMU |
| 94 | + uses: docker/setup-qemu-action@v3 |
| 95 | + with: |
| 96 | + platforms: all |
| 97 | + |
| 98 | + - name: Set up Docker Buildx |
| 99 | + uses: docker/setup-buildx-action@v3 |
| 100 | + id: buildx |
| 101 | + |
| 102 | + - name: Login to Docker Hub |
| 103 | + uses: docker/login-action@v3 |
| 104 | + with: |
| 105 | + username: ${{ secrets.DOCKER_USERNAME }} |
| 106 | + password: ${{ secrets.DOCKER_PASSWORD }} |
| 107 | + |
| 108 | + - name: Build and Push Docker Image |
| 109 | + uses: docker/build-push-action@v5 |
| 110 | + with: |
| 111 | + context: . |
| 112 | + platforms: linux/amd64,linux/arm64,linux/arm/v7,linux/s390x,linux/ppc64le |
| 113 | + push: true |
| 114 | + tags: | |
| 115 | + ${{ env.IMAGE_NAME }}:latest |
| 116 | + ${{ env.IMAGE_NAME }}:${{ github.event.inputs.version }} |
0 commit comments