diff --git a/.github/workflows/trigger-build-app-develop.yml b/.github/workflows/distribute-develop.yml similarity index 68% rename from .github/workflows/trigger-build-app-develop.yml rename to .github/workflows/distribute-develop.yml index a6a42ee..c2e34ed 100644 --- a/.github/workflows/trigger-build-app-develop.yml +++ b/.github/workflows/distribute-develop.yml @@ -1,4 +1,4 @@ -name: Distribute PushOk (Develop PR Merge) +name: PushOk (Develop PR Merge) on: pull_request: @@ -9,7 +9,7 @@ on: jobs: call-reusable: if: ${{ github.event.pull_request.merged == true }} - uses: ./.github/workflows/trigger-build-app-reusable.yml + uses: ./.github/workflows/distribute-reusable.yml with: branch: ${{ github.base_ref }} secrets: inherit diff --git a/.github/workflows/trigger-build-app-manual.yml b/.github/workflows/distribute-manual.yml similarity index 71% rename from .github/workflows/trigger-build-app-manual.yml rename to .github/workflows/distribute-manual.yml index b3cd1fc..8c21bc7 100644 --- a/.github/workflows/trigger-build-app-manual.yml +++ b/.github/workflows/distribute-manual.yml @@ -5,7 +5,7 @@ on: jobs: call-reusable: - uses: ./.github/workflows/trigger-build-app-reusable.yml + uses: ./.github/workflows/distribute-reusable.yml with: branch: ${{ github.ref_name }} secrets: inherit diff --git a/.github/workflows/trigger-build-app-master-support.yml b/.github/workflows/distribute-release-support-mission.yml similarity index 72% rename from .github/workflows/trigger-build-app-master-support.yml rename to .github/workflows/distribute-release-support-mission.yml index 3061184..06ffa4c 100644 --- a/.github/workflows/trigger-build-app-master-support.yml +++ b/.github/workflows/distribute-release-support-mission.yml @@ -1,4 +1,4 @@ -name: Distribute PushOk (Release / Support PR / Mission) +name: Distribute PushOk (Release / Support / Mission PRs) on: pull_request: @@ -13,7 +13,7 @@ on: jobs: call-reusable: if: ${{ startsWith(github.event.pull_request.head.ref, 'release/') }} - uses: ./.github/workflows/trigger-build-app-reusable.yml + uses: ./.github/workflows/distribute-reusable.yml with: branch: ${{ github.event.pull_request.head.ref }} secrets: inherit diff --git a/.github/workflows/trigger-build-app-reusable.yml b/.github/workflows/distribute-reusable.yml similarity index 95% rename from .github/workflows/trigger-build-app-reusable.yml rename to .github/workflows/distribute-reusable.yml index 271c199..f366954 100644 --- a/.github/workflows/trigger-build-app-reusable.yml +++ b/.github/workflows/distribute-reusable.yml @@ -1,4 +1,4 @@ -name: Distribute PushOk (Reusable) +name: Distribute PushOk - Reusable on: workflow_call: diff --git a/.github/workflows/manual-prepare_release_branch.yml b/.github/workflows/manual-prepare_release_branch.yml new file mode 100644 index 0000000..7ad4a18 --- /dev/null +++ b/.github/workflows/manual-prepare_release_branch.yml @@ -0,0 +1,192 @@ +name: "Manual Release Prep: React Native" + +on: + workflow_dispatch: + inputs: + release_version: + description: 'React Native release version (semver: X.Y.Z or X.Y.Z-rc)' + required: true + android_sdk_version: + description: 'Native Android SDK version (optional, defaults to RN version)' + required: false + default: '' + ios_sdk_version: + description: 'Native iOS SDK version (optional, defaults to RN version)' + required: false + default: '' + source_branch: + description: 'Create branch from' + required: true + default: 'develop' + target_branch: + description: 'Pull Request to' + required: true + default: 'master' + +jobs: + validate-input: + name: Validate versions format + runs-on: ubuntu-latest + steps: + - name: Check release_version + run: | + V=${{ github.event.inputs.release_version }} + echo "Input release_version=$V" + if ! [[ "$V" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-rc)?$ ]]; then + echo "❌ release_version must be X.Y.Z or X.Y.Z-rc" + exit 1 + fi + - name: Check android_sdk_version if set + if: ${{ github.event.inputs.android_sdk_version != '' }} + run: | + A=${{ github.event.inputs.android_sdk_version }} + echo "Input android_sdk_version=$A" + if ! [[ "$A" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-rc)?$ ]]; then + echo "❌ android_sdk_version must be X.Y.Z or X.Y.Z-rc" + exit 1 + fi + - name: Check ios_sdk_version if set + if: ${{ github.event.inputs.ios_sdk_version != '' }} + run: | + I=${{ github.event.inputs.ios_sdk_version }} + echo "Input ios_sdk_version=$I" + if ! [[ "$I" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-rc)?$ ]]; then + echo "❌ ios_sdk_version must be X.Y.Z or X.Y.Z-rc" + exit 1 + fi + + validate-branches: + name: Validate source & target branches exist + runs-on: ubuntu-latest + needs: validate-input + steps: + - uses: actions/checkout@v4 + with: { fetch-depth: 0 } + - name: Check source branch + run: | + SRC=${{ github.event.inputs.source_branch }} + if ! git ls-remote --heads origin "$SRC" | grep -q "$SRC"; then + echo "❌ source_branch '$SRC' does not exist on origin" + exit 1 + fi + - name: Check target branch + run: | + DST=${{ github.event.inputs.target_branch }} + if ! git ls-remote --heads origin "$DST" | grep -q "$DST"; then + echo "❌ target_branch '$DST' does not exist on origin" + exit 1 + fi + + bump_and_branch: + name: Create release branch & bump versions + runs-on: ubuntu-latest + needs: validate-branches + outputs: + release_branch: ${{ steps.bump.outputs.release_branch }} + steps: + - uses: actions/checkout@v4 + with: + ref: ${{ github.event.inputs.source_branch }} + fetch-depth: 0 + + - name: Configure Git + run: | + git config user.name "github-actions[bot]" + git config user.email "41898282+github-actions[bot]@users.noreply.github.com" + + - id: bump + name: Create branch & apply bumps + run: | + set -euo pipefail + VERSION="${{ github.event.inputs.release_version }}" + AND_VER="${{ github.event.inputs.android_sdk_version }}" + IO_VER="${{ github.event.inputs.ios_sdk_version }}" + SRC="${{ github.event.inputs.source_branch }}" + REL="release/$VERSION" + + # fallback to RN version + [ -z "$AND_VER" ] && AND_VER="$VERSION" + [ -z "$IO_VER" ] && IO_VER="$VERSION" + + echo "→ Branching from $SRC into $REL" + git checkout -b "$REL" + + ############################################################################## + # 1) package.json: bump "target-version" + ############################################################################## + echo "→ Bumping package.json target-version" + sed -i "s/\"target-version\": \".*\"/\"target-version\": \"$VERSION\"/" package.json + git add package.json + + ############################################################################## + # 2) Android build.gradle: bump cloud.mindbox:mobile-sdk: + ############################################################################## + echo "→ Bumping Android SDK in android/build.gradle" + sed -i "s|\(api 'cloud.mindbox:mobile-sdk:\).*|\1$AND_VER'|" android/build.gradle + git add android/build.gradle + + ############################################################################## + # 3) iOS podspec: bump Mindbox and MindboxNotifications dependencies + ############################################################################## + echo "→ Bumping iOS SDK in MindboxSdk.podspec" + sed -i -E "s/(s\.dependency \"Mindbox\", \").*(\")/\1$IO_VER\2/" MindboxSdk.podspec + sed -i -E "s/(s\.dependency \"MindboxNotifications\", \").*(\")/\1$IO_VER\2/" MindboxSdk.podspec + git add MindboxSdk.podspec + + ############################################################################## + # 4) CHANGELOG.md: insert Unreleased section at top + ############################################################################## + echo "→ Inserting Unreleased section into CHANGELOG.md" + awk -v a="$AND_VER" -v i="$IO_VER" ' + /^# Changelog/ { + print + print "" + print "## [Unreleased]" + print "" + print "### Changes" + print "- Upgrade Android SDK dependency to v" a + print "- Upgrade iOS SDK dependency to v" i + print "" + next + } + { print } + ' CHANGELOG.md > CHANGELOG.tmp && mv CHANGELOG.tmp CHANGELOG.md + git add CHANGELOG.md + + ############################################################################## + # 5) Final commit + ############################################################################## + git commit -m "Bump RN SDK versions: core=$VERSION, android=$AND_VER, ios=$IO_VER" + echo "release_branch=$REL" >> $GITHUB_OUTPUT + + - name: Push release branch + run: git push --set-upstream origin ${{ steps.bump.outputs.release_branch }} + + create_pull_request: + name: Create Pull Request + runs-on: ubuntu-latest + needs: bump_and_branch + steps: + - name: Build PR body and open PR + env: + GITHUB_TOKEN: ${{ secrets.PAT_FOR_TRIGGERING_BRANCH_PROTECTION }} + SRC: ${{ needs.bump_and_branch.outputs.release_branch }} + DST: ${{ github.event.inputs.target_branch }} + REPO: ${{ github.repository }} + run: | + AND_VER=${{ github.event.inputs.android_sdk_version }} + IO_VER=${{ github.event.inputs.ios_sdk_version }} + [ -z "$AND_VER" ] && AND_VER="${{ github.event.inputs.release_version }}" + [ -z "$IO_VER" ] && IO_VER="${{ github.event.inputs.release_version }}" + + BODY=$( + printf 'Automated PR: merge `%s` into `%s`\n\n**Versions:**\n- React Native SDK: `%s`\n- Android SDK: `%s`\n- iOS SDK: `%s`' \ + "$SRC" "$DST" "${{ github.event.inputs.release_version }}" "$AND_VER" "$IO_VER" + ) + + gh pr create \ + --repo "$REPO" \ + --base "$DST" \ + --head "$SRC" \ + --title "Release ${{ github.event.inputs.release_version }}" \ + --body "$BODY" diff --git a/.github/workflows/publish-master.yml b/.github/workflows/publish-from-master-or-support.yml similarity index 93% rename from .github/workflows/publish-master.yml rename to .github/workflows/publish-from-master-or-support.yml index 91e6326..9f75a8f 100644 --- a/.github/workflows/publish-master.yml +++ b/.github/workflows/publish-from-master-or-support.yml @@ -2,7 +2,7 @@ name: SDK publish from master or support branch on: pull_request: - types: [ closed ] + types: [closed] branches: - 'master' - 'support/*' diff --git a/.github/workflows/publish-manual.yml b/.github/workflows/publish-manual.yml index 3498cc2..c4f2669 100644 --- a/.github/workflows/publish-manual.yml +++ b/.github/workflows/publish-manual.yml @@ -1,4 +1,4 @@ -name: SDK publish manual +name: SDK publish RC manual on: workflow_dispatch: diff --git a/.github/workflows/publish-reusable.yml b/.github/workflows/publish-reusable.yml index 75922c3..37efa1a 100644 --- a/.github/workflows/publish-reusable.yml +++ b/.github/workflows/publish-reusable.yml @@ -96,6 +96,8 @@ jobs: startsWith(github.head_ref, 'release') && github.base_ref == 'master' runs-on: ubuntu-latest + env: + GITHUB_TOKEN: ${{ secrets.PAT_FOR_TRIGGERING_BRANCH_PROTECTION }} steps: - name: Checkout develop branch uses: actions/checkout@v4 @@ -103,11 +105,7 @@ jobs: ref: develop - name: Create Pull Request run: gh pr create --base develop --head master --title "Merge 'master' into 'develop' after release" --body "Automated Pull Request to merge 'master' into 'develop' after release" - env: - GITHUB_TOKEN: ${{ secrets.PAT_FOR_TRIGGERING_BRANCH_PROTECTION }} - name: Merge Pull Request run: | pr_number=$(gh pr list --base develop --head master --json number --jq '.[0].number') gh pr merge $pr_number --merge --auto - env: - GITHUB_TOKEN: ${{ secrets.PAT_FOR_TRIGGERING_BRANCH_PROTECTION }} diff --git a/.github/workflows/release-version-check.yml b/.github/workflows/release-version-check.yml index 2dbe862..fbdd6c5 100644 --- a/.github/workflows/release-version-check.yml +++ b/.github/workflows/release-version-check.yml @@ -1,4 +1,4 @@ -name: release-version-check +name: Branch Protection on: pull_request: