Skip to content

Commit ad6ada2

Browse files
authored
[MOB-10788] - Github Action Pre Release (#893)
1 parent 6047778 commit ad6ada2

File tree

3 files changed

+113
-0
lines changed

3 files changed

+113
-0
lines changed
Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
name: Prepare For Release
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
version:
7+
description: 'Version number (e.g., 6.5.0)'
8+
required: true
9+
type: string
10+
jira_ticket:
11+
description: 'JIRA ticket MOB number (e.g., 1234)'
12+
required: true
13+
type: string
14+
15+
permissions:
16+
contents: write
17+
pull-requests: write
18+
19+
jobs:
20+
prepare-release:
21+
runs-on: macos-latest
22+
steps:
23+
- uses: actions/checkout@v4
24+
with:
25+
token: ${{ secrets.GITHUB_TOKEN }}
26+
27+
- name: Update Changelog
28+
id: update_changelog
29+
run: |
30+
changelog_file="CHANGELOG.md"
31+
32+
# Function to extract content between two patterns, including the first pattern
33+
extract_between() {
34+
awk "/^## \[$1\]/{p=1;print;next} /^## \[/{p=0} p" "$3"
35+
}
36+
37+
# Get the unreleased content
38+
unreleased_content=$(extract_between "Unreleased" "[0-9]" "$changelog_file")
39+
40+
if [ -z "$unreleased_content" ]; then
41+
echo "No unreleased changes found in $changelog_file"
42+
exit 1
43+
fi
44+
45+
# Get the current version
46+
current_version=$(grep -oP "^## \[\K[0-9]+\.[0-9]+\.[0-9]+(?:-[a-zA-Z0-9]+)?(?=\])" "$changelog_file" | head -n1)
47+
new_version="${{ github.event.inputs.version }}"
48+
49+
# Validate version format
50+
if ! [[ $new_version =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9]+)?$ ]]; then
51+
echo "Invalid version format. Please use semantic versioning (e.g., 6.5.0 or 6.5.0-beta1)"
52+
exit 1
53+
fi
54+
55+
echo "new_version=${new_version}" >> $GITHUB_OUTPUT
56+
57+
# Create temporary file
58+
temp_file=$(mktemp)
59+
60+
# Preserve header and write new content
61+
{
62+
# Preserve the header (first 4 lines)
63+
head -n 4 "$changelog_file"
64+
echo "## [Unreleased]"
65+
echo ""
66+
echo "## [$new_version]"
67+
# Remove the "## [Unreleased]" line from unreleased_content if it exists
68+
echo "$unreleased_content" | sed '1{/^## \[Unreleased\]/d}'
69+
echo ""
70+
# Get the rest of the file starting from the first version entry
71+
sed -n '/^## \[[0-9]/,$p' "$changelog_file"
72+
} > "$temp_file"
73+
74+
# Replace original file
75+
mv "$temp_file" "$changelog_file"
76+
77+
- name: Update Version Numbers
78+
run: |
79+
# Update Iterable-iOS-SDK.podspec
80+
sed -i '' "s/\(s\.version[[:space:]]*=[[:space:]]*\)\".*\"/\1\"${{ github.event.inputs.version }}\"/" Iterable-iOS-SDK.podspec
81+
82+
# Update Iterable-iOS-AppExtensions.podspec
83+
sed -i '' "s/\(s\.version[[:space:]]*=[[:space:]]*\)\".*\"/\1\"${{ github.event.inputs.version }}\"/" Iterable-iOS-AppExtensions.podspec
84+
85+
# Update sdkVersion in IterableAPI.swift
86+
find . -name "IterableAPI.swift" -type f -exec sed -i '' "s/\(static let sdkVersion[[:space:]]*=[[:space:]]*\)\".*\"/\1\"${{ github.event.inputs.version }}\"/" {} \;
87+
88+
- name: Create Pull Request
89+
uses: peter-evans/create-pull-request@v5
90+
with:
91+
token: ${{ secrets.GITHUB_TOKEN }}
92+
title: "MOB-${{ github.event.inputs.jira_ticket }}: Prepare for Release ${{ steps.update_changelog.outputs.new_version }}"
93+
body: |
94+
# Prepare for Release ${{ steps.update_changelog.outputs.new_version }}
95+
96+
## SDK Release Checklist
97+
- [ ] CHANGELOG.md updated with correct version
98+
- [ ] Version numbers updated:
99+
- [ ] Iterable-iOS-SDK.podspec
100+
- [ ] Iterable-iOS-AppExtensions.podspec
101+
- [ ] sdkVersion in IterableAPI.swift
102+
- [ ] README.md reviewed (if needed)
103+
- [ ] All tests passing
104+
- [ ] Documentation updated (if needed)
105+
106+
branch: "MOB-${{ github.event.inputs.jira_ticket }}-prepare-for-release-${{ steps.update_changelog.outputs.new_version }}"
107+
commit-message: "[MOB-${{ github.event.inputs.jira_ticket }}]: Prepare for release ${{ steps.update_changelog.outputs.new_version }}"
108+
labels: release
109+
delete-branch: true

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,4 @@ CI.swift
2727
.build/arm64-apple-macosx/debug/index/db/v13/p25195--4de704/data.mdb
2828
.build/workspace-state.json
2929
*.mdb
30+
.build/arm64-apple-macosx/debug/IterableSDK.build/output-file-map.json

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
All notable changes to this project will be documented in this file.
44
This project adheres to [Semantic Versioning](http://semver.org/).
55

6+
## [Unreleased]
7+
- Adding section for unreleased changes
8+
69
## [6.5.11]
710
### Fixed
811
- Added missing constructor for `IterableAPIMobileFrameworkInfo`

0 commit comments

Comments
 (0)