diff --git a/.gitea/workflows/release.yml b/.gitea/workflows/release.yml index 620dbc2..9a4e4c9 100644 --- a/.gitea/workflows/release.yml +++ b/.gitea/workflows/release.yml @@ -150,13 +150,62 @@ jobs: echo "EOF" >> $GITHUB_OUTPUT - name: Create Gitea Release - uses: actions/gitea-release-action@v1 - with: - token: ${{ secrets.SRC_GITEA_TOKEN }} - tag: ${{ github.ref_name }} - title: "v${{ steps.version.outputs.version }}" - body: ${{ steps.changelog.outputs.changelog }} - prerelease: ${{ contains(github.ref_name, '-') }} - files: | - releases/wc-licensed-product-${{ steps.version.outputs.version }}.zip - releases/wc-licensed-product-${{ steps.version.outputs.version }}.zip.sha256 + id: create_release + run: | + VERSION=${{ steps.version.outputs.version }} + TAG_NAME=${{ github.ref_name }} + + # Determine if prerelease + if [[ "$TAG_NAME" == *"-"* ]]; then + PRERELEASE=true + else + PRERELEASE=false + fi + + # Escape changelog for JSON + CHANGELOG_ESCAPED=$(echo '${{ steps.changelog.outputs.changelog }}' | jq -Rs .) + + # Create release via Gitea API + RESPONSE=$(curl -s -X POST \ + -H "Authorization: token ${{ secrets.SRC_GITEA_TOKEN }}" \ + -H "Content-Type: application/json" \ + "${GITHUB_SERVER_URL}/api/v1/repos/${GITHUB_REPOSITORY}/releases" \ + -d "{ + \"tag_name\": \"${TAG_NAME}\", + \"name\": \"v${VERSION}\", + \"body\": ${CHANGELOG_ESCAPED}, + \"draft\": false, + \"prerelease\": ${PRERELEASE} + }") + + # Extract release ID + RELEASE_ID=$(echo "$RESPONSE" | jq -r '.id') + echo "Release ID: $RELEASE_ID" + echo "release_id=$RELEASE_ID" >> $GITHUB_OUTPUT + + if [ "$RELEASE_ID" == "null" ] || [ -z "$RELEASE_ID" ]; then + echo "Failed to create release" + echo "$RESPONSE" + exit 1 + fi + + - name: Upload Release Assets + run: | + VERSION=${{ steps.version.outputs.version }} + RELEASE_ID=${{ steps.create_release.outputs.release_id }} + + # Upload zip file + curl -s -X POST \ + -H "Authorization: token ${{ secrets.SRC_GITEA_TOKEN }}" \ + -H "Content-Type: application/octet-stream" \ + "${GITHUB_SERVER_URL}/api/v1/repos/${GITHUB_REPOSITORY}/releases/${RELEASE_ID}/assets?name=wc-licensed-product-${VERSION}.zip" \ + --data-binary @"releases/wc-licensed-product-${VERSION}.zip" + + # Upload checksum file + curl -s -X POST \ + -H "Authorization: token ${{ secrets.SRC_GITEA_TOKEN }}" \ + -H "Content-Type: application/octet-stream" \ + "${GITHUB_SERVER_URL}/api/v1/repos/${GITHUB_REPOSITORY}/releases/${RELEASE_ID}/assets?name=wc-licensed-product-${VERSION}.zip.sha256" \ + --data-binary @"releases/wc-licensed-product-${VERSION}.zip.sha256" + + echo "Assets uploaded successfully"