diff --git a/.gitea/workflows/build.yml b/.gitea/workflows/build.yml index e20413268d..dfb96997b2 100644 --- a/.gitea/workflows/build.yml +++ b/.gitea/workflows/build.yml @@ -270,30 +270,59 @@ jobs: echo "changelog=${CHANGELOG}" >> $GITHUB_OUTPUT - name: Create Release - uses: softprops/action-gh-release@v1 - with: - name: Gitea ${{ steps.version.outputs.version }} - tag_name: ${{ steps.version.outputs.version }} - body: | - ## Changes in ${{ steps.version.outputs.version }} + run: | + VERSION="${{ steps.version.outputs.version }}" + IS_PRERELEASE="false" + if [[ "$VERSION" == *"-rc"* ]] || [[ "$VERSION" == *"-beta"* ]] || [[ "$VERSION" == *"-alpha"* ]]; then + IS_PRERELEASE="true" + fi - ${{ steps.changelog.outputs.changelog }} + RELEASE_BODY="## Changes in ${VERSION} - ## Downloads + ${{ steps.changelog.outputs.changelog }} - | Platform | Architecture | Download | - |----------|--------------|----------| - | Linux | amd64 | `gitea-${{ steps.version.outputs.version }}-linux-amd64` | - | Linux | arm64 | `gitea-${{ steps.version.outputs.version }}-linux-arm64` | - | macOS | amd64 | `gitea-${{ steps.version.outputs.version }}-darwin-amd64` | - | macOS | arm64 | `gitea-${{ steps.version.outputs.version }}-darwin-arm64` | - | Windows | amd64 | `gitea-${{ steps.version.outputs.version }}-windows-amd64.exe` | + ## Downloads - ## Checksums + | Platform | Architecture | Download | + |----------|--------------|----------| + | Linux | amd64 | gitea-${VERSION}-linux-amd64 | + | Linux | arm64 | gitea-${VERSION}-linux-arm64 | + | macOS | amd64 | gitea-${VERSION}-darwin-amd64 | + | macOS | arm64 | gitea-${VERSION}-darwin-arm64 | + | Windows | amd64 | gitea-${VERSION}-windows-amd64.exe | - SHA256 checksums are provided in `.sha256` files alongside each binary. - files: dist/* - draft: false - prerelease: ${{ contains(steps.version.outputs.version, '-rc') || contains(steps.version.outputs.version, '-beta') || contains(steps.version.outputs.version, '-alpha') }} - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + ## Checksums + + SHA256 checksums are provided in .sha256 files alongside each binary." + + # Create release via Gitea API + RELEASE_DATA=$(jq -n \ + --arg tag "$VERSION" \ + --arg name "Gitea $VERSION" \ + --arg body "$RELEASE_BODY" \ + --argjson prerelease "$IS_PRERELEASE" \ + '{tag_name: $tag, name: $name, body: $body, draft: false, prerelease: $prerelease}') + + RESPONSE=$(curl -s -X POST \ + -H "Authorization: token ${{ secrets.RELEASE_TOKEN }}" \ + -H "Content-Type: application/json" \ + -d "$RELEASE_DATA" \ + "${{ github.server_url }}/api/v1/repos/${{ github.repository }}/releases") + + echo "Release response: $RESPONSE" + RELEASE_ID=$(echo "$RESPONSE" | jq -r '.id') + echo "Created release with ID: $RELEASE_ID" + + # Upload assets + for file in dist/*; do + if [ -f "$file" ]; then + filename=$(basename "$file") + echo "Uploading $filename..." + curl -s -X POST \ + -H "Authorization: token ${{ secrets.RELEASE_TOKEN }}" \ + -H "Content-Type: multipart/form-data" \ + -F "attachment=@$file" \ + "${{ github.server_url }}/api/v1/repos/${{ github.repository }}/releases/$RELEASE_ID/assets?name=$filename" + echo "Uploaded $filename" + fi + done