Create Release PR #42
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: Create Release PR | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| on: | |
| # For making a release pr from android / ios sdk actions | |
| workflow_call: | |
| secrets: | |
| GH_PUSH_TOKEN: | |
| required: false | |
| description: "GitHub token for pushing changes" | |
| inputs: | |
| dotnet_version: | |
| description: "New .NET Version (e.g., 5.2.15 or 5.2.15-beta.1)" | |
| required: true | |
| type: string | |
| android_version: | |
| description: "New Android SDK Version (e.g., 2.3.0). Leave blank to skip." | |
| required: false | |
| type: string | |
| ios_version: | |
| description: "New iOS SDK Version (e.g., 1.5.0). Leave blank to skip." | |
| required: false | |
| type: string | |
| target_branch: | |
| description: "Target branch to create the release PR on. Defaults to main." | |
| required: false | |
| type: string | |
| default: main | |
| # For making a release pr from .NET github actions | |
| workflow_dispatch: | |
| inputs: | |
| dotnet_version: | |
| description: ".NET release version (e.g., 5.0.0 or 5.0.0-beta1)" | |
| required: true | |
| type: string | |
| android_version: | |
| description: "New Android SDK Version (e.g., 2.3.0). Leave blank to skip." | |
| required: false | |
| type: string | |
| ios_version: | |
| description: "New iOS SDK Version (e.g., 1.5.0). Leave blank to skip." | |
| required: false | |
| type: string | |
| target_branch: | |
| description: "Target branch to create the release PR on. Defaults to main." | |
| required: false | |
| type: string | |
| default: main | |
| jobs: | |
| prep: | |
| uses: OneSignal/sdk-shared/.github/workflows/prep-release.yml@main | |
| secrets: | |
| # Need this cross-repo token (sdk-shared & this repo) to perform changes | |
| GH_PUSH_TOKEN: ${{ secrets.GH_PUSH_TOKEN }} | |
| with: | |
| target_repo: OneSignal/OneSignal-DotNet-SDK | |
| version: ${{ inputs.dotnet_version }} | |
| # DOTNET specific steps | |
| update-version: | |
| name: Create Release PR | |
| needs: prep | |
| runs-on: macos-latest | |
| outputs: | |
| dotnet_from: ${{ steps.current_versions.outputs.dotnet_from }} | |
| android_from: ${{ steps.current_versions.outputs.android_from }} | |
| ios_from: ${{ steps.current_versions.outputs.ios_from }} | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v5 | |
| with: | |
| repository: OneSignal/OneSignal-DotNet-SDK | |
| ref: ${{ needs.prep.outputs.release_branch }} | |
| token: ${{ secrets.GH_PUSH_TOKEN || github.token }} | |
| - name: Setup Git User | |
| uses: OneSignal/sdk-shared/.github/actions/setup-git-user@main | |
| - name: Setup .NET | |
| uses: actions/setup-dotnet@v5 | |
| with: | |
| dotnet-version: "10.0.x" | |
| - name: Get current native SDK versions from target branch | |
| id: current_versions | |
| run: | | |
| git fetch origin ${{ inputs.target_branch }} | |
| # Get versions from target branch (not the release branch) | |
| CURRENT_DOTNET_VERSION=$(git show origin/${{ inputs.target_branch }}:OneSignalSDK.DotNet.nuspec | grep '<version>' | sed -E 's/.*<version>([^<]+)<\/version>.*/\1/' | head -1) | |
| ANDROID_VERSION=$(git show origin/${{ inputs.target_branch }}:versions.json | grep '"android"' | sed -E 's/.*"android": *"([^"]+)".*/\1/') | |
| IOS_VERSION=$(git show origin/${{ inputs.target_branch }}:versions.json | grep '"ios"' | sed -E 's/.*"ios": *"([^"]+)".*/\1/') | |
| echo "dotnet_from=$CURRENT_DOTNET_VERSION" >> $GITHUB_OUTPUT | |
| echo "android_from=$ANDROID_VERSION" >> $GITHUB_OUTPUT | |
| echo "ios_from=$IOS_VERSION" >> $GITHUB_OUTPUT | |
| - name: Clone and update native SDKs | |
| if: inputs.android_version != '' || inputs.ios_version != '' | |
| run: | | |
| if [ -n "${{ inputs.android_version }}" ]; then | |
| VERSION="${{ inputs.android_version }}" | |
| if ! curl --fail --silent --show-error --retry 4 --retry-delay 30 \ | |
| -H "Authorization: token ${{ github.token }}" \ | |
| "https://api.github.com/repos/OneSignal/OneSignal-Android-SDK/releases/tags/${VERSION}" \ | |
| >/dev/null; then | |
| echo "✗ Android SDK version ${VERSION} not found" | |
| exit 1 | |
| fi | |
| fi | |
| if [ -n "${{ inputs.ios_version }}" ]; then | |
| VERSION="${{ inputs.ios_version }}" | |
| if ! curl --fail --silent --show-error --retry 4 --retry-delay 30 \ | |
| -H "Authorization: token ${{ github.token }}" \ | |
| "https://api.github.com/repos/OneSignal/OneSignal-iOS-SDK/releases/tags/${VERSION}" \ | |
| >/dev/null; then | |
| echo "✗ iOS SDK version ${VERSION} not found" | |
| exit 1 | |
| fi | |
| fi | |
| # Clone iOS SDK if ios_version is provided | |
| if [ -n "${{ inputs.ios_version }}" ]; then | |
| echo "Cloning iOS SDK..." | |
| IOS_CLONE_PATH="../OneSignal-iOS-SDK" | |
| # When called from the iOS SDK repo, ../OneSignal-iOS-SDK resolves to the | |
| # workspace itself. Clone to a temp path and set IOS_SDK_PATH for the script. | |
| RESOLVED=$(cd "$(dirname "$IOS_CLONE_PATH")" && echo "$(pwd)/$(basename "$IOS_CLONE_PATH")") | |
| if [ "$RESOLVED" = "$(pwd)" ]; then | |
| IOS_CLONE_PATH="${RUNNER_TEMP}/OneSignal-iOS-SDK" | |
| export IOS_SDK_PATH="$IOS_CLONE_PATH" | |
| fi | |
| git clone --branch ${{ inputs.ios_version }} --depth 1 https://github.com/OneSignal/OneSignal-iOS-SDK.git "$IOS_CLONE_PATH" | |
| fi | |
| echo "Running update_native_binaries.sh..." | |
| ARGS="" | |
| if [ -n "${{ inputs.android_version }}" ]; then | |
| ARGS="$ARGS --android_native_version=${{ inputs.android_version }}" | |
| fi | |
| if [ -n "${{ inputs.ios_version }}" ]; then | |
| ARGS="$ARGS --ios_native_version=${{ inputs.ios_version }}" | |
| fi | |
| ./update_native_binaries.sh $ARGS | |
| - name: Update .NET version in nuspec | |
| run: | | |
| VERSION=${{ inputs.dotnet_version }} | |
| echo "🔧 Updating .NET SDK version to $VERSION" | |
| sed -i '' "s|<version>.*</version>|<version>${VERSION}</version>|" OneSignalSDK.DotNet.nuspec | |
| echo "✅ Updated OneSignalSDK.DotNet.nuspec" | |
| # Only commit if there are changes | |
| git add -A | |
| git diff --staged --quiet && exit 0 | |
| git commit -m "Release $VERSION" && git push | |
| - name: Restore workloads | |
| run: dotnet workload restore | |
| - name: Check Build Errors | |
| run: | | |
| echo "Building Android SDK..." | |
| dotnet build OneSignalSDK.DotNet.Android/OneSignalSDK.DotNet.Android.csproj -c Release -f net10.0-android | |
| echo "Building iOS SDK..." | |
| dotnet build OneSignalSDK.DotNet.iOS/OneSignalSDK.DotNet.iOS.csproj -c Release -f net10.0-ios | |
| create-pr: | |
| needs: [prep, update-version] | |
| uses: OneSignal/sdk-shared/.github/workflows/create-release.yml@main | |
| secrets: | |
| # Need this cross-repo token (sdk-shared & this repo) to perform changes | |
| GH_PUSH_TOKEN: ${{ secrets.GH_PUSH_TOKEN }} | |
| with: | |
| # Need target_repo otherwise caller would set github.repository to the caller itself (e.g. sdk-shared) | |
| target_repo: OneSignal/OneSignal-DotNet-SDK | |
| release_branch: ${{ needs.prep.outputs.release_branch }} | |
| target_branch: ${{ inputs.target_branch }} | |
| android_from: ${{ needs.update-version.outputs.android_from }} | |
| android_to: ${{ inputs.android_version }} | |
| ios_from: ${{ needs.update-version.outputs.ios_from }} | |
| ios_to: ${{ inputs.ios_version }} |