Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
88 changes: 65 additions & 23 deletions .github/bump_versions_in_release_branch.sh
Original file line number Diff line number Diff line change
@@ -1,49 +1,91 @@
#!/bin/bash
set -e

# Check if the parameter is provided
# === Validate input ===
if [ $# -eq 0 ]; then
echo "Please provide the release version number as a parameter."
exit 1
fi

# Check if the version number matches the semver format
if ! [[ $1 =~ ^[0-9]+\.[0-9]+\.[0-9]+(-rc)?$ ]]; then
echo "The release version number does not match the semver format (X.Y.Z or X.Y.Z-rc)."
exit 1
fi

# Check the current Git branch
version=$1
current_branch=$(git symbolic-ref --short HEAD)
echo "Currently on branch: $current_branch"
echo "Currently on branch: $current_branch"

if [[ ! $current_branch =~ ^(release|support)/[0-9]+\.[0-9]+\.[0-9]+(-rc)?$ ]]; then
echo "The current Git branch ($current_branch) is not in the format 'release/X.Y.Z', 'release/X.Y.Z-rc', 'support/X.Y.Z' or 'support/X.Y.Z-rc'."
exit 1
echo "The current Git branch ($current_branch) is not in the correct format."
exit 1
fi

version=$1
# === Update gradle.properties ===
properties_file="gradle.properties"
if [ ! -f "$properties_file" ]; then
echo "❌ $properties_file not found."
exit 1
fi

# Show the current directory and its files
echo "Current directory: $(pwd)"
echo "Files in the current directory:"
ls -l
current_version=$(grep -E '^SDK_VERSION_NAME=' "$properties_file" | cut -d'=' -f2)
echo "→ Current SDK_VERSION_NAME: ${current_version:-<empty>}"
echo "→ Updating SDK_VERSION_NAME to $version"

# Add changelog to the index and create a commit
properties_file="gradle.properties"
current_version=$(grep -E '^KMP_SDK_VERSION_NAME=' gradle.properties | cut -d'=' -f2)
sed -i "s/^KMP_SDK_VERSION_NAME=.*/KMP_SDK_VERSION_NAME=$version/" $properties_file
if [[ "$OSTYPE" == "darwin"* ]]; then
sed -i '' "s/^SDK_VERSION_NAME=.*/SDK_VERSION_NAME=$version/" "$properties_file"
else
sed -i "s/^SDK_VERSION_NAME=.*/SDK_VERSION_NAME=$version/" "$properties_file"
fi

grep "^SDK_VERSION_NAME=" "$properties_file"
git add "$properties_file"

# Replace the current version with the new version in the Package.swift file
sed -i '' -E 's#(url: ")[^"]*(MindboxCommon\.xcframework\.zip)(",)#\1https://github.com/mindbox-cloud/kmp-common-sdk/releases/download/'"$VERSION"'/MindboxCommon.xcframework.zip\3#g' Package.swift
# === Update MindboxCommon.podspec (only s.version) ===
podspec_file="MindboxCommon.podspec"
if [ -f "$podspec_file" ]; then
echo "→ Updating $podspec_file version to $version"

if [[ "$OSTYPE" == "darwin"* ]]; then
sed -i '' -E "s|^[[:space:]]*s\.version[[:space:]]*=.*| s.version = '$version'|" "$podspec_file"
else
sed -i -E "s|^[[:space:]]*s\.version[[:space:]]*=.*| s.version = '$version'|" "$podspec_file"
fi

echo "Bump Common SDK version from $current_version to $version."
grep "s.version" "$podspec_file"
git add "$podspec_file"
else
echo "⚠️ $podspec_file not found, skipping podspec update."
fi

# === Commit changes ===
echo ""
git commit -m "Bump Common SDK version to $version" || echo "No changes to commit"

# === Validation ===
echo "→ Validating version bump..."
new_version=$(grep -E '^SDK_VERSION_NAME=' "$properties_file" | cut -d'=' -f2)

git add $properties_file
git commit -m "Bump Common SDK version to $version"
if [ "$new_version" != "$version" ]; then
echo "❌ Validation failed: expected SDK_VERSION_NAME=$version but found $new_version"
exit 1
fi

echo "Pushing changes to branch: $current_branch"
if ! git push origin $current_branch; then
echo "Failed to push changes to the origin $current_branch"
if [ -f "$podspec_file" ]; then
podspec_version=$(grep -E "^[[:space:]]*s\.version" "$podspec_file" | grep -Eo "[0-9]+\.[0-9]+\.[0-9]+(-rc)?")
if [ "$podspec_version" != "$version" ]; then
echo "❌ Validation failed: expected s.version=$version but found $podspec_version"
exit 1
fi
fi

echo "✅ Validation passed: version successfully updated to $version"

# === Push changes ===
echo "→ Pushing changes to branch: $current_branch"
if ! git push origin "$current_branch"; then
echo "❌ Failed to push changes to origin/$current_branch"
exit 1
fi

echo "✅ bump_versions_in_release_branch.sh completed successfully."
2 changes: 1 addition & 1 deletion .github/git-release-ci.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash
set -e

version=$(awk -F '"' '/val kmpSdkVersionName: String/ { print $2; exit }' mindbox-common/build.gradle.kts)
version=$(awk -F= '/^[[:space:]]*SDK_VERSION_NAME[[:space:]]*=/ { val=$2; sub(/#.*/,"",val); gsub(/[[:space:]]/,"",val); print val; exit }' gradle.properties)

is_beta=false
if [[ $version == *"rc"* ]]; then
Expand Down
32 changes: 4 additions & 28 deletions .github/workflows/manual-prepare_release_branch.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: "Manual Release Prep: Branch & Version Bump"
name: "1. Release branch manual preparation"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

А что за цифры, зачем они нужны?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

И названия скриптов надо оставить один в один как в других репозиториях. Чтобы легко контекст можно было переключать

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Продолжительная идея в том, чтобы при пине в Github Actions этот воркфлоу был наверху, так как это первый шаг

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Тут обсудили на дэйли, хотим попробовать такой формат в KMP, если приживется поправим везде. Дэдлайн пару месяцев


on:
workflow_dispatch:
Expand All @@ -23,7 +23,7 @@ jobs:
- name: Check version matches semver or semver-rc
run: |
VER="${{ github.event.inputs.release_version }}"
echo " release_version = $VER"
echo " release_version = $VER"
Comment thread
Vailence marked this conversation as resolved.
if ! [[ "$VER" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-rc)?$ ]]; then
echo "❌ release_version must be X.Y.Z or X.Y.Z-rc"
exit 1
Expand Down Expand Up @@ -92,34 +92,10 @@ jobs:
run: |
git push origin "${{ steps.bump.outputs.release_branch }}"

