name: Build and Release on: push: branches: [ main, develop ] tags: [ 'v*' ] pull_request: branches: [ main ] jobs: test: name: Test runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@v4 - name: Set up Go uses: actions/setup-go@v4 with: go-version: '1.21' - name: Download dependencies run: go mod download - name: Run tests run: go test -v ./... - name: Run race detection tests run: go test -race -v ./... - name: Run benchmarks run: go test -bench=. -benchmem ./... build: name: Build Multi-Platform runs-on: ubuntu-latest needs: test strategy: matrix: include: - goos: linux goarch: amd64 name: linux-amd64 - goos: linux goarch: arm64 name: linux-arm64 - goos: linux goarch: 386 name: linux-386 - goos: linux goarch: arm name: linux-arm - goos: darwin goarch: amd64 name: darwin-amd64 - goos: darwin goarch: arm64 name: darwin-arm64 - goos: windows goarch: amd64 name: windows-amd64 ext: .exe - goos: windows goarch: 386 name: windows-386 ext: .exe - goos: windows goarch: arm64 name: windows-arm64 ext: .exe - goos: freebsd goarch: amd64 name: freebsd-amd64 - goos: freebsd goarch: arm64 name: freebsd-arm64 steps: - name: Checkout code uses: actions/checkout@v4 with: fetch-depth: 0 - name: Set up Go uses: actions/setup-go@v4 with: go-version: '1.21' - name: Get version id: version run: | if [[ $GITHUB_REF == refs/tags/* ]]; then VERSION=${GITHUB_REF#refs/tags/} else VERSION=v1.1.0-$(git rev-parse --short HEAD) fi echo "VERSION=$VERSION" >> $GITHUB_OUTPUT echo "Building version: $VERSION" - name: Build binary env: GOOS: ${{ matrix.goos }} GOARCH: ${{ matrix.goarch }} VERSION: ${{ steps.version.outputs.VERSION }} run: | BUILD_TIME=$(date -u '+%Y-%m-%d_%H:%M:%S') GIT_COMMIT=$(git rev-parse --short HEAD) LDFLAGS="-ldflags \"-X main.version=${VERSION} -X main.buildTime=${BUILD_TIME} -X main.gitCommit=${GIT_COMMIT} -s -w\"" mkdir -p dist BINARY_NAME="wormhole-server-${VERSION}-${{ matrix.name }}${{ matrix.ext }}" echo "Building ${BINARY_NAME}..." go build ${LDFLAGS} -o "dist/${BINARY_NAME}" cmd/wormhole-server/main.go - name: Upload artifact uses: actions/upload-artifact@v3 with: name: wormhole-server-${{ matrix.name }} path: dist/wormhole-server-*-${{ matrix.name }}* retention-days: 30 release: name: Create Release runs-on: ubuntu-latest needs: build if: startsWith(github.ref, 'refs/tags/') steps: - name: Checkout code uses: actions/checkout@v4 - name: Download all artifacts uses: actions/download-artifact@v3 with: path: artifacts - name: Get version id: version run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT - name: Create release packages run: | mkdir -p release VERSION=${{ steps.version.outputs.VERSION }} # 移动所有二进制文件到一个目录 find artifacts -name "wormhole-server-*" -type f -exec mv {} release/ \; cd release # 为每个平台创建发布包 for binary in wormhole-server-${VERSION}-*; do if [[ "$binary" == *.exe ]]; then # Windows平台使用zip platform=$(echo "$binary" | sed "s/wormhole-server-${VERSION}-//; s/.exe$//") zip -j "wormhole-server-${VERSION}-${platform}.zip" "$binary" ../configs/server.yaml ../README.md else # 其他平台使用tar.gz platform=$(echo "$binary" | sed "s/wormhole-server-${VERSION}-//") tar -czf "wormhole-server-${VERSION}-${platform}.tar.gz" "$binary" -C .. configs/server.yaml README.md fi done # 创建校验和文件 sha256sum wormhole-server-${VERSION}-*.{tar.gz,zip} > wormhole-server-${VERSION}-checksums.txt - name: Create Release uses: ncipollo/release-action@v1 with: tag: ${{ steps.version.outputs.VERSION }} name: Wormhole Server ${{ steps.version.outputs.VERSION }} draft: false prerelease: false artifacts: "release/wormhole-server-*" body: | ## Wormhole Server ${{ steps.version.outputs.VERSION }} ### 🚀 新功能 - 高性能 SOCKS5 代理服务器 - 速率限制和连接池优化 - 内存优化和DNS缓存 - 多平台支持 ### 📦 下载 选择适合您系统的版本: **Linux:** - `wormhole-server-${{ steps.version.outputs.VERSION }}-linux-amd64.tar.gz` - Linux x86_64 - `wormhole-server-${{ steps.version.outputs.VERSION }}-linux-arm64.tar.gz` - Linux ARM64 - `wormhole-server-${{ steps.version.outputs.VERSION }}-linux-arm.tar.gz` - Linux ARM - `wormhole-server-${{ steps.version.outputs.VERSION }}-linux-386.tar.gz` - Linux x86 **macOS:** - `wormhole-server-${{ steps.version.outputs.VERSION }}-darwin-amd64.tar.gz` - macOS Intel - `wormhole-server-${{ steps.version.outputs.VERSION }}-darwin-arm64.tar.gz` - macOS Apple Silicon **Windows:** - `wormhole-server-${{ steps.version.outputs.VERSION }}-windows-amd64.zip` - Windows x64 - `wormhole-server-${{ steps.version.outputs.VERSION }}-windows-386.zip` - Windows x86 - `wormhole-server-${{ steps.version.outputs.VERSION }}-windows-arm64.zip` - Windows ARM64 **FreeBSD:** - `wormhole-server-${{ steps.version.outputs.VERSION }}-freebsd-amd64.tar.gz` - FreeBSD x86_64 - `wormhole-server-${{ steps.version.outputs.VERSION }}-freebsd-arm64.tar.gz` - FreeBSD ARM64 ### 🔐 校验和 下载 `wormhole-server-${{ steps.version.outputs.VERSION }}-checksums.txt` 来验证文件完整性。 ### 📖 使用方法 1. 下载适合您系统的版本 2. 解压文件 3. 编辑 `server.yaml` 配置文件 4. 运行 `./wormhole-server -config server.yaml` 更多信息请查看 [README.md](https://github.com/azoic/wormhole-server/blob/main/README.md) docker: name: Build Docker Images runs-on: ubuntu-latest needs: test if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/')) steps: - name: Checkout code uses: actions/checkout@v4 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - name: Login to Docker Hub uses: docker/login-action@v3 with: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_PASSWORD }} if: secrets.DOCKER_USERNAME && secrets.DOCKER_PASSWORD - name: Get version id: version run: | if [[ $GITHUB_REF == refs/tags/* ]]; then VERSION=${GITHUB_REF#refs/tags/} echo "VERSION=$VERSION" >> $GITHUB_OUTPUT echo "LATEST=true" >> $GITHUB_OUTPUT else VERSION=v1.1.0-$(git rev-parse --short HEAD) echo "VERSION=$VERSION" >> $GITHUB_OUTPUT echo "LATEST=false" >> $GITHUB_OUTPUT fi - name: Build and push Docker image uses: docker/build-push-action@v5 with: context: . platforms: linux/amd64,linux/arm64 push: ${{ secrets.DOCKER_USERNAME && secrets.DOCKER_PASSWORD }} tags: | ${{ secrets.DOCKER_USERNAME }}/wormhole-server:${{ steps.version.outputs.VERSION }} ${{ secrets.DOCKER_USERNAME }}/wormhole-server:latest build-args: | VERSION=${{ steps.version.outputs.VERSION }} cache-from: type=gha cache-to: type=gha,mode=max