-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFastfile
103 lines (82 loc) · 3.82 KB
/
Fastfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
default_platform(:ios)
before_all do |lane, options|
if File.exist?('Podfile')
cocoapods(silent: true)
end
end
desc "Runs the unit tests to ensure the build is working"
lane :test do
# Perform all of the unit tests in this project
scan(scheme: ENV["TEST_SCHEME"], devices: ["iPhone 11 Pro"], prelaunch_simulator: true, clean: true)
end
desc "Cuts a new release and distributes it on CocoaPods and Carthage"
lane :release do
# ---------------------------------------------------------------------
# Fetch the new release version
# We get the desired tag number from the Buildkite release message
release_message = ENV["BUILDKITE_MESSAGE"]
# See if we can extract the new version from the message
latest_version = release_message.scan(/[vV]?(\d{1,3}\.\d{1,3}\.\d{1,3})/).last.first
if !latest_version
UI.user_error! "--- ERROR: Was unable to find version number in build message. ---"
next
end
# ---------------------------------------------------------------------
# Load the matching entry from the CHANGELOG
# Load the Release Notes from file, and throw an error if they weren't updated
changelog_contents = File.read("../CHANGELOG.md")
v = latest_version.split(".")
release_notes = changelog_contents.scan(/#{v[0]}\.#{v[1]}\.#{v[2]}\ [Rr]elease\ [Nn]otes.*\n\=+\n([\s\S]*?)(\d{1,3}\.\d{1,3}\.\d{1,3}\ [Rr]elease\ [Nn]otes.*\n\=+\n|\Z)/).last
if !release_notes
UI.user_error! "--- ERROR: Unable to find Release Notes entry for v#{latest_version} in CHANGELOG. ---"
next
end
# ---------------------------------------------------------------------
# Bump the version number in the Podspec and framework
# Keep track if we need to push any changes
needs_git_push = false
# Update the Podspec version and push to the repo
podspec_version = version_get_podspec(path: ENV["PODSPEC_PATH"])
if podspec_version != latest_version
version_bump_podspec(path: ENV["PODSPEC_PATH"], version_number: latest_version)
git_commit(path: ENV["PODSPEC_PATH"], message: "Bumped Podspec version to v#{latest_version} [skip ci]")
needs_git_push = true
end
# Update and push framework version number if the current version doesn't match
framework_version = get_info_plist_value(path: ENV["FRAMEWORK_PLIST_PATH"], key: "CFBundleShortVersionString")
if framework_version != latest_version
set_info_plist_value(path: ENV["FRAMEWORK_PLIST_PATH"], key: "CFBundleShortVersionString", value: latest_version)
git_commit(path: ENV["FRAMEWORK_PLIST_PATH"], message: "Bumped framework version to v#{latest_version} [skip ci]")
needs_git_push = true
end
# If changes were made, push them to main
if needs_git_push
UI.message "Pushing bumped version changes to main branch"
push_to_git_remote(remote_branch: "main", set_upstream: true)
end
# ---------------------------------------------------------------------
# Create a new version tag after the commit has completed
# Create a new tag and commit it against the last commit
if !git_tag_exists(tag: latest_version)
add_git_tag(tag: latest_version)
push_git_tags(tag: latest_version)
end
# ---------------------------------------------------------------------
# Push a new release to GitHub releases
# Publish the Release on GitHub
release = get_github_release(url:ENV["REPO_PATH"], version: latest_version)
if release == nil
set_github_release(repository_name: ENV["REPO_PATH"],
api_token: ENV["GITHUB_TOKEN"],
name: "v#{latest_version}",
tag_name: latest_version,
description: release_notes.first)
end
# ---------------------------------------------------------------------
# Publish to CocoaPods trunk
begin
pod_push(use_bundle_exec: true, allow_warnings: true)
rescue => ex
UI.error(ex)
end
end