Skip to content

Commit 105730a

Browse files
committed
Add GitHub release automation
1 parent 4d35835 commit 105730a

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed

CLAUDE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ swift package generate-xcodeproj
3838
bundle exec fastlane release version:4.2.1
3939
```
4040

41-
The `release` lane runs tests, bumps build/version, updates the podspec, stamps the changelog, commits, tags, pushes, and runs `pod push`.
41+
The `release` lane runs tests, bumps build/version, updates the podspec, stamps the changelog, commits, tags, pushes, creates a GitHub release via `gh`, and runs `pod push`.
4242

4343
Note: `CHANGELOG.md` uses compare links and keeps link references ordered from oldest to newest (latest at the bottom) so `stamp_changelog` can append the next compare link. The lane also refreshes the `[Unreleased]` compare link.
4444

fastlane/Fastfile

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,38 @@
11
fastlane_version "2.230.0"
22

3+
require "tempfile"
4+
35
default_platform :mac
46

57
platform :mac do
8+
def read_changelog_section(version:)
9+
content = File.read("CHANGELOG.md")
10+
pattern = /^## \\[#{Regexp.escape(version)}\\].*?\\n(.*?)(?=^## \\[|\\z)/m
11+
match = content.match(pattern)
12+
UI.user_error!("Missing CHANGELOG.md section for #{version}") unless match
13+
match[1].strip
14+
end
15+
16+
def github_release_exists?(version:)
17+
begin
18+
sh("gh release view #{version} --repo onevcat/Rainbow", log: false)
19+
true
20+
rescue
21+
false
22+
end
23+
end
24+
25+
def create_github_release(version:)
26+
return if github_release_exists?(version: version)
27+
28+
notes = read_changelog_section(version: version)
29+
Tempfile.create(["release_notes_", ".md"]) do |file|
30+
file.write(notes + "\n")
31+
file.flush
32+
sh("gh release create #{version} --repo onevcat/Rainbow --title \"#{version}\" --notes-file #{file.path}")
33+
end
34+
end
35+
636
def update_unreleased_compare_link(tag:)
737
changelog_path = "CHANGELOG.md"
838
content = File.read(changelog_path)
@@ -40,6 +70,7 @@ platform :mac do
4070
add_git_tag tag: target_version
4171

4272
push_to_git_remote
73+
create_github_release(version: target_version)
4374
pod_push
4475
end
4576

0 commit comments

Comments
 (0)