Skip to content

Commit acf6437

Browse files
authored
WMSDK-440: Update checks, releases and distribution (#532)
* WMSDK-440: PushOk Distribution * WMSDK-440: Linter and Tests Except master branch * WMSDK-440: Prepare release branch and PR * WMSDK-440: Publish Scripts * WMSDK-440: Branch protection script * WMSDK-440: Update secret PAT naming * WMSDK-440: Fix distribute PushOk name * WMSDK-440: Fix manual release name * WMSDK-440: Fix manual release prep * WMSDK-440: Lint and test only by push * WMSDK-440: Fix release preparation
1 parent d03747d commit acf6437

11 files changed

+295
-22
lines changed
Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
1-
name: PushOk (Develop PR Merge)
1+
name: Distribute PushOk (Develop PR Merge)
22

33
on:
44
pull_request:
55
branches:
66
- develop
7-
- main
87
types:
98
- closed
109

1110
jobs:
1211
call-reusable:
1312
if: ${{ github.event.pull_request.merged == true }}
1413
uses: ./.github/workflows/distribute-reusable.yml
15-
secrets: inherit
14+
with:
15+
branch: ${{ github.base_ref }}
16+
secrets: inherit
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
name: Distribute PushOk (manual)
2+
3+
on:
4+
workflow_dispatch:
5+
6+
jobs:
7+
call-reusable:
8+
uses: ./.github/workflows/distribute-reusable.yml
9+
with:
10+
branch: ${{ github.ref_name }}
11+
secrets: inherit

.github/workflows/distribute-release-support.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
1-
name: PushOk (Release/Support PR)
1+
name: Distribute PushOk (Release / Support / Mission PRs)
22

33
on:
44
pull_request:
55
branches:
66
- master
7+
- support/*
8+
- mission/*
79
types:
810
- opened
911
- synchronize
1012

1113
jobs:
1214
call-reusable:
13-
if: ${{ startsWith(github.event.pull_request.head.ref, 'release/') || startsWith(github.event.pull_request.head.ref, 'support/') }}
15+
if: ${{ startsWith(github.event.pull_request.head.ref, 'release/') }}
1416
uses: ./.github/workflows/distribute-reusable.yml
17+
with:
18+
branch: ${{ github.event.pull_request.head.ref }}
1519
secrets: inherit
16-

.github/workflows/distribute-reusable.yml

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,30 @@ name: Distribute PushOk - Reusable
22

33
on:
44
workflow_call:
5+
inputs:
6+
branch:
7+
required: true
8+
type: string
9+
secrets:
10+
GITLAB_TRIGGER_TOKEN:
11+
required: true
512

613
jobs:
714
distribution:
815
runs-on: macos-15
916
steps:
1017
- name: Checkout repository
1118
uses: actions/checkout@v4
19+
with:
20+
ref: ${{ inputs.branch }}
21+
fetch-depth: 0
1222

1323
- name: Get last 3 commit messages
1424
run: |
1525
commits=$(git log -3 --pretty=format:"%s")
16-
echo "commits=$commits" >> $GITHUB_ENV
26+
echo "commits<<EOF" >> $GITHUB_ENV
27+
echo "$commits" >> $GITHUB_ENV
28+
echo "EOF" >> $GITHUB_ENV
1729
1830
- name: Get Mindbox SDK Version
1931
run: |
@@ -34,6 +46,6 @@ jobs:
3446
curl --location 'https://mindbox.gitlab.yandexcloud.net/api/v4/projects/1021/trigger/pipeline' \
3547
--form 'token="${{ secrets.GITLAB_TRIGGER_TOKEN }}"' \
3648
--form 'ref="develop"' \
37-
--form "variables[INPUT_BRANCH]=\"${{ github.ref_name }}\"" \
49+
--form "variables[INPUT_BRANCH]=\"${{ inputs.branch }}\"" \
3850
--form "variables[INPUT_COMMITS]=\"${{ env.commits }}\"" \
3951
--form "variables[INPUT_SDK_VERSION]=\"${{ env.sdkVersion }}\""

.github/workflows/linter_and_unit_tests.yml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
1-
name: SwiftLint + UnitTests
1+
name: SwiftLint & UnitTests
22

33
on:
44
push:
5-
branches:
6-
- '**'
7-
- '!master'
5+
branches-ignore:
6+
- master
87
paths-ignore:
98
- '**.md'
10-
tags-ignore:
11-
- '**'
129

1310
jobs:
1411
SwiftLint:
Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
name: "Manual Release Prep: Branch & Version Bump"
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
release_version:
7+
description: 'Release version (e.g. 1.2.3 or 1.2.3-rc)'
8+
required: true
9+
source_branch:
10+
description: 'Create branch from'
11+
required: true
12+
default: 'develop'
13+
target_branch:
14+
description: 'Pull Request to'
15+
required: true
16+
default: 'master'
17+
18+
jobs:
19+
validate-input:
20+
name: Validate release_version format
21+
runs-on: ubuntu-latest
22+
steps:
23+
- name: Check version matches semver or semver-rc
24+
run: |
25+
VER="${{ github.event.inputs.release_version }}"
26+
echo "→ release_version = $VER"
27+
if ! [[ "$VER" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-rc)?$ ]]; then
28+
echo "❌ release_version must be X.Y.Z or X.Y.Z-rc"
29+
exit 1
30+
fi
31+
32+
validate-branches:
33+
name: Validate branch names
34+
runs-on: ubuntu-latest
35+
needs: validate-input
36+
steps:
37+
- name: Checkout minimal repo
38+
uses: actions/checkout@v4
39+
with:
40+
fetch-depth: 0
41+
42+
- name: Validate source branch exists
43+
run: |
44+
SRC="${{ github.event.inputs.source_branch }}"
45+
if ! git ls-remote --heads origin "$SRC" | grep -q "$SRC"; then
46+
echo "❌ source_branch '$SRC' does not exist on origin"
47+
exit 1
48+
fi
49+
50+
- name: Validate target branch exists
51+
run: |
52+
DST="${{ github.event.inputs.target_branch }}"
53+
if ! git ls-remote --heads origin "$DST" | grep -q "$DST"; then
54+
echo "❌ target_branch '$DST' does not exist on origin"
55+
exit 1
56+
fi
57+
58+
bump_and_branch:
59+
name: Create release branch & bump version
60+
runs-on: macos-15
61+
needs: validate-branches
62+
outputs:
63+
release_branch: ${{ steps.bump.outputs.release_branch }}
64+
steps:
65+
- name: Checkout source branch
66+
uses: actions/checkout@v4
67+
with:
68+
ref: ${{ github.event.inputs.source_branch }}
69+
fetch-depth: 0
70+
71+
- name: Create release branch & bump version
72+
id: bump
73+
run: |
74+
VERSION="${{ github.event.inputs.release_version }}"
75+
SRC="${{ github.event.inputs.source_branch }}"
76+
REL="release/$VERSION"
77+
78+
echo "→ Branching from $SRC into $REL"
79+
git checkout -b "$REL"
80+
81+
echo "→ Running bump script on $REL"
82+
./.github/git-release-branch-create.sh "$VERSION"
83+
84+
echo "release_branch=$REL" >> $GITHUB_OUTPUT
85+
86+
- name: Push release branch
87+
run: |
88+
git push origin "${{ steps.bump.outputs.release_branch }}"
89+
90+
check_sdk_version:
91+
name: Check SDK Version
92+
runs-on: macos-15
93+
needs: bump_and_branch
94+
steps:
95+
- name: Checkout the release branch
96+
uses: actions/checkout@v4
97+
with:
98+
ref: ${{ needs.bump_and_branch.outputs.release_branch }}
99+
fetch-depth: 0
100+
101+
- name: Pull latest changes
102+
run: git pull
103+
104+
- name: Validate sdkVersion
105+
run: |
106+
EXPECT="${{ github.event.inputs.release_version }}"
107+
SDK_VERSION=$(sed -n 's/^.*sdkVersion = "\(.*\)"/\1/p' SDKVersionProvider/SDKVersionProvider.swift)
108+
echo "→ Found in code: $SDK_VERSION, expected: $EXPECT"
109+
if [ "$SDK_VERSION" != "$EXPECT" ]; then
110+
echo "❌ SDK version does not match!"
111+
exit 1
112+
fi
113+
114+
create_pull_request:
115+
name: Create Pull Request
116+
runs-on: ubuntu-latest
117+
needs: [bump_and_branch, check_sdk_version]
118+
steps:
119+
- name: Create PR via GitHub CLI
120+
env:
121+
GH_TOKEN: ${{ secrets.PAT_FOR_TRIGGERING_BRANCH_PROTECTION }}
122+
SRC: ${{ needs.bump_and_branch.outputs.release_branch }}
123+
DST: ${{ github.event.inputs.target_branch }}
124+
REPO: ${{ github.repository }}
125+
run: |
126+
echo "→ Creating PR from $SRC into $DST"
127+
gh pr create \
128+
--repo "$REPO" \
129+
--base "$DST" \
130+
--head "$SRC" \
131+
--title "Release ${{ github.event.inputs.release_version }}" \
132+
--body "Updates the release version to ${{ github.event.inputs.release_version }}. Automated PR: merge $SRC into $DST"

.github/workflows/prepare_release_branch.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ jobs:
6666

6767
create_pull_request:
6868
name: Create Pull Request
69-
runs-on: macos-15
69+
runs-on: ubuntu-latest
7070
needs: check_sdk_version
7171
steps:
7272
- name: Checkout code
@@ -82,5 +82,5 @@ jobs:
8282
PR_URL=$(gh pr view --json url --jq '.url')
8383
echo "PR_URL=$PR_URL" >> $GITHUB_ENV
8484
env:
85-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
85+
GH_TOKEN: ${{ secrets.PAT_FOR_TRIGGERING_BRANCH_PROTECTION }}
8686

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
name: SDK publish from master or support branch
2+
3+
on:
4+
pull_request:
5+
types: [closed]
6+
branches:
7+
- 'master'
8+
- 'support/*'
9+
10+
jobs:
11+
call-reusable:
12+
if: ${{ github.event.pull_request.merged == true }}
13+
uses: ./.github/workflows/publish-reusable.yml
14+
with:
15+
branch: ${{ github.base_ref }}
16+
secrets: inherit
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: SDK publish RC manual
2+
3+
on:
4+
workflow_dispatch:
5+
6+
jobs:
7+
check-branch:
8+
name: Check RC pattern for publish
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Check if branch matches pattern
12+
run: |
13+
if ! echo "${{ github.ref_name }}" | grep -q "release/.*-rc"; then
14+
echo "Branch name must match pattern 'release/*-rc' (e.g. release/2.13.2-rc)"
15+
exit 1
16+
fi
17+
18+
call-publish-reusable:
19+
needs: check-branch
20+
uses: ./.github/workflows/publish-reusable.yml
21+
with:
22+
branch: ${{ github.ref_name }}
23+
secrets: inherit
Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,20 @@
11
name: SDK publish
22

33
on:
4-
pull_request:
5-
types: [closed]
6-
branches:
7-
- 'master'
8-
- 'support/*'
4+
workflow_call:
5+
inputs:
6+
branch:
7+
required: true
8+
type: string
99

1010
jobs:
1111
unit-tests:
1212
if: github.event.pull_request.merged == true
1313
runs-on: macos-15
1414
steps:
1515
- uses: actions/checkout@v4
16+
with:
17+
ref: ${{ inputs.branch }}
1618
- uses: maxim-lobanov/setup-xcode@v1
1719
with:
1820
xcode-version: latest-stable
@@ -28,6 +30,8 @@ jobs:
2830
runs-on: ubuntu-latest
2931
steps:
3032
- uses: actions/checkout@v4
33+
with:
34+
ref: ${{ inputs.branch }}
3135
- name: Extract SDK version
3236
run: |
3337
SDK_VERSION=$(sed -n 's/^.*sdkVersion = "\(.*\)"/\1/p' SDKVersionProvider/SDKVersionProvider.swift)
@@ -43,6 +47,8 @@ jobs:
4347
runs-on: macos-15
4448
steps:
4549
- uses: actions/checkout@v4
50+
with:
51+
ref: ${{ inputs.branch }}
4652
- name: Update bundler
4753
run: gem install bundler
4854
- name: Install bundler dependencies
@@ -66,6 +72,8 @@ jobs:
6672
runs-on: macos-15
6773
steps:
6874
- uses: actions/checkout@v4
75+
with:
76+
ref: ${{ inputs.branch }}
6977
- name: Update bundler
7078
run: gem install bundler
7179
- name: Install bundler dependencies
@@ -85,6 +93,8 @@ jobs:
8593
runs-on: macos-15
8694
steps:
8795
- uses: actions/checkout@v4
96+
with:
97+
ref: ${{ inputs.branch }}
8898
- name: Update bundler
8999
run: gem install bundler
90100
- name: Install bundler dependencies
@@ -110,6 +120,8 @@ jobs:
110120
runs-on: macos-15
111121
steps:
112122
- uses: actions/checkout@v4
123+
with:
124+
ref: ${{ inputs.branch }}
113125
- name: Update bundler
114126
run: gem install bundler
115127
- name: Install bundler dependencies
@@ -128,14 +140,16 @@ jobs:
128140
runs-on: ubuntu-latest
129141
steps:
130142
- uses: actions/checkout@v4
143+
with:
144+
ref: ${{ inputs.branch }}
131145
- name: Release generation
132146
run: ./.github/git-release.sh
133147
env:
134148
GH_TOKEN: ${{ github.token }}
135149

136150
merge:
137151
needs: [publish-MindboxLogger, publish-MindboxNotifications, publish-Mindbox]
138-
if: startsWith(github.head_ref, 'release/')
152+
if: startsWith(github.head_ref, 'release/') && github.base_ref == 'master'
139153
runs-on: ubuntu-latest
140154
steps:
141155
- name: Checkout develop branch

0 commit comments

Comments
 (0)