From d383a05e5f3e3a8c5ca59a5bad2b76153e687435 Mon Sep 17 00:00:00 2001 From: Sergei Semko <28645140+justSmK@users.noreply.github.com> Date: Mon, 26 Jan 2026 12:13:21 +0300 Subject: [PATCH 1/2] WMSDK-608: Support app distribution from all branches (#154) Solution without GItLab API token With manual distribution, you can specify the branch name for the app. If there is no such branch, the workflow will fail and the logs will show an error stating that the branch could not be found. In all other cases, I always try to trigger a build on GitLab with the exact same branch as the one on which the distribution workflow runs. If there is no such branch, it triggers a build in GitLab on develop. --- .github/workflows/distribute-manual.yml | 8 +- .github/workflows/distribute-reusable.yml | 208 ++++++++++++++++++++-- 2 files changed, 197 insertions(+), 19 deletions(-) diff --git a/.github/workflows/distribute-manual.yml b/.github/workflows/distribute-manual.yml index 8c21bc7..7dfe64d 100644 --- a/.github/workflows/distribute-manual.yml +++ b/.github/workflows/distribute-manual.yml @@ -2,10 +2,16 @@ name: Distribute PushOk (manual) on: workflow_dispatch: + inputs: + app_ref: + description: "GitLab App branch (Optional)" + required: false + default: "" jobs: call-reusable: uses: ./.github/workflows/distribute-reusable.yml with: - branch: ${{ github.ref_name }} + branch: ${{ github.ref_name }} # SDK branch = current branch GitHub + app_ref: ${{ inputs.app_ref }} # optional override for GitLab ref secrets: inherit diff --git a/.github/workflows/distribute-reusable.yml b/.github/workflows/distribute-reusable.yml index f366954..7f064e9 100644 --- a/.github/workflows/distribute-reusable.yml +++ b/.github/workflows/distribute-reusable.yml @@ -6,25 +6,197 @@ on: branch: required: true type: string + app_ref: + required: false + type: string + default: "" + secrets: + GITLAB_TRIGGER_TOKEN: + required: true jobs: trigger: - runs-on: macos-latest + runs-on: ubuntu-latest steps: - - name: Checkout repository - uses: actions/checkout@v4 - with: - ref: ${{ inputs.branch }} - - - name: Get last 3 commit messages - run: | - commits=$(git log -3 --pretty=format:"%s") - echo "commits=$commits" >> $GITHUB_ENV - - - name: Trigger build workflow in react-native-app repo - run: | - curl --location 'https://mindbox.gitlab.yandexcloud.net/api/v4/projects/1512/trigger/pipeline' \ - --form 'token="${{ secrets.GITLAB_TRIGGER_TOKEN }}"' \ - --form 'ref="develop"' \ - --form "variables[INPUT_BRANCH]=\"${{ inputs.branch }}\"" \ - --form "variables[INPUT_COMMITS]=\"${{ env.commits }}\"" + - name: Checkout repository + uses: actions/checkout@v4 + with: + ref: ${{ inputs.branch }} + fetch-depth: 3 + + - name: Get last 3 commit messages + shell: bash + run: | + set -euo pipefail + commits="$(git log -3 --pretty=format:"%s")" + echo "commits<> "$GITHUB_ENV" + echo "$commits" >> "$GITHUB_ENV" + echo "EOF" >> "$GITHUB_ENV" + + - name: Debug payload that will be sent to GitLab + shell: bash + env: + SOURCE_BRANCH: ${{ inputs.branch }} + APP_REF_OVERRIDE: ${{ inputs.app_ref }} + DEFAULT_APP_REF: develop + INPUT_COMMITS: ${{ env.commits }} + run: | + set -euo pipefail + APP_REF_OVERRIDE="$(printf '%s' "${APP_REF_OVERRIDE:-}" | xargs)" + + echo "---- DEBUG (GitHub -> GitLab trigger payload) ----" + echo "SDK branch (INPUT_BRANCH): $SOURCE_BRANCH" + echo "Manual App ref override: ${APP_REF_OVERRIDE:-}" + echo "Default App ref: $DEFAULT_APP_REF" + echo "" + echo "RAW INPUT_COMMITS (cat -A):" + printf '%s' "${INPUT_COMMITS:-}" | cat -A + echo "" + echo "RAW INPUT_COMMITS (printf %q):" + printf '%q\n' "${INPUT_COMMITS:-}" + echo "--------------------------------------------------" + + - name: Trigger build workflow in react-native-app repo (override strict; else same->develop) + shell: bash + env: + GITLAB_HOST: mindbox.gitlab.yandexcloud.net + APP_PROJECT_ID: "1512" + DEFAULT_APP_REF: develop + + SOURCE_BRANCH: ${{ inputs.branch }} + APP_REF_OVERRIDE: ${{ inputs.app_ref }} + + GITLAB_TRIGGER_TOKEN: ${{ secrets.GITLAB_TRIGGER_TOKEN }} + INPUT_COMMITS: ${{ env.commits }} + run: | + set -euo pipefail + + # Trim override so " " becomes empty + APP_REF_OVERRIDE="$(printf '%s' "${APP_REF_OVERRIDE:-}" | xargs)" + + # Normalize commits: + # - convert CRLF -> LF + # - if commits accidentally contain literal "\n", expand them to real newlines + normalize_commits() { + local raw="${1:-}" + raw="$(printf '%s' "$raw" | tr -d '\r')" + if [[ "$raw" == *"\\n"* ]]; then + raw="$(printf '%b' "$raw")" + fi + printf '%s' "$raw" + } + + COMMITS_TO_SEND="$(normalize_commits "${INPUT_COMMITS:-}")" + + echo "SDK branch (INPUT_BRANCH): $SOURCE_BRANCH" + echo "Manual App ref override: ${APP_REF_OVERRIDE:-}" + echo "Default App ref: $DEFAULT_APP_REF" + echo "" + echo "COMMITS_TO_SEND preview (cat -A):" + printf '%s' "$COMMITS_TO_SEND" | cat -A + echo "" + + trigger_pipeline() { + local ref="$1" + local tmp_body + tmp_body="$(mktemp)" + + local code + code="$(curl -sS -o "$tmp_body" -w '%{http_code}' --location \ + --retry 3 --retry-all-errors --retry-delay 2 \ + "https://${GITLAB_HOST}/api/v4/projects/${APP_PROJECT_ID}/trigger/pipeline" \ + --form "token=${GITLAB_TRIGGER_TOKEN}" \ + --form "ref=${ref}" \ + --form "variables[INPUT_BRANCH]=${SOURCE_BRANCH}" \ + --form "variables[INPUT_COMMITS]=${COMMITS_TO_SEND}")" + + local body + body="$(cat "$tmp_body" 2>/dev/null || true)" + rm -f "$tmp_body" + + echo "Trigger HTTP: $code (ref=$ref)" + echo "Response body:" + echo "$body" + + if [[ "$code" == "200" || "$code" == "201" ]]; then + local web_url + web_url="$( + printf '%s\n' "$body" | + grep -o '"web_url":"[^"]*"' | + head -n 1 | + cut -d'"' -f4 + )" + if [[ -n "${web_url:-}" ]]; then + echo "Pipeline URL: $web_url" + fi + return 0 + fi + + if [[ "$code" == "401" || "$code" == "403" ]]; then + echo "Auth error (HTTP $code). Check that GITLAB_TRIGGER_TOKEN is valid and has access to project ${APP_PROJECT_ID}." + return 1 + fi + + # Missing ref: GitLab returns 400 + "Reference not found" + if [[ "$code" == "400" || "$code" == "404" ]]; then + if [[ "$body" == *"Reference not found"* ]]; then + return 2 + fi + + echo "Got HTTP $code but it's NOT 'Reference not found'." + echo "This can happen if pipelines are blocked for triggers by workflow:rules or job rules when CI_PIPELINE_SOURCE == 'trigger'." + echo "Check the target repo .gitlab-ci.yml rules/workflow:rules." + return 1 + fi + + if [[ "$code" =~ ^5[0-9][0-9]$ ]]; then + echo "Server error (HTTP $code). GitLab/proxy might be temporarily unavailable." + return 1 + fi + + echo "Unexpected HTTP status: $code" + return 1 + } + + # If override is provided: try ONLY override; if missing ref -> fail + if [[ -n "$APP_REF_OVERRIDE" ]]; then + echo "Override provided -> trying ONLY App ref: $APP_REF_OVERRIDE" + trigger_pipeline "$APP_REF_OVERRIDE" || rc=$? + rc="${rc:-0}" + + if [[ "$rc" == "0" ]]; then + echo "Triggered on override ref." + exit 0 + fi + + if [[ "$rc" == "2" ]]; then + echo "ERROR: App ref not found: $APP_REF_OVERRIDE (GitLab returned 'Reference not found')" + exit 1 + fi + + echo "Trigger failed for reasons other than missing ref." + exit 1 + fi + + # No override: same branch -> fallback develop + desired_ref="$SOURCE_BRANCH" + fallback_ref="$DEFAULT_APP_REF" + + echo "No override -> trying App ref: $desired_ref" + trigger_pipeline "$desired_ref" || rc=$? + rc="${rc:-0}" + + if [[ "$rc" == "0" ]]; then + echo "Triggered on same branch." + exit 0 + fi + + if [[ "$rc" == "2" ]]; then + echo "Same branch not found. Falling back to: $fallback_ref" + trigger_pipeline "$fallback_ref" + echo "Triggered on fallback ref." + exit 0 + fi + + echo "Trigger failed for reasons other than missing ref." + exit 1 From 1c4810f0110900aa921c0379ba8335020587913a Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 6 Apr 2026 10:13:33 +0000 Subject: [PATCH 2/2] Bump RN SDK versions: core=2.15.0, android=2.15.0, ios=2.15.0 --- CHANGELOG.md | 7 +++++++ MindboxSdk.podspec | 4 ++-- android/build.gradle | 2 +- package.json | 2 +- 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 32db3d9..e2ee9b2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # Changelog +## [Unreleased] + +### Changes +- Upgrade Android SDK dependency to v2.15.0 +- Upgrade iOS SDK dependency to v2.15.0 + + ## [2.14.6] - 2026-01-20 ### Changes diff --git a/MindboxSdk.podspec b/MindboxSdk.podspec index 6cd9d95..fdb1db1 100644 --- a/MindboxSdk.podspec +++ b/MindboxSdk.podspec @@ -17,6 +17,6 @@ Pod::Spec.new do |s| s.dependency "React-Core" - s.dependency "Mindbox", "2.14.5" - s.dependency "MindboxNotifications", "2.14.5" + s.dependency "Mindbox", "2.15.0" + s.dependency "MindboxNotifications", "2.15.0" end diff --git a/android/build.gradle b/android/build.gradle index fea7b90..605b2b1 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -126,5 +126,5 @@ dependencies { // noinspection GradleDynamicVersion api 'com.facebook.react:react-native:+' implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" - api 'cloud.mindbox:mobile-sdk:2.14.5' + api 'cloud.mindbox:mobile-sdk:2.15.0' } diff --git a/package.json b/package.json index 047d33e..f8a2946 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "mindbox-sdk", "version": "2.14.6", - "target-version": "2.14.6", + "target-version": "2.15.0", "description": "SDK for integration React Native mobile apps with Mindbox", "main": "lib/commonjs/index", "module": "lib/module/index",