check_sdk_version:
name: Check SDK Version
runs-on: ubuntu-latest
needs: bump_and_branch
steps:
- name: Checkout the release branch
uses: actions/checkout@v4
with:
ref: ${{ needs.bump_and_branch.outputs.release_branch }}
fetch-depth: 0

- name: Pull latest changes
run: git pull

- name: Validate sdkVersion
run: |
EXPECT="${{ github.event.inputs.release_version }}"
SDK_VERSION=$(grep -E '^KMP_SDK_VERSION_NAME=' gradle.properties | cut -d'=' -f2)
echo "→ Found in code: $SDK_VERSION, expected: $EXPECT"
if [ "$SDK_VERSION" != "$EXPECT" ]; then
echo "❌ SDK version does not match!"
exit 1
fi

create_pull_request:
name: Create Pull Request
runs-on: ubuntu-latest
needs: [bump_and_branch, check_sdk_version]
needs: [bump_and_branch]
steps:
- name: Create PR via GitHub CLI
env:
Expand All @@ -134,4 +110,4 @@ jobs:
--base "$DST" \
--head "$SRC" \
--title "Release ${{ github.event.inputs.release_version }}" \
--body "Updates the release version to ${{ github.event.inputs.release_version }}. Automated PR: merge $SRC into $DST"
--body "Updates the release version to ${{ github.event.inputs.release_version }}. Automated PR: merge $SRC into $DST"
93 changes: 0 additions & 93 deletions .github/workflows/prepare_release_branch.yml

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/publish-from-master-or-support.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Common SDK publish from master or support branch
name: 2. Auto Github Release

on:
pull_request:
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/publish-manual.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Common SDK publish RC manual
name: 2. Manual Github Release


on:
Expand All @@ -10,8 +10,8 @@ jobs:
steps:
- name: Check if branch matches pattern
run: |
if ! echo "${{ github.ref_name }}" | grep -q "release/.*-rc"; then
echo "Branch name must match pattern 'release/*-rc' (e.g. release/2.13.2-rc)"
if ! echo "${{ github.ref_name }}" | grep -q "release/"; then
echo "Branch name must match pattern 'release' (e.g. release/2.13.2)"
exit 1
fi

Expand Down
Loading