diff --git a/.gitea/workflows/build.yml b/.gitea/workflows/build.yml new file mode 100644 index 0000000..b3fcc9e --- /dev/null +++ b/.gitea/workflows/build.yml @@ -0,0 +1,61 @@ +# .gitea/workflows/build.yml +name: Build GHub + +on: + push: + branches: + - main + - master + tags: + - 'v*' + pull_request: + branches: + - main + - master + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: 检出代码 + uses: actions/checkout@v4 + + - name: 设置 Go 环境 + uses: actions/setup-go@v5 + with: + go-version: '1.25' + + - name: 获取版本信息 + id: version + run: | + if [[ $GITHUB_REF == refs/tags/* ]]; then + VERSION=${GITHUB_REF#refs/tags/} + else + VERSION=$(git describe --tags --always --dirty 2>/dev/null || echo "dev") + fi + echo "version=$VERSION" >> $GITHUB_OUTPUT + echo "构建版本: $VERSION" + + - name: 编译 Windows ARM64 + run: | + GOOS=windows GOARCH=arm64 go build -ldflags="-s -w -X main.Version=${{ steps.version.outputs.version }}" -o GHub-windows-arm64.exe + + - name: 编译 Linux AMD64 + run: | + GOOS=linux GOARCH=amd64 go build -ldflags="-s -w -X main.Version=${{ steps.version.outputs.version }}" -o GHub-linux-amd64 + + - name: 上传构建产物 + uses: actions/upload-artifact@v4 + with: + name: GHub-${{ steps.version.outputs.version }} + path: | + GHub-windows-arm64.exe + GHub-linux-amd64 + + - name: 创建 Release + if: startsWith(github.ref, 'refs/tags/') + uses: actions/gitea-release@v1 + with: + files: | + GHub-windows-arm64.exe + GHub-linux-amd64