8000 Update Fastlane script to contain a `release` lane. (#615) · androiddev2019/Android@30715ed · GitHub
[go: up one dir, main page]

Skip to content

Commit 30715ed

Browse files
authored
Update Fastlane script to contain a release lane. (duckduckgo#615)
You can use this to better automate the release process. ## Pre-Requisites - You need `git flow` tools installed (this would be an easy tidy-up to remove this dependency later) - You have `develop` checked out - You have a clean working directory ## Using Start with `fastlane release` and it will prompt for new version number and release notes. It will perform the required updates to the `version.properties` and `release-notes` files, on a release branch, and will confirm everything looks right before it creates a tag and does the required merging back into `develop` and `master`.
1 parent 8a9337c commit 30715ed

File tree

2 files changed

+71
-2
lines changed

2 files changed

+71
-2
lines changed

fastlane/Fastfile

Lines changed: 65 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ default_platform(:android)
1717

1818
platform :android do
1919

20-
desc "Release"
20+
desc "Deploy APK to GitHub"
2121
lane :deploy_github do
2222

2323
props = property_file_read(file: "app/version/version.properties")
@@ -39,4 +39,68 @@ platform :android do
3939
is_prerelease: false)
4040

4141
end
42+
43+
# Note, this currently relies on having `git flow` tools installed.
44+
# This dependency could be removed with a little more time to tidy up this script to do the branching/merging manually.
45+
46+
desc "Create new release"
47+
lane :release do
48+
49+
UI.header "Creating a new release"
50+
UI.message ("Checking current branch: #{git_branch}")
51+
52+
ensure_git_status_clean
53+
54+
ensure_git_branch(
55+
branch: 'develop'
56+
)
57+
58+
newVersion = prompt(text: "\nLast release was: #{last_git_tag}\nEnter New Version Number:")
59+
releaseNotes = prompt(text: "Release Notes: ", multi_line_end_keyword: "END")
60+
commits = changelog_from_git_commits(
61+
between: [last_git_tag, "HEAD"],
62+
pretty: "- %s",
63+
date_format: "short",
64+
match_lightweight_tag: false,
65+
merge_commit_filtering: "exclude_merges"
66+
)
67+
UI.message ("Performing a new release for #{newVersion}")
68+
69+
70+
if UI.confirm("Are you sure you're happy with this release?\n\nVersion=#{newVersion}\nCommits Since Last Release:\n#{commits}\nRelease Notes:\n#{releaseNotes}\n")
71+
UI.success "Creating release branch for release/#{newVersion}"
72+
73+
sh "git flow release start #{newVersion}"
74+
75+
File.open('../app/version/version.properties', 'w') do |file|
76+
file.write("VERSION=#{newVersion}")
77+
end
78+
79+
File.open('../app/version/release-notes', 'w') do |file|
80+
file.write("""## What's new in this release?
81+
#{releaseNotes}
82+
83+
## Have feedback?
84+
You can always reach us at https://duckduckgo.com/feedback.""")
85+
end
86+
87+
git_commit(path: "*", message: "Updated release notes and version number for new release - #{newVersion}")
88+
89+
prompt(text:"If you have any other changes to make to the release branch, do them now. Hit ENTER when ready...")
90+
91+
sh "git flow release finish -mnFS '#{newVersion}' '#{newVersion}'"
92+
add_git_tag(tag: "#{newVersion}")
93+
push_git_tags
94+
95+
sh "git push origin master"
96+
sh "git push origin develop"
97+
98+
UI.header("#{newVersion} has been successfully released 🎉")
99+
100+
else
101+
UI.error "Release cancelled 😢"
102+
end
103+
104+
end
105+
42106
end

fastlane/README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,12 @@ or alternatively using `brew cask install fastlane`
2020
```
2121
fastlane android deploy_github
2222
```
23-
Release
23+
Deploy APK to GitHub
24+
### android release
25+
```
26+
fastlane android release
27+
```
28+
Create new release
2429

2530
----
2631

0 commit comments

Comments
 (0)
0