diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index dfdced7..4d89dfc 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -33,3 +33,38 @@ jobs: Release ${{ env.VERSION }} Install with: `composer require getstream/getstream-php:^${{ env.VERSION }}` + + - name: Update Packagist + env: + PACKAGIST_TOKEN: ${{ secrets.PACKAGIST_TOKEN }} + PACKAGIST_USERNAME: ${{ secrets.PACKAGIST_USERNAME }} + run: | + if [ -z "$PACKAGIST_TOKEN" ]; then + echo "⚠️ PACKAGIST_TOKEN secret is not set. Skipping Packagist update." + exit 0 + fi + + if [ -z "$PACKAGIST_USERNAME" ]; then + echo "⚠️ PACKAGIST_USERNAME secret is not set. Skipping Packagist update." + echo "💡 Add PACKAGIST_USERNAME secret with your Packagist account username." + exit 0 + fi + + echo "🔄 Updating Packagist package..." + response=$(curl -s -w "\n%{http_code}" -X POST \ + -H "Content-Type: application/json" \ + -H "Authorization: Bearer $PACKAGIST_TOKEN" \ + -d '{"repository":{"url":"https://github.com/GetStream/getstream-php"}}' \ + "https://packagist.org/api/update-package?username=$PACKAGIST_USERNAME") + + http_code=$(echo "$response" | tail -n1) + body=$(echo "$response" | sed '$d') + + if [ "$http_code" -eq 200 ] || [ "$http_code" -eq 202 ]; then + echo "✅ Packagist update triggered successfully" + echo "$body" + else + echo "❌ Failed to update Packagist (HTTP $http_code)" + echo "$body" + exit 1 + fi