-
Notifications
You must be signed in to change notification settings - Fork 0
70 lines (60 loc) · 2.38 KB
/
release.yml
File metadata and controls
70 lines (60 loc) · 2.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
name: Release
on:
pull_request:
types: [closed]
branches:
- master
jobs:
release:
name: 🚀 Release
if: github.event.pull_request.merged && startsWith(github.head_ref, 'release-')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/github-script@v7
with:
script: |
// Getting the release version from the PR source branch
// Source branch looks like this: release-1.0.0
const version = context.payload.pull_request.head.ref.split('-')[1]
core.exportVariable('VERSION', version)
- name: Create release on GitHub
uses: ncipollo/release-action@v1
with:
tag: ${{ env.VERSION }}
token: ${{ secrets.GITHUB_TOKEN }}
body: |
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