Publish Release to CocoaPods and SPM #8
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Publish Release to CocoaPods and SPM | |
| # This workflow publishes the OneSignal pods to CocoaPods trunk. | |
| # And creates the tagged release in the OneSignal-XCFramework repository for SPM. | |
| # Run this AFTER the release PR has been merged and the GitHub release has been created. | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| ref: | |
| description: "Branch or commit SHA to run on (e.g., main, 5.3-main)" | |
| type: string | |
| required: false | |
| default: "main" | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| publish: | |
| outputs: | |
| sdk_version: ${{ steps.extract_version.outputs.version }} | |
| runs-on: macos-14 | |
| env: | |
| COCOAPODS_TRUNK_TOKEN: ${{ secrets.COCOAPODS_TRUNK_TOKEN }} | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| steps: | |
| - name: Checkout OneSignal-iOS-SDK | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: ${{ github.event.inputs.ref }} | |
| fetch-depth: 0 | |
| - name: Detect current branch | |
| id: detect_branch | |
| run: | | |
| if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then | |
| BRANCH="${{ github.event.inputs.ref }}" | |
| else | |
| BRANCH="${GITHUB_REF#refs/heads/}" | |
| fi | |
| echo "branch=$BRANCH" >> $GITHUB_OUTPUT | |
| echo "Detected branch: $BRANCH" | |
| - name: Extract release version from podspec | |
| id: extract_version | |
| run: | | |
| VERSION=$(grep -E "s.version\s*=" OneSignal.podspec | sed -E 's/.*"(.*)".*/\1/') | |
| echo "version=$VERSION" >> $GITHUB_OUTPUT | |
| echo "Extracted version: $VERSION" | |
| - name: 📋 Display Configuration | |
| run: | | |
| echo "============================================" | |
| echo "📦 Release Version: ${{ steps.extract_version.outputs.version }}" | |
| echo "🌿 Branch: ${{ steps.detect_branch.outputs.branch }}" | |
| echo "============================================" | |
| - name: Setup Ruby | |
| uses: ruby/setup-ruby@v1 | |
| with: | |
| ruby-version: "3.0" | |
| - name: Install CocoaPods | |
| run: | | |
| gem install cocoapods | |
| pod --version | |
| - name: Validate OneSignal.podspec | |
| run: | | |
| echo "Validating OneSignal.podspec..." | |
| pod spec lint OneSignal.podspec --allow-warnings | |
| - name: Validate OneSignalXCFramework.podspec | |
| run: | | |
| echo "Validating OneSignalXCFramework.podspec..." | |
| pod spec lint OneSignalXCFramework.podspec --allow-warnings | |
| - name: Publish OneSignal.podspec to CocoaPods Trunk | |
| run: | | |
| echo "Publishing OneSignal.podspec to CocoaPods Trunk..." | |
| pod trunk push OneSignal.podspec --allow-warnings | |
| - name: Publish OneSignalXCFramework.podspec to CocoaPods Trunk | |
| run: | | |
| echo "Publishing OneSignalXCFramework.podspec to CocoaPods Trunk..." | |
| pod trunk push OneSignalXCFramework.podspec --allow-warnings | |