Skip to content

Commit c6b8a95

Browse files
added a release script
1 parent bf4acd3 commit c6b8a95

File tree

6 files changed

+265
-1
lines changed

6 files changed

+265
-1
lines changed

CHANGELOG.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# StreamChatSwiftUI iOS SDK CHANGELOG
2+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
3+
4+
# Upcoming
5+
6+
### ✅ Added
7+
- Infrastructure improvements (GitHub actions, release scripts)
8+
- Unit tests
9+
10+
### 🐞 Fixed
11+
- Localization improvements
12+
13+
# [4.6.0](https://github.com/GetStream/stream-chat-swiftui/releases/tag/4.6.0)
14+
_December 01, 2021_
15+
16+
### ✅ Added
17+
This is the first version of the SwiftUI SDK for Stream Chat. It includes the following features:
18+
19+
- channel list
20+
- message list
21+
- message composer
22+
- message reactions
23+
- customization of components
24+
- sample app

StreamChatSwiftUI.xcodeproj/project.pbxproj

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,13 @@
226226
/* End PBXBuildFile section */
227227

228228
/* Begin PBXContainerItemProxy section */
229+
844AE868275EB8CF003225E5 /* PBXContainerItemProxy */ = {
230+
isa = PBXContainerItemProxy;
231+
containerPortal = 8465FBAC2746873A00AF091E /* Project object */;
232+
proxyType = 1;
233+
remoteGlobalIDString = 8465FCBB27468B6900AF091E;
234+
remoteInfo = DemoAppSwiftUI;
235+
};
229236
8465FBBF2746873A00AF091E /* PBXContainerItemProxy */ = {
230237
isa = PBXContainerItemProxy;
231238
containerPortal = 8465FBAC2746873A00AF091E /* Project object */;
@@ -540,9 +547,9 @@
540547
8465FBC12746873A00AF091E /* StreamChatSwiftUITests */ = {
541548
isa = PBXGroup;
542549
children = (
543-
84C94C7E27567D3F007FE2B9 /* StreamChatSwiftUITests-Bridging-Header.h */,
544550
84C94D4027579EAF007FE2B9 /* Tests */,
545551
84C94D3F27579E9B007FE2B9 /* Infrastructure */,
552+
84C94C7E27567D3F007FE2B9 /* StreamChatSwiftUITests-Bridging-Header.h */,
546553
);
547554
path = StreamChatSwiftUITests;
548555
sourceTree = "<group>";
@@ -1055,6 +1062,7 @@
10551062
);
10561063
dependencies = (
10571064
8465FBC02746873A00AF091E /* PBXTargetDependency */,
1065+
844AE869275EB8CF003225E5 /* PBXTargetDependency */,
10581066
);
10591067
name = StreamChatSwiftUITests;
10601068
productName = StreamChatSwiftUITests;
@@ -1407,6 +1415,11 @@
14071415
/* End PBXSourcesBuildPhase section */
14081416

14091417
/* Begin PBXTargetDependency section */
1418+
844AE869275EB8CF003225E5 /* PBXTargetDependency */ = {
1419+
isa = PBXTargetDependency;
1420+
target = 8465FCBB27468B6900AF091E /* DemoAppSwiftUI */;
1421+
targetProxy = 844AE868275EB8CF003225E5 /* PBXContainerItemProxy */;
1422+
};
14101423
8465FBC02746873A00AF091E /* PBXTargetDependency */ = {
14111424
isa = PBXTargetDependency;
14121425
target = 8465FBB42746873A00AF091E /* StreamChatSwiftUI */;

StreamChatSwiftUI.xcodeproj/xcshareddata/xcschemes/DemoAppSwiftUI.xcscheme

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,16 @@
2828
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
2929
shouldUseLaunchSchemeArgsEnv = "YES">
3030
<Testables>
31+
<TestableReference
32+
skipped = "NO">
33+
<BuildableReference
34+
BuildableIdentifier = "primary"
35+
BlueprintIdentifier = "844AE86D275EBA09003225E5"
36+
BuildableName = "DemoAppSwiftUIUITests.xctest"
37+
BlueprintName = "DemoAppSwiftUIUITests"
38+
ReferencedContainer = "container:StreamChatSwiftUI.xcodeproj">
39+
</BuildableReference>
40+
</TestableReference>
3141
</Testables>
3242
</TestAction>
3343
<LaunchAction

fastlane/Fastfile

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,69 @@ before_all do
1111
end
1212
end
1313

14+
desc "Release a new version"
15+
lane :release do |options|
16+
ensure_git_branch(branch: 'main') # We can only release on default branch
17+
ensure_git_status_clean unless options[:no_ensure_clean]
18+
19+
UI.user_error!("Please set GITHUB_TOKEN environment value. See https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token") unless !ENV["GITHUB_TOKEN"].nil?
20+
21+
if (!options[:version].nil?) # User passed a version, use it
22+
version_number = options.fetch(:version)
23+
increment_version_number_in_plist(version_number: version_number, xcodeproj: "StreamChatSwiftUI.xcodeproj", target: "StreamChatSwiftUI")
24+
else
25+
UI.user_error!("Please use type parameter with one of the options: type:patch, type:minor, type:major") unless ["patch", "minor", "major"].include?(options[:type])
26+
version_number = increment_version_number_in_plist(bump_type: options[:type], xcodeproj: "StreamChatSwiftUI.xcodeproj", target: "StreamChatSwiftUI")
27+
end
28+
29+
if git_tag_exists(tag: version_number)
30+
UI.user_error!("Tag for version #{version_number} already exists!")
31+
end
32+
33+
changes = touch_changelog(release_version: version_number)
34+
35+
# Make sure the podspecs actually build before pushing
36+
pod_lib_lint(podspec: "StreamChatSwiftUI.podspec", allow_warnings: true)
37+
38+
version_bump_podspec(path: "StreamChatSwiftUI.podspec", version_number: version_number)
39+
40+
sh("git add -A")
41+
42+
if(!prompt(text: "Will commit changes. All looking good?", boolean: true))
43+
UI.user_error!("Not committing changes")
44+
end
45+
46+
sh("git commit -m 'Bump #{version_number}'")
47+
sh("git tag #{version_number}")
48+
49+
if(!prompt(text: "Will push changes. All looking good?", boolean: true))
50+
UI.user_error!("Not pushing changes")
51+
end
52+
53+
push_to_git_remote(tags: true)
54+
55+
github_release = set_github_release(
56+
repository_name: "GetStream/stream-chat-swiftui",
57+
api_token: ENV["GITHUB_TOKEN"],
58+
name: version_number,
59+
tag_name: version_number,
60+
description: changes
61+
)
62+
63+
# The & operator makes sure truthy values are converted to bool true
64+
# and falsy (false and nil) values are converted to bool false
65+
push_pods(sync: options[:sync] & true)
66+
67+
UI.success("Successfully released #{version_number}")
68+
UI.success("Github release was created, please visit #{github_release["url"]} to see it")
69+
end
70+
71+
desc "Pushes the StreamChatSwiftUI SDK podspec to Cocoapods trunk"
72+
lane :push_pods do |options|
73+
# First pod release will not have any problems
74+
pod_push(path: "StreamChatSwiftUI.podspec", allow_warnings: true)
75+
end
76+
1477
desc "If `readonly: true` (by default), installs all Certs and Profiles necessary for development and ad-hoc.\nIf `readonly: false`, recreates all Profiles necessary for development and ad-hoc, updates them locally and remotely."
1578
lane :match_me do |options|
1679
# Get `:readonly` value, fallback to `true` if it's missing.

fastlane/README.md

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
fastlane documentation
2+
================
3+
# Installation
4+
5+
Make sure you have the latest version of the Xcode command line tools installed:
6+
7+
```
8+
xcode-select --install
9+
```
10+
11+
Install _fastlane_ using
12+
```
13+
[sudo] gem install fastlane -NV
14+
```
15+
or alternatively using `brew install fastlane`
16+
17+
# Available Actions
18+
### release
19+
```
20+
fastlane release
21+
```
22+
Release a new version
23+
### push_pods
24+
```
25+
fastlane push_pods
26+
```
27+
Pushes the StreamChatSwiftUI SDK podspec to Cocoapods trunk
28+
### match_me
29+
```
30+
fastlane match_me
31+
```
32+
If `readonly: true` (by default), installs all Certs and Profiles necessary for development and ad-hoc.
33+
If `readonly: false`, recreates all Profiles necessary for development and ad-hoc, updates them locally and remotely.
34+
### register_new_device_and_recreate_profiles
35+
```
36+
fastlane register_new_device_and_recreate_profiles
37+
```
38+
Register new device, regenerates profiles, updates them remotely and locally
39+
### get_next_issue_number
40+
```
41+
fastlane get_next_issue_number
42+
```
43+
Get next PR number from github to be used in CHANGELOG
44+
### test_ui
45+
```
46+
fastlane test_ui
47+
```
48+
Runs tests in Debug config
49+
### build_demo
50+
```
51+
fastlane build_demo
52+
```
53+
Builds Demo app
54+
### spm_integration
55+
```
56+
fastlane spm_integration
57+
```
58+
Test SPM Integration
59+
### cocoapods_integration
60+
```
61+
fastlane cocoapods_integration
62+
```
63+
Test CocoaPods Integration
64+
65+
----
66+
67+
This README.md is auto-generated and will be re-generated every time [_fastlane_](https://fastlane.tools) is run.
68+
More information about fastlane can be found on [fastlane.tools](https://fastlane.tools).
69+
The documentation of fastlane can be found on [docs.fastlane.tools](https://docs.fastlane.tools).

fastlane/actions/touch_changelog.rb

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
module Fastlane
2+
module Actions
3+
class TouchChangelogAction < Action
4+
def self.run(params)
5+
changelog_path = params[:changelog_path] unless params[:changelog_path].to_s.empty?
6+
7+
release_version = params[:release_version] unless params[:release_version].to_s.empty?
8+
9+
UI.message "Starting to update '#{changelog_path}'"
10+
11+
file_data = File.readlines(changelog_path)
12+
unchanged_file_data = file_data
13+
14+
upcoming_line = -1
15+
changes_since_last_release = ""
16+
17+
File.open(changelog_path).each.with_index { |line, index|
18+
if upcoming_line != -1
19+
if line.start_with?("# [")
20+
break
21+
else
22+
changes_since_last_release += line
23+
end
24+
elsif line == "# Upcoming\n"
25+
upcoming_line = index
26+
end
27+
}
28+
29+
file_data[upcoming_line] = "# [#{release_version}](https://github.com/GetStream/stream-chat-swiftui/releases/tag/#{release_version})"
30+
31+
today = Time.now.strftime("%B %d, %Y")
32+
file_data.insert(upcoming_line + 1, "_#{today}_")
33+
34+
file_data.insert(upcoming_line, "# Upcoming")
35+
file_data.insert(upcoming_line + 1, "")
36+
file_data.insert(upcoming_line + 2, "### 🔄 Changed")
37+
file_data.insert(upcoming_line + 3, "")
38+
39+
# Write updated content to file
40+
changelog = File.open(changelog_path, "w")
41+
changelog.puts(file_data)
42+
changelog.close
43+
UI.success("Successfully updated #{changelog_path}")
44+
return changes_since_last_release
45+
end
46+
47+
#####################################################
48+
# @!group Documentation
49+
#####################################################
50+
51+
def self.description
52+
"Updates CHANGELOG.md file with release"
53+
end
54+
55+
def self.details
56+
"Use this action to rename your unrelease section to your release version and add a new unreleased section to your project CHANGELOG.md"
57+
end
58+
59+
def self.available_options
60+
[
61+
FastlaneCore::ConfigItem.new(key: :changelog_path,
62+
env_name: "FL_CHANGELOG_PATH",
63+
description: "The path to your project CHANGELOG.md",
64+
is_string: true,
65+
default_value: "./CHANGELOG.md",
66+
optional: true),
67+
FastlaneCore::ConfigItem.new(key: :release_version,
68+
env_name: "FL_CHANGELOG_RELEASE_VERSION",
69+
description: "The release version, according to semantic versioning",
70+
is_string: true,
71+
default_value: "",
72+
optional: false)
73+
]
74+
end
75+
76+
def self.authors
77+
["martinmitrevski"]
78+
end
79+
80+
def self.is_supported?(platform)
81+
true
82+
end
83+
end
84+
end
85+
end

0 commit comments

Comments
 (0)