Skip to content

Commit 3c0738f

Browse files
authored
ci: generate changelog and update version in release step (#8)
1 parent 86a7b72 commit 3c0738f

File tree

7 files changed

+91
-9
lines changed

7 files changed

+91
-9
lines changed

.circleci/config.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,8 @@ workflows:
5454
- build-test-macos
5555
- release:
5656
filters:
57-
tags:
58-
only: /^v.*/
5957
branches:
60-
ignore: /.*/
58+
only: release
6159
requires:
6260
- build-test-ios
6361
- build-test-macos

AmplifyUtilsNotifications.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ Pod::Spec.new do |spec|
2121
spec.osx.deployment_target = "10.15"
2222
spec.swift_version = "5.6"
2323

24-
spec.source = { :git => "https://github.com/aws-amplify/amplify-swift-utils-notifications.git", :tag => "#{spec.version}" }
24+
spec.source = { :git => "https://github.com/aws-amplify/amplify-swift-utils-notifications.git", :tag => "v#{spec.version}" }
2525

2626
spec.source_files = "Sources/AmplifyUtilsNotifications/**/*.swift"
2727

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Changelog
2+
3+

Gemfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,6 @@ source 'https://rubygems.org'
22

33
gem 'cocoapods', '~> 1.11.3'
44
gem 'fastlane', '~> 2.211'
5+
6+
plugins_path = File.join(File.dirname(__FILE__), 'fastlane', 'Pluginfile')
7+
eval_gemfile(plugins_path) if File.exist?(plugins_path)

Gemfile.lock

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
GIT
2+
remote: https://github.com/aws-amplify/amplify-ci-support
3+
revision: 8b34bda1805cf89fcdb6fa67038784109ac0100a
4+
branch: main
5+
glob: src/fastlane/release_actions/*.gemspec
6+
specs:
7+
fastlane-plugin-release_actions (1.1.0)
8+
19
GEM
210
remote: https://rubygems.org/
311
specs:
@@ -279,6 +287,7 @@ PLATFORMS
279287
DEPENDENCIES
280288
cocoapods (~> 1.11.3)
281289
fastlane (~> 2.211)
290+
fastlane-plugin-release_actions!
282291

283292
BUNDLED WITH
284293
1.17.2

fastlane/Fastfile

Lines changed: 69 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
PODSPEC_PATH = "AmplifyUtilsNotifications.podspec"
2+
CHANGELOG_PATH = "CHANGELOG.md"
13

24
platform :ios do
35
before_all do
@@ -18,11 +20,73 @@ platform :ios do
1820

1921
desc "Publish to Cocoapods whenever a new version tag is created"
2022
lane :release do
21-
# publish to Cocoapods
22-
# pod_push(
23-
# use_bundle_exec: true,
24-
# path: "AmplifyUtilsNotifications.podspec",
25-
# )
23+
sh('git', 'config', '--global', 'user.email', ENV['GITHUB_EMAIL'])
24+
sh('git', 'config', '--global', 'user.name', ENV['GITHUB_USER'])
25+
next_version, commits = calculate_next_release_version
26+
27+
generate_version_bump_commit(version: next_version)
28+
generate_changelog_commit(version: next_version, commits: commits)
29+
create_new_version_tag(version: next_version)
30+
# publish_to_cocoapod_trunk
31+
# sync_up_main_release_branch
32+
end
33+
34+
desc "Generate commit for version bump"
35+
private_lane :generate_version_bump_commit do |options|
36+
next_version = options[:version]
37+
UI.user_error!("version shouldn't be nil") if next_version.nil?
38+
39+
version_bump_podspec(path: PODSPEC_PATH, version_number: next_version)
40+
UI.message "Set version to: #{next_version}"
41+
git_commit(path: PODSPEC_PATH, message: "chore: bump version to #{next_version} [skip ci]")
42+
end
43+
44+
desc "Generate commit for changelog"
45+
private_lane :generate_changelog_commit do |options|
46+
next_version = options[:version]
47+
UI.user_error!("version shouldn't be nil") if next_version.nil?
48+
49+
commits = options[:commits]
50+
UI.user_error!("commits shouldn't be nil") if commits.nil?
51+
52+
53+
changelog = build_changelog(version: next_version, commits: commits)
54+
write_changelog(changelog: changelog, path: CHANGELOG_PATH)
55+
56+
git_commit(path: CHANGELOG_PATH, message: "changelog: update changelog for #{next_version} [skip ci]")
57+
end
58+
59+
desc "Create new version tag after bump up version"
60+
private_lane :create_new_version_tag do |options|
61+
next_version = options[:version]
62+
UI.user_error!("version shouldn't be nil") if next_version.nil?
63+
64+
add_git_tag(tag: "v#{next_version}", grouping: nil)
65+
end
66+
67+
desc "Publish new version to cocoapod trunck"
68+
private_lane :publish_to_cocoapod_trunk do
69+
pod_push(
70+
use_bundle_exec: true,
71+
allow_warnings: true,
72+
path: PODSPEC_PATH,
73+
)
74+
end
75+
76+
desc "Push commits and tags to remote branches"
77+
private_lane :sync_up_main_release_branch do
78+
push_to_git_remote(
79+
local_branch: "release",
80+
remote_branch: "release",
81+
tags: true,
82+
)
83+
84+
# update main branch with release branch
85+
push_to_git_remote(
86+
local_branch: "release",
87+
remote_branch: "main",
88+
tags: true,
89+
)
2690
end
2791
end
2892

fastlane/Pluginfile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Autogenerated by fastlane
2+
#
3+
# Ensure this file is checked in to source control!
4+
5+
gem 'fastlane-plugin-release_actions', git: 'https://github.com/aws-amplify/amplify-ci-support', branch: 'main', glob: 'src/fastlane/release_actions/*.gemspec'

0 commit comments

Comments
 (0)