From d35c1650ee71e45ce3be17f4d4daf85ef1109393 Mon Sep 17 00:00:00 2001 From: aslam ansari Date: Thu, 10 Sep 2026 10:10:32 +0530 Subject: [PATCH 1/2] [objC] Release workflow automation to create PR (#373) * updated workflow * added workflow to release on PR Merged * Rename prepare_release to prepare_release_PR * Delete draft_release.yml --- .github/workflows/prepare_release.yml | 106 ---------------- .github/workflows/prepare_release_PR.yml | 151 +++++++++++++++++++++++ 2 files changed, 151 insertions(+), 106 deletions(-) delete mode 100644 .github/workflows/prepare_release.yml create mode 100644 .github/workflows/prepare_release_PR.yml diff --git a/.github/workflows/prepare_release.yml b/.github/workflows/prepare_release.yml deleted file mode 100644 index b5754a7aa..000000000 --- a/.github/workflows/prepare_release.yml +++ /dev/null @@ -1,106 +0,0 @@ -name: Prepare Release - -on: - workflow_dispatch: - inputs: - release_type: - description: 'Release Type' - required: true - type: choice - options: - - major - - minor - version: - description: 'Base Version (e.g., 1.84 or 2.0)' - required: true - type: string - sync_tag: - description: 'Sync Tag (e.g., v1.84.0-pre1)' - required: true - type: string -permissions: - contents: write -jobs: - prepare-release: - runs-on: macos-14 - - steps: - - name: Checkout Code - uses: actions/checkout@v4 - with: - fetch-depth: 0 # Required to fetch all history for the merge check - - - name: Set up Git configuration - run: | - git config user.name "github-actions[bot]" - git config user.email "github-actions[bot]@users.noreply.github.com" - git fetch --all - - - name: Verify Previous Release is Merged (Major Only) - if: ${{ github.event.inputs.release_type == 'major' }} - run: | - echo "Finding the latest release branch on remote..." - - # List all remote release branches, sort them by version, and grab the highest one - LATEST_BRANCH=$(git branch -r --list "origin/grpc_release_*.x" | sort -V | tail -n 1 | sed 's/origin\///' | tr -d '[:space:]') - - if [ -z "$LATEST_BRANCH" ]; then - echo "⚠️ No previous release branches found on remote. Skipping merge check." - exit 0 - fi - - echo "Latest release branch found: $LATEST_BRANCH" - echo "Checking if $LATEST_BRANCH is merged into main..." - - # Check if the latest release branch is an ancestor of main - if ! git merge-base --is-ancestor origin/$LATEST_BRANCH origin/main; then - echo "❌ ERROR: $LATEST_BRANCH has NOT been merged into main!" - echo "Please merge the previous release branch into main before cutting a new major release." - exit 1 - else - echo "✅ $LATEST_BRANCH is successfully merged into main." - fi - - - name: Prepare Branch - id: branch_prep - run: | - VERSION="${{ github.event.inputs.version }}" - BRANCH_NAME="grpc_release_${VERSION}.x" - - if [ "${{ github.event.inputs.release_type }}" == "major" ]; then - echo "Preparing Major Release for $BRANCH_NAME..." - git checkout main - git checkout -b $BRANCH_NAME - else - echo "Preparing Minor Release for $BRANCH_NAME..." - # For minor releases, checkout the existing branch from remote - git checkout -b $BRANCH_NAME origin/$BRANCH_NAME - fi - - # Save branch name to environment for later steps - echo "branch_name=$BRANCH_NAME" >> $GITHUB_ENV - - - name: Prepare Environment - run: | - chmod +x ./scripts/prepare_env.sh - ./scripts/prepare_env.sh - - - name: Sync gRPC Code - run: | - source .venv/bin/activate - chmod +x ./scripts/sync_grpc_src_shallow.sh - ./scripts/sync_grpc_src_shallow.sh ${{ github.event.inputs.sync_tag }} - - - name: Commit Changes - run: | - git add . - git commit -m "Sync c-core ${{ github.event.inputs.sync_tag }}" - - - name: Push Branch and Tag - run: | - # 1. Push ONLY the new branch (main remains untouched) - git push origin ${{ env.branch_name }} - - # 2. Add the tag and push it - git tag ${{ github.event.inputs.sync_tag }} - git push origin ${{ github.event.inputs.sync_tag }} \ No newline at end of file diff --git a/.github/workflows/prepare_release_PR.yml b/.github/workflows/prepare_release_PR.yml new file mode 100644 index 000000000..fbe91b77c --- /dev/null +++ b/.github/workflows/prepare_release_PR.yml @@ -0,0 +1,151 @@ +name: Prepare Release PR + +on: + workflow_dispatch: + inputs: + release_type: + description: 'Release Type' + required: true + type: choice + options: + - major + - minor + version: + description: 'Base Version (e.g., 1.84 or 2.0)' + required: true + type: string + sync_tag: + description: 'Sync Tag (e.g., v1.84.0-pre1)' + required: true + type: string +permissions: + contents: write + pull-requests: write +jobs: + prepare-release: + runs-on: macos-14 + + steps: + - name: Checkout Code + uses: actions/checkout@v4 + with: + fetch-depth: 0 # Required to fetch all history for the merge check + + - name: Set up Git configuration + run: | + git config user.name "github-actions[bot]" + git config user.email "github-actions[bot]@users.noreply.github.com" + git fetch --all + + - name: Verify Previous Release is Merged (Major Only) + if: ${{ github.event.inputs.release_type == 'major' }} + run: | + VERSION="${{ github.event.inputs.version }}" + echo "Finding the latest release branch on remote..." + + # List all remote release branches, sort them by version, and grab the highest one (excluding current version if it already exists) + LATEST_BRANCH=$(git branch -r --list "origin/grpc_release_*.x" | sed 's/origin\///' | tr -d '[:space:]' | grep -v "^grpc_release_${VERSION}\.x$" | sort -V | tail -n 1) + + if [ -z "$LATEST_BRANCH" ]; then + echo "⚠️ No previous release branches found on remote. Skipping merge check." + exit 0 + fi + + echo "Latest release branch found: $LATEST_BRANCH" + echo "Checking if $LATEST_BRANCH is merged into main..." + + # Check if the latest release branch is an ancestor of main + if ! git merge-base --is-ancestor origin/$LATEST_BRANCH origin/main; then + echo "❌ ERROR: $LATEST_BRANCH has NOT been merged into main!" + echo "Please merge the previous release branch into main before cutting a new major release." + exit 1 + else + echo "✅ $LATEST_BRANCH is successfully merged into main." + fi + + - name: Prepare Branch + id: branch_prep + run: | + VERSION="${{ github.event.inputs.version }}" + SYNC_TAG="${{ github.event.inputs.sync_tag }}" + TARGET_BRANCH="grpc_release_${VERSION}.x" + SYNC_BRANCH="${SYNC_TAG}" + + if [ "${{ github.event.inputs.release_type }}" == "major" ]; then + echo "Preparing Major Release for $TARGET_BRANCH..." + git checkout -B main origin/main + git checkout -B "$TARGET_BRANCH" main + + # Push empty release branch if not already present on remote + if git show-ref --verify --quiet "refs/remotes/origin/$TARGET_BRANCH"; then + echo "⚠️ Target release branch $TARGET_BRANCH already exists on remote." + else + echo "Pushing empty branch $TARGET_BRANCH to origin..." + git push origin "$TARGET_BRANCH" + fi + + # Create sync branch from the empty branch + echo "Creating sync branch $SYNC_BRANCH from $TARGET_BRANCH..." + git checkout --no-track -B "$SYNC_BRANCH" "$TARGET_BRANCH" + else + echo "Preparing Minor Release for $TARGET_BRANCH..." + if ! git show-ref --verify --quiet "refs/remotes/origin/$TARGET_BRANCH"; then + echo "❌ ERROR: Target branch $TARGET_BRANCH does not exist on remote!" + echo "Please verify the base version or create the release branch first." + exit 1 + fi + + # Create sync branch from the existing release branch + echo "Creating sync branch $SYNC_BRANCH from origin/$TARGET_BRANCH..." + git checkout --no-track -B "$SYNC_BRANCH" "origin/$TARGET_BRANCH" + fi + + # Save branch names to environment for later steps + echo "target_branch=$TARGET_BRANCH" >> $GITHUB_ENV + echo "sync_branch=$SYNC_BRANCH" >> $GITHUB_ENV + + - name: Prepare Environment + run: | + chmod +x ./scripts/prepare_env.sh + ./scripts/prepare_env.sh + + - name: Sync gRPC Code + run: | + source .venv/bin/activate + chmod +x ./scripts/sync_grpc_src_shallow.sh + ./scripts/sync_grpc_src_shallow.sh ${{ github.event.inputs.sync_tag }} + + - name: Commit Changes + run: | + git add . + if git diff --staged --quiet; then + echo "No changes to commit." + else + git commit -m "Sync c-core ${{ github.event.inputs.sync_tag }}" + fi + + - name: Push Branch + run: | + echo "Pushing branch ${{ env.sync_branch }} to origin..." + git push -u origin ${{ env.sync_branch }} --force + + - name: Create Pull Request + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + EXISTING_PR=$(gh pr list --repo "${{ github.repository }}" --head "${{ env.sync_branch }}" --base "${{ env.target_branch }}" --state open --json url --jq '.[0].url // empty') + if [ -n "$EXISTING_PR" ]; then + echo "Pull request already exists: $EXISTING_PR" + echo "### Pull Request" >> $GITHUB_STEP_SUMMARY + echo "A pull request already exists: $EXISTING_PR" >> $GITHUB_STEP_SUMMARY + else + PR_URL=$(gh pr create \ + --repo "${{ github.repository }}" \ + --base "${{ env.target_branch }}" \ + --head "${{ env.sync_branch }}" \ + --title "Sync c-core ${{ github.event.inputs.sync_tag }}" \ + --body "Automated PR to sync gRPC c-core sources for \`${{ github.event.inputs.sync_tag }}\` into \`${{ env.target_branch }}\`.") + echo "Created pull request: $PR_URL" + echo "### Pull Request Created" >> $GITHUB_STEP_SUMMARY + echo "Successfully created pull request: $PR_URL" >> $GITHUB_STEP_SUMMARY + fi \ No newline at end of file From f80c2753a4bf51952519fc5ef09ebc5560f1d789 Mon Sep 17 00:00:00 2001 From: aslam ansari Date: Thu, 10 Sep 2026 14:46:12 +0530 Subject: [PATCH 2/2] updated the script to run linting only for iOS (#378) --- scripts/release_cocoapod.sh | 3 +++ scripts/skip_pod_push_lint.sh | 28 ++++++++++++++-------------- scripts/wait_for_pod_release.sh | 1 + 3 files changed, 18 insertions(+), 14 deletions(-) diff --git a/scripts/release_cocoapod.sh b/scripts/release_cocoapod.sh index 3054b83b7..cca9a2636 100755 --- a/scripts/release_cocoapod.sh +++ b/scripts/release_cocoapod.sh @@ -13,6 +13,9 @@ if [ -z "$TARGET_PODSPEC" ]; then exit 1 fi +# Configure pod trunk push lint to validate on iOS only (--no-subspecs --fail-fast) +"$(dirname "$0")/skip_pod_push_lint.sh" + echo "Publishing podspec $TARGET_PODSPEC" pushd ${TARGET_DIR} diff --git a/scripts/skip_pod_push_lint.sh b/scripts/skip_pod_push_lint.sh index f7c352164..2cffb9a2b 100755 --- a/scripts/skip_pod_push_lint.sh +++ b/scripts/skip_pod_push_lint.sh @@ -1,20 +1,20 @@ #!/bin/bash # -# Script to disable pod lint during trunk push. -# -# The script provides an ad-hoc patch to the internal cocoapod push command by removing the -# validation / lint steps. The script should be relatively stable for runners with a fixed virtual -# mac os x image, but may require updates to the Gem/Trunk versioning if upgrading to a new runner +# Script to optimize pod lint during trunk push so it validates on iOS only +# (with --no-subspecs and --fail-fast) instead of compiling across all 5 platforms. +# This ensures any podspec, dependency, or compilation error is caught while +# keeping validation under ~20 minutes instead of exceeding the 6-hour timeout. set -ex -# env setup -GEM_VERSION=3.0.0 -POD_TRUNK_VERSION=1.6.0 +PUSH_FILES=$(find /opt/homebrew /usr/local /Library/Ruby "$HOME/.gem" $(gem env gemdir 2>/dev/null) \ + -name "push.rb" -path "*/cocoapods-trunk-*/lib/pod/command/trunk/push.rb" 2>/dev/null | sort -u) -# PUSH_FILE_DIR="/Library/Ruby/Gems/2.6.0/gems/cocoapods-trunk-1.6.0/lib/pod/command/trunk" -PUSH_FILE_DIR="/usr/local/lib/ruby/gems/${GEM_VERSION}/gems/cocoapods-trunk-${POD_TRUNK_VERSION}/lib/pod/command/trunk" +if [ -z "$PUSH_FILES" ]; then + echo "ERROR: Could not locate cocoapods-trunk push.rb" + exit 1 +fi -# remove validation steps -pushd $PUSH_FILE_DIR -sudo sed -i "" 's/^ *validate_podspec//' push.rb -popd +for PUSH_FILE in $PUSH_FILES; do + echo "Patching $PUSH_FILE to validate podspec on iOS with no_subspecs and fail_fast..." + sudo sed -i "" "s/Validator.new(spec, \[repo_url\])/Validator.new(spec, [repo_url], ['ios']); validator.no_subspecs = true; validator.fail_fast = true/" "$PUSH_FILE" +done diff --git a/scripts/wait_for_pod_release.sh b/scripts/wait_for_pod_release.sh index 1e9cdc91f..1cac5171a 100755 --- a/scripts/wait_for_pod_release.sh +++ b/scripts/wait_for_pod_release.sh @@ -17,6 +17,7 @@ do echo "Version found!" break fi + sleep 30 done