diff --git a/.gitea/workflows/release.yaml b/.gitea/workflows/release.yaml new file mode 100644 index 0000000..fbaf0b2 --- /dev/null +++ b/.gitea/workflows/release.yaml @@ -0,0 +1,59 @@ +name: release + +on: + workflow_dispatch: {} + push: + tags: + - 'v*' + +jobs: + build-and-release: + runs-on: ubuntu-latest + + env: + APP_NAME: sfdl + + steps: + - name: Checkout + uses: https://gitea.starryskymeow.cn/mirrors/checkout@v4 + + - name: Setup Go + uses: https://gitea.starryskymeow.cn/mirrors/setup-go@v5 + with: + go-version: '1.25.4' + + - name: Build multi-platform binaries + run: | + set -e + mkdir -p dist + + platforms=( + "linux amd64" + "linux arm64" + "windows amd64" + "darwin amd64" + "darwin arm64" + ) + + for platform in "${platforms[@]}"; do + os=$(echo "$platform" | cut -d' ' -f1) + arch=$(echo "$platform" | cut -d' ' -f2) + + ext="" + if [ "$os" = "windows" ]; then + ext=".exe" + fi + + echo ">>> Building for $os/$arch" + GOOS=$os GOARCH=$arch CGO_ENABLED=0 \ + go build -o "dist/${APP_NAME}-${os}-${arch}${ext}" . + + done + + - name: Create Gitea Release + uses: https://gitea.starryskymeow.cn/mirrors/gitea-release-action@v1 + with: + token: '${{ secrets.RELEASE_TOKEN }}' + server_url: 'https://gitea.starryskymeow.cn' + files: | + dist/*