Skip to content

Commit e12bbdd

Browse files
committed
adjust backup-utils release script to better support patch branches
1 parent 2b8d549 commit e12bbdd

File tree

1 file changed

+26
-3
lines changed

1 file changed

+26
-3
lines changed

script/release

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ GH_REPO = ENV['GH_REPO'] || 'backup-utils'
3131
GH_OWNER = ENV['GH_OWNER'] || 'github'
3232
GH_AUTHOR = ENV['GH_AUTHOR']
3333
DEB_PKG_NAME = 'github-backup-utils'
34-
GH_BASE_BRANCH = ENV['GH_BASE_BRANCH'] || 'master'
35-
GH_STABLE_BRANCH = ENV['GH_STABLE_BRANCH'] || 'stable'
34+
GH_BASE_BRANCH = ENV['GH_BASE_BRANCH'] || 'master' # TODO: should we even allow a default or require all params get set explicitly?
35+
GH_STABLE_BRANCH = ""
3636

3737
CHANGELOG_TMPL = '''<%= package_name %> (<%= package_version %>) UNRELEASED; urgency=medium
3838
@@ -138,6 +138,7 @@ def beautify_changes(changes)
138138
end
139139

140140
def changelog
141+
puts "building changelog by comparing origin/#{GH_STABLE_BRANCH}...origin/#{GH_BASE_BRANCH}"
141142
changes = `git log --pretty=oneline origin/#{GH_STABLE_BRANCH}...origin/#{GH_BASE_BRANCH} --reverse --grep "Merge pull request" | sort -t\# -k2`.lines.map(&:strip)
142143
raise 'Building the changelog failed' if $CHILD_STATUS != 0
143144

@@ -334,9 +335,31 @@ def clean_up(version)
334335
`git branch --quiet -D tmp-packaging >/dev/null 2>&1`
335336
end
336337

338+
def is_base_branch_valid?(branch)
339+
if branch == "master" || branch.match(/^\d+\.\d+-main$/)
340+
return true
341+
else
342+
return false
343+
end
344+
end
345+
337346
#### All the action starts ####
338347
if $PROGRAM_NAME == __FILE__
339348
begin
349+
## validate base branch. this must either be "master" or a release branch which will match the pattern "x.y-main"
350+
raise "The branch #{GH_BASE_BRANCH} is not valid for releasing backup-utils. branch name must be master or match x.y-main" if !is_base_branch_valid?(GH_BASE_BRANCH)
351+
352+
## derive the proper stable branch. if the base branch is "master" the stable branch is just "stable"
353+
## if the base branch is a release branch, the stable branch will be "x.y-stable"
354+
if GH_BASE_BRANCH == "master"
355+
GH_STABLE_BRANCH = "stable"
356+
else
357+
GH_STABLE_BRANCH = GH_BASE_BRANCH.gsub(/-main$/, "-stable")
358+
end
359+
360+
puts "base branch = " + GH_BASE_BRANCH
361+
puts "stable branch = " + GH_STABLE_BRANCH
362+
340363
args = ARGV.dup
341364
dry_run = false
342365
skip_version_bump_check = false
@@ -456,7 +479,7 @@ if $PROGRAM_NAME == __FILE__
456479
puts 'Cleaning up...'
457480
clean_up version
458481

459-
puts 'Updating stable branch...'
482+
puts "Updating #{GH_STABLE_BRANCH} branch..."
460483
update_stable_branch
461484

462485
puts 'Released!'

0 commit comments

Comments
 (0)