|
| 1 | +name: Create GitHub Release |
| 2 | + |
| 3 | +# This workflow creates a GitHub release in iOS-SDK and attaches the built zip files. |
| 4 | +# Run this AFTER the release PR has been merged. |
| 5 | + |
| 6 | +on: |
| 7 | + workflow_dispatch: |
| 8 | + inputs: |
| 9 | + ref: |
| 10 | + description: 'Branch or commit SHA to run on (e.g., main, 5.3-main)' |
| 11 | + type: string |
| 12 | + required: false |
| 13 | + default: 'main' |
| 14 | + |
| 15 | +permissions: |
| 16 | + contents: write |
| 17 | + pull-requests: read |
| 18 | + |
| 19 | +concurrency: |
| 20 | + group: ${{ github.workflow }}-${{ github.ref }} |
| 21 | + cancel-in-progress: true |
| 22 | + |
| 23 | +jobs: |
| 24 | + release: |
| 25 | + runs-on: macos-13 |
| 26 | + |
| 27 | + env: |
| 28 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 29 | + |
| 30 | + steps: |
| 31 | + - name: Checkout OneSignal-iOS-SDK |
| 32 | + uses: actions/checkout@v4 |
| 33 | + with: |
| 34 | + ref: ${{ github.event.inputs.ref }} |
| 35 | + fetch-depth: 0 |
| 36 | + |
| 37 | + - name: Detect current branch |
| 38 | + id: detect_branch |
| 39 | + run: | |
| 40 | + if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then |
| 41 | + BRANCH="${{ github.event.inputs.ref }}" |
| 42 | + else |
| 43 | + BRANCH="${GITHUB_REF#refs/heads/}" |
| 44 | + fi |
| 45 | + echo "branch=$BRANCH" >> $GITHUB_OUTPUT |
| 46 | + echo "Detected branch: $BRANCH" |
| 47 | +
|
| 48 | + - name: Extract release version from podspec |
| 49 | + id: extract_version |
| 50 | + run: | |
| 51 | + VERSION=$(grep -E "s.version\s*=" OneSignal.podspec | sed -E 's/.*"(.*)".*/\1/') |
| 52 | + echo "version=$VERSION" >> $GITHUB_OUTPUT |
| 53 | + echo "Extracted version: $VERSION" |
| 54 | +
|
| 55 | + - name: 📋 Display Configuration |
| 56 | + run: | |
| 57 | + echo "============================================" |
| 58 | + echo "📦 Release Version: ${{ steps.extract_version.outputs.version }}" |
| 59 | + echo "🌿 Branch: ${{ steps.detect_branch.outputs.branch }}" |
| 60 | + echo "============================================" |
| 61 | +
|
| 62 | + - name: Get Merged Release PR |
| 63 | + id: get_release_pr |
| 64 | + run: | |
| 65 | + VERSION="${{ steps.extract_version.outputs.version }}" |
| 66 | +
|
| 67 | + # Try to find the merged release PR for this version |
| 68 | + PR_NUMBER=$(gh pr list --state merged --search "Release $VERSION in:title" --json number --jq '.[0].number // empty') |
| 69 | +
|
| 70 | + if [[ -n "$PR_NUMBER" ]]; then |
| 71 | + echo "Found merged release PR: #$PR_NUMBER" |
| 72 | + echo "pr_number=$PR_NUMBER" >> $GITHUB_OUTPUT |
| 73 | +
|
| 74 | + # Get PR body for release notes |
| 75 | + gh pr view "$PR_NUMBER" --json body --jq '.body' > pr_body.md || echo "" > pr_body.md |
| 76 | + else |
| 77 | + echo "No merged release PR found for version $VERSION" |
| 78 | + echo "pr_number=" >> $GITHUB_OUTPUT |
| 79 | + echo "" > pr_body.md |
| 80 | + fi |
| 81 | +
|
| 82 | + - name: Generate Release Notes |
| 83 | + run: | |
| 84 | + VERSION="${{ steps.extract_version.outputs.version }}" |
| 85 | +
|
| 86 | + if [[ -s pr_body.md ]] && [[ -n "${{ steps.get_release_pr.outputs.pr_number }}" ]]; then |
| 87 | + # Use the PR body from the release PR |
| 88 | + echo "Using release notes from PR #${{ steps.get_release_pr.outputs.pr_number }}" |
| 89 | + cp pr_body.md release_notes.md |
| 90 | + else |
| 91 | + # Generate release notes from commits |
| 92 | + echo "## 🔖 Release Notes" > release_notes.md |
| 93 | + fi |
| 94 | +
|
| 95 | + - name: Create Git Tag |
| 96 | + run: | |
| 97 | + VERSION="${{ steps.extract_version.outputs.version }}" |
| 98 | +
|
| 99 | + # Configure git |
| 100 | + git config --local user.email "noreply@onesignal.com" |
| 101 | + git config --local user.name "github-actions[bot]" |
| 102 | +
|
| 103 | + # Create and push tag |
| 104 | + git tag -a "$VERSION" -m "Release $VERSION" |
| 105 | + git push origin "$VERSION" |
| 106 | +
|
| 107 | + echo "✅ Created and pushed tag: $VERSION" |
| 108 | +
|
| 109 | + - name: Create GitHub Release |
| 110 | + run: | |
| 111 | + VERSION="${{ steps.extract_version.outputs.version }}" |
| 112 | + BRANCH="${{ steps.detect_branch.outputs.branch }}" |
| 113 | +
|
| 114 | + cd iOS_SDK/OneSignalSDK |
| 115 | +
|
| 116 | + # Determine if this is a pre-release |
| 117 | + PRERELEASE_FLAG="" |
| 118 | + if [[ "$VERSION" == *"alpha"* ]] || [[ "$VERSION" == *"beta"* ]]; then |
| 119 | + PRERELEASE_FLAG="--prerelease" |
| 120 | + echo "Marking as pre-release (alpha/beta detected)" |
| 121 | + fi |
| 122 | +
|
| 123 | + gh release create "$VERSION" \ |
| 124 | + --title "Release $VERSION" \ |
| 125 | + --notes-file ../../release_notes.md \ |
| 126 | + --target "$BRANCH" \ |
| 127 | + $PRERELEASE_FLAG \ |
| 128 | + OneSignalCore.xcframework.zip \ |
| 129 | + OneSignalExtension.xcframework.zip \ |
| 130 | + OneSignalFramework.xcframework.zip \ |
| 131 | + OneSignalInAppMessages.xcframework.zip \ |
| 132 | + OneSignalLiveActivities.xcframework.zip \ |
| 133 | + OneSignalLocation.xcframework.zip \ |
| 134 | + OneSignalNotifications.xcframework.zip \ |
| 135 | + OneSignalOSCore.xcframework.zip \ |
| 136 | + OneSignalOutcomes.xcframework.zip \ |
| 137 | + OneSignalUser.xcframework.zip |
| 138 | +
|
| 139 | + echo "✅ GitHub release created successfully!" |
| 140 | + echo "🔗 https://github.com/${{ github.repository }}/releases/tag/$VERSION" |
0 commit comments