|
47 | 47 | UNIT_SENTRY_DSN: ${{ secrets.UNIT_SENTRY_DSN }} |
48 | 48 | UNIT_ANDROID_KS: ${{ secrets.UNIT_ANDROID_KS }} |
49 | 49 | UNIT_GOOGLE_SERVICES: ${{ secrets.UNIT_GOOGLE_SERVICES }} |
| 50 | + UNIT_IOS_GOOGLE_SERVICES: ${{ secrets.UNIT_IOS_GOOGLE_SERVICES }} |
50 | 51 | MATCH_PASSWORD: ${{ secrets.MATCH_PASSWORD }} |
51 | 52 | APP_STORE_CONNECT_KEY_ID: ${{ secrets.APP_STORE_CONNECT_KEY_ID }} |
52 | 53 | APP_STORE_CONNECT_ISSUER_ID: ${{ secrets.APP_STORE_CONNECT_ISSUER_ID }} |
|
71 | 72 | UNIT_APP_KEY: ${{ secrets.UNIT_APP_KEY }} |
72 | 73 | APP_KEY: ${{ secrets.APP_KEY }} |
73 | 74 | NODE_OPTIONS: --openssl-legacy-provider |
| 75 | + CHANGERAWR_API_KEY: ${{ secrets.CHANGERAWR_API_KEY }} |
| 76 | + CHANGERAWR_API_URL: ${{ secrets.CHANGERAWR_API_URL }} |
74 | 77 |
|
75 | 78 | jobs: |
76 | 79 | check-skip: |
@@ -153,6 +156,11 @@ jobs: |
153 | 156 | run: | |
154 | 157 | echo $UNIT_GOOGLE_SERVICES | base64 -d > google-services.json |
155 | 158 |
|
| 159 | + - name: 📋 Create Google Json File for iOS |
| 160 | + if: ${{ matrix.platform == 'ios' }} |
| 161 | + run: | |
| 162 | + echo $UNIT_IOS_GOOGLE_SERVICES | base64 -d > GoogleService-Info.plist |
| 163 | +
|
156 | 164 | - name: 📋 Update package.json Versions |
157 | 165 | run: | |
158 | 166 | # Ensure jq exists on both Linux and macOS |
@@ -287,33 +295,145 @@ jobs: |
287 | 295 |
|
288 | 296 | - name: 📋 Prepare Release Notes file |
289 | 297 | if: ${{ matrix.platform == 'android' }} |
290 | | - env: |
291 | | - RELEASE_NOTES_INPUT: ${{ github.event.inputs.release_notes }} |
292 | | - PR_BODY: ${{ github.event.pull_request.body }} |
293 | 298 | run: | |
294 | 299 | set -eo pipefail |
295 | | - # Determine source of release notes: workflow input, PR body, or recent commits |
296 | | - if [ -n "$RELEASE_NOTES_INPUT" ]; then |
297 | | - NOTES="$RELEASE_NOTES_INPUT" |
298 | | - elif [ -n "$PR_BODY" ]; then |
299 | | - NOTES="$(printf '%s\n' "$PR_BODY" \ |
| 300 | + |
| 301 | + # Function to extract release notes from PR body |
| 302 | + extract_release_notes() { |
| 303 | + local body="$1" |
| 304 | + # Try to extract content under "## Release Notes" heading |
| 305 | + local notes="$(printf '%s\n' "$body" \ |
300 | 306 | | awk 'f && /^## /{exit} /^## Release Notes/{f=1; next} f')" |
301 | | - else |
| 307 | + |
| 308 | + # If no specific section found, use the entire body (up to first 500 chars for safety) |
| 309 | + if [ -z "$notes" ]; then |
| 310 | + notes="$(printf '%s\n' "$body" | head -c 500)" |
| 311 | + fi |
| 312 | + |
| 313 | + printf '%s\n' "$notes" |
| 314 | + } |
| 315 | + |
| 316 | + # Determine source of release notes |
| 317 | + NOTES="" |
| 318 | + |
| 319 | + # Check if this was triggered by a push event (likely a merge) |
| 320 | + if [ "${{ github.event_name }}" = "push" ]; then |
| 321 | + echo "Fetching PR body for merged commit..." |
| 322 | + |
| 323 | + # First, try to find PR number from commit message (most reliable) |
| 324 | + PR_FROM_COMMIT=$(git log -1 --pretty=%B | grep -oE '#[0-9]+' | head -1 | tr -d '#' || echo "") |
| 325 | + |
| 326 | + if [ -n "$PR_FROM_COMMIT" ]; then |
| 327 | + echo "Found PR #$PR_FROM_COMMIT from commit message" |
| 328 | + PR_BODY=$(gh pr view "$PR_FROM_COMMIT" --json body --jq '.body' 2>/dev/null || echo "") |
| 329 | + |
| 330 | + if [ -n "$PR_BODY" ]; then |
| 331 | + NOTES="$(extract_release_notes "$PR_BODY")" |
| 332 | + fi |
| 333 | + else |
| 334 | + echo "No PR reference in commit message, searching by commit SHA..." |
| 335 | + # Get PRs that contain this commit (using GitHub API to search by commit) |
| 336 | + PR_NUMBERS=$(gh api \ |
| 337 | + "repos/${{ github.repository }}/commits/${{ github.sha }}/pulls" \ |
| 338 | + --jq '.[].number' 2>/dev/null || echo "") |
| 339 | + |
| 340 | + if [ -n "$PR_NUMBERS" ]; then |
| 341 | + # Take the first PR found (most recently merged) |
| 342 | + PR_NUMBER=$(echo "$PR_NUMBERS" | head -n 1) |
| 343 | + echo "Found PR #$PR_NUMBER associated with commit" |
| 344 | + |
| 345 | + # Fetch the PR body |
| 346 | + PR_BODY=$(gh pr view "$PR_NUMBER" --json body --jq '.body' 2>/dev/null || echo "") |
| 347 | + |
| 348 | + if [ -n "$PR_BODY" ]; then |
| 349 | + NOTES="$(extract_release_notes "$PR_BODY")" |
| 350 | + fi |
| 351 | + else |
| 352 | + echo "No associated PR found for this commit" |
| 353 | + fi |
| 354 | + fi |
| 355 | + fi |
| 356 | + |
| 357 | + # Fallback to recent commits if no PR body found |
| 358 | + if [ -z "$NOTES" ]; then |
| 359 | + echo "No PR body found, using recent commits..." |
302 | 360 | NOTES="$(git log -n 5 --pretty=format:'- %s')" |
303 | 361 | fi |
| 362 | + |
304 | 363 | # Fail if no notes extracted |
305 | 364 | if [ -z "$NOTES" ]; then |
306 | 365 | echo "Error: No release notes extracted" >&2 |
307 | 366 | exit 1 |
308 | 367 | fi |
| 368 | + |
309 | 369 | # Write header and notes to file |
310 | 370 | { |
311 | 371 | echo "## Version 7.${{ github.run_number }} - $(date +%Y-%m-%d)" |
312 | 372 | echo |
313 | 373 | printf '%s\n' "$NOTES" |
314 | 374 | } > RELEASE_NOTES.md |
| 375 | + |
| 376 | + echo "Release notes prepared:" |
| 377 | + cat RELEASE_NOTES.md |
| 378 | + env: |
| 379 | + GH_TOKEN: ${{ github.token }} |
| 380 | + |
| 381 | + - name: 📝 Send Release Notes to Changerawr |
| 382 | + if: ${{ matrix.platform == 'android' }} |
| 383 | + run: | |
| 384 | + set -eo pipefail |
| 385 | + |
| 386 | + # Check if required secrets are set |
| 387 | + if [ -z "$CHANGERAWR_API_URL" ] || [ -z "$CHANGERAWR_API_KEY" ]; then |
| 388 | + echo "⚠️ Changerawr API credentials not configured, skipping release notes submission" |
| 389 | + exit 0 |
| 390 | + fi |
| 391 | + |
| 392 | + # Read release notes |
| 393 | + RELEASE_NOTES=$(cat RELEASE_NOTES.md) |
| 394 | + VERSION="7.${{ github.run_number }}" |
| 395 | + |
| 396 | + # Prepare JSON payload |
| 397 | + PAYLOAD=$(jq -n \ |
| 398 | + --arg version "$VERSION" \ |
| 399 | + --arg notes "$RELEASE_NOTES" \ |
| 400 | + --arg platform "android" \ |
| 401 | + --arg buildNumber "${{ github.run_number }}" \ |
| 402 | + --arg commitSha "${{ github.sha }}" \ |
| 403 | + --arg buildUrl "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" \ |
| 404 | + '{ |
| 405 | + version: $version, |
| 406 | + releaseNotes: $notes, |
| 407 | + platform: $platform, |
| 408 | + buildNumber: $buildNumber, |
| 409 | + commitSha: $commitSha, |
| 410 | + buildUrl: $buildUrl, |
| 411 | + timestamp: now | todate |
| 412 | + }') |
| 413 | + |
| 414 | + echo "Sending release notes to Changerawr..." |
| 415 | + |
| 416 | + # Send to Changerawr API |
| 417 | + RESPONSE=$(curl -X POST "$CHANGERAWR_API_URL" \ |
| 418 | + -H "Content-Type: application/json" \ |
| 419 | + -H "Authorization: Bearer $CHANGERAWR_API_KEY" \ |
| 420 | + -d "$PAYLOAD" \ |
| 421 | + -w "\n%{http_code}" \ |
| 422 | + -s) |
| 423 | + |
| 424 | + HTTP_CODE=$(echo "$RESPONSE" | tail -n1) |
| 425 | + RESPONSE_BODY=$(echo "$RESPONSE" | sed '$d') |
| 426 | + |
| 427 | + if [ "$HTTP_CODE" -ge 200 ] && [ "$HTTP_CODE" -lt 300 ]; then |
| 428 | + echo "✅ Successfully sent release notes to Changerawr (HTTP $HTTP_CODE)" |
| 429 | + echo "Response: $RESPONSE_BODY" |
| 430 | + else |
| 431 | + echo "⚠️ Failed to send release notes to Changerawr (HTTP $HTTP_CODE)" |
| 432 | + echo "Response: $RESPONSE_BODY" |
| 433 | + # Don't fail the build, just warn |
| 434 | + fi |
315 | 435 |
|
316 | | - - name: 📦 Create Release |
| 436 | + - name: �📦 Create Release |
317 | 437 | if: ${{ matrix.platform == 'android' && (github.event.inputs.buildType == 'all' || github.event_name == 'push' || github.event.inputs.buildType == 'prod-apk') }} |
318 | 438 | uses: ncipollo/release-action@v1 |
319 | 439 | with: |
|
0 commit comments