diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a93e2f9..3dd69d0 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -12,23 +12,14 @@ jobs: runs-on: ubuntu-latest steps: - # -------------------------------------------------- - # Checkout - # -------------------------------------------------- - name: Checkout code uses: actions/checkout@v4 - # -------------------------------------------------- - # Go setup - # -------------------------------------------------- - name: Set up Go uses: actions/setup-go@v5 with: go-version: "1.22" - # -------------------------------------------------- - # Build binaries - # -------------------------------------------------- - name: Build for ARMv6 (Pi Zero / Pi 1) run: | GOOS=linux GOARCH=arm GOARM=6 \ @@ -39,9 +30,6 @@ jobs: GOOS=linux GOARCH=arm64 \ go build -ldflags="-s -w" -o wol-server-arm64 - # -------------------------------------------------- - # systemd service (portable, no hardcoded user) - # -------------------------------------------------- - name: Create systemd service file run: | cat > wol-server.service << 'EOF' @@ -61,9 +49,6 @@ jobs: WantedBy=multi-user.target EOF - # -------------------------------------------------- - # Install script (auto-detect architecture) - # -------------------------------------------------- - name: Create install script run: | cat > install.sh << 'EOF' @@ -118,9 +103,6 @@ jobs: chmod +x install.sh - # -------------------------------------------------- - # Package - # -------------------------------------------------- - name: Create release package run: | mkdir -p package @@ -132,16 +114,25 @@ jobs: tar -czf wol-server.tar.gz -C package . - # -------------------------------------------------- - # GitHub Release - # -------------------------------------------------- - - name: Create GitHub Release - uses: softprops/action-gh-release@v1 + - name: Create Forgejo Release if: github.ref == 'refs/heads/main' - with: - tag_name: v${{ github.run_number }} - name: Release v${{ github.run_number }} - files: | - wol-server.tar.gz - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + TAG="v${{ github.run_number }}" + API_URL="${{ github.server_url }}/api/v1" + REPO="${{ github.repository }}" + + # Create release + RELEASE_ID=$(curl -s -X POST \ + -H "Authorization: token ${{ secrets.GITEA_TOKEN }}" \ + -H "Content-Type: application/json" \ + "${API_URL}/repos/${REPO}/releases" \ + -d "{\"tag_name\": \"${TAG}\", \"name\": \"Release ${TAG}\", \"draft\": false, \"prerelease\": false}" \ + | grep -o '"id":[0-9]*' | head -1 | cut -d: -f2) + + # Upload asset + curl -s -X POST \ + -H "Authorization: token ${{ secrets.GITEA_TOKEN }}" \ + "${API_URL}/repos/${REPO}/releases/${RELEASE_ID}/assets?name=wol-server.tar.gz" \ + -F "attachment=@wol-server.tar.gz" > /dev/null + + echo "Release ${TAG} created with asset wol-server.tar.gz"