Repository navigation
update to go 1.26 #10
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: 🚀 Release Build | |
| on: | |
| push: | |
| tags: | |
| - "v*" | |
| - "v*.*" | |
| - "v*.*.*" | |
| workflow_dispatch: | |
| inputs: | |
| tag: | |
| description: "Tag to release" | |
| required: true | |
| default: "v0.0.1" | |
| env: | |
| REGISTRY: ghcr.io | |
| IMAGE_NAME: ${{ github.repository }} | |
| jobs: | |
| # 构建多平台二进制文件 | |
| build: | |
| name: 🔨 Build Release | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| # Windows | |
| - goos: windows | |
| goarch: amd64 | |
| suffix: .exe | |
| - goos: windows | |
| goarch: arm64 | |
| suffix: .exe | |
| # Linux | |
| - goos: linux | |
| goarch: amd64 | |
| suffix: "" | |
| - goos: linux | |
| goarch: arm64 | |
| suffix: "" | |
| # macOS | |
| - goos: darwin | |
| goarch: amd64 | |
| suffix: "" | |
| - goos: darwin | |
| goarch: arm64 | |
| suffix: "" | |
| # FreeBSD | |
| - goos: freebsd | |
| goarch: amd64 | |
| suffix: "" | |
| steps: | |
| - name: 📦 Checkout | |
| uses: actions/checkout@v4 | |
| - name: 🔧 Setup Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version: "1.24.5" | |
| - name: 🔨 Build Binary | |
| env: | |
| GOOS: ${{ matrix.goos }} | |
| GOARCH: ${{ matrix.goarch }} | |
| CGO_ENABLED: 0 | |
| run: | | |
| VERSION=${GITHUB_REF#refs/tags/} | |
| if [ -z "$VERSION" ]; then | |
| VERSION="${{ github.event.inputs.tag || 'v0.0.1' }}" | |
| fi | |
| BINARY_NAME="fake-mc-server-${VERSION}-${{ matrix.goos }}-${{ matrix.goarch }}${{ matrix.suffix }}" | |
| echo "构建 ${BINARY_NAME}..." | |
| go build \ | |
| -ldflags="-w -s -X main.version=${VERSION}" \ | |
| -o "${BINARY_NAME}" \ | |
| cmd/server/main.go | |
| # 生成校验和 | |
| sha256sum "${BINARY_NAME}" > "${BINARY_NAME}.sha256" | |
| # 验证文件是否存在 | |
| ls -la "${BINARY_NAME}"* | |
| echo "构建完成: ${BINARY_NAME}" | |
| - name: 📤 Upload Build Artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: binary-${{ matrix.goos }}-${{ matrix.goarch }} | |
| path: | | |
| fake-mc-server-* | |
| *.sha256 | |
| retention-days: 7 | |
| # Docker镜像 | |
| docker: | |
| name: 🐳 Docker | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| packages: write | |
| steps: | |
| - name: 📦 Checkout | |
| uses: actions/checkout@v4 | |
| - name: 🔧 Setup Docker Buildx | |
| uses: docker/setup-buildx-action@v2 | |
| - name: 🔐 Login to Registry | |
| uses: docker/login-action@v2 | |
| with: | |
| registry: ${{ env.REGISTRY }} | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: 🏷️ Extract metadata | |
| id: meta | |
| uses: docker/metadata-action@v4 | |
| with: | |
| images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | |
| tags: | | |
| type=ref,event=tag | |
| type=semver,pattern={{version}} | |
| type=semver,pattern={{major}}.{{minor}} | |
| - name: 🐳 Build and push | |
| uses: docker/build-push-action@v4 | |
| with: | |
| context: . | |
| platforms: linux/amd64,linux/arm64 | |
| push: true | |
| tags: ${{ steps.meta.outputs.tags }} | |
| labels: ${{ steps.meta.outputs.labels }} | |
| # 创建Release | |
| release: | |
| name: 🎉 Release | |
| needs: [build, docker] | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: 📦 Checkout | |
| uses: actions/checkout@v4 | |
| - name: 📥 Download All Build Artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| pattern: binary-* | |
| path: ./release | |
| merge-multiple: true | |
| - name: 📝 Generate Release Checksums | |
| working-directory: ./release | |
| run: | | |
| echo "列出所有文件:" | |
| ls -la | |
| echo "生成完整的校验和文件..." | |
| sha256sum fake-mc-server-* > SHA256SUMS | |
| echo "校验和文件内容:" | |
| cat SHA256SUMS | |
| - name: 🎉 Create GitHub Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: ${{ github.ref_name }} | |
| name: FakeMCServer ${{ github.ref_name }} | |
| files: | | |
| release/fake-mc-server-* | |
| release/SHA256SUMS | |
| generate_release_notes: true | |
| draft: false | |
| prerelease: false | |
| body: | | |
| ## 🚀 FakeMCServer ${{ github.ref_name }} | |
| ### 📦 下载说明 | |
| 请根据您的操作系统和架构选择对应的二进制文件: | |
| - **Windows**: `fake-mc-server-*-windows-*.exe` | |
| - **Linux**: `fake-mc-server-*-linux-*` | |
| - **macOS**: `fake-mc-server-*-darwin-*` | |
| - **FreeBSD**: `fake-mc-server-*-freebsd-*` | |
| ### 🔒 校验文件完整性 | |
| 使用 `SHA256SUMS` 文件验证下载的二进制文件: | |
| ```bash | |
| sha256sum -c SHA256SUMS | |
| ``` | |
| ### 🐳 Docker镜像 | |
| ```bash | |
| docker pull ghcr.io/${{ github.repository }}:${{ github.ref_name }} | |
| ``` | |
| ### 📝 使用说明 | |
| 下载对应平台的二进制文件后,重命名为 `fake-mc-server` 并赋予执行权限: | |
| ```bash | |
| # Linux/macOS | |
| chmod +x fake-mc-server-* | |
| ./fake-mc-server-* -version | |
| # Windows | |
| fake-mc-server-*.exe -version | |
| ``` | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |