diff --git a/.forgejo/workflows/release.yml b/.forgejo/workflows/release.yml index b1f91e4..2c81fab 100644 --- a/.forgejo/workflows/release.yml +++ b/.forgejo/workflows/release.yml @@ -49,7 +49,7 @@ jobs: - name: Build binary env: - VERSION: ${{ github.ref_name }} + VERSION: ${{ gitea.ref_name }} run: | set -euo pipefail mkdir -p dist @@ -93,11 +93,45 @@ jobs: sha256sum * > SHA256SUMS ls -lh - - name: Create Forgejo release - uses: https://github.com/softprops/action-gh-release@v2 - with: - name: ${{ github.ref_name }} - prerelease: ${{ contains(github.ref_name, '-') }} - generate_release_notes: true - files: | - release/* + - name: Create Forgejo release and upload assets + env: + TOKEN: ${{ secrets.FORGEJO_TOKEN }} + TAG: ${{ gitea.ref_name }} + API_URL: ${{ gitea.api_url }} + REPO: ${{ gitea.repository }} + run: | + set -euo pipefail + IS_PRERELEASE="false" + if [[ "$TAG" == *-* ]]; then + IS_PRERELEASE="true" + fi + + echo "Creating Release $TAG in Forgejo ($REPO)..." + RESPONSE=$(curl -sS -X POST \ + -H "Authorization: token $TOKEN" \ + -H "Content-Type: application/json" \ + -d "{\"tag_name\":\"$TAG\",\"name\":\"$TAG\",\"prerelease\":$IS_PRERELEASE}" \ + "$API_URL/repos/$REPO/releases") + + RELEASE_ID=$(echo "$RESPONSE" | jq -r ".id" 2>/dev/null || echo "$RESPONSE" | grep -o '"id":[^,]*' | head -n 1 | cut -d':' -f2 | tr -d ' ') + + if [[ -z "$RELEASE_ID" || "$RELEASE_ID" == "null" ]]; then + echo "Error creating release in Forgejo. Response:" + echo "$RESPONSE" + exit 1 + fi + + echo "Release created successfully in Forgejo with ID: $RELEASE_ID" + + for FILE in release/*; do + if [ -f "$FILE" ]; then + FILENAME=$(basename "$FILE") + echo "Uploading $FILENAME to Forgejo release $RELEASE_ID..." + curl -sS -X POST \ + -H "Authorization: token $TOKEN" \ + -F "attachment=@$FILE" \ + "$API_URL/repos/$REPO/releases/$RELEASE_ID/assets" + echo "" + fi + done + echo "All assets uploaded successfully to Forgejo Release!"