-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Created bin/release script * Update lib/edusign/version.rb through bin/release task * Commit change to version on master
- Loading branch information
Showing
1 changed file
with
52 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
#!/usr/bin/env ruby | ||
require 'json' | ||
|
||
SEMVER_PATTERN = /^(?<major>0|[1-9]\d*)\.(?<minor>0|[1-9]\d*)\.(?<patch>0|[1-9]\d*)(?:-(?<prerelease>(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+(?<buildmetadata>[0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/m | ||
version = "" | ||
|
||
unless `git branch --show-current`.strip == 'master' | ||
puts "⚠️ You must be on master to run bin/release script" | ||
return | ||
end | ||
|
||
unless `git status`.match?(/nothing to commit, working tree clean/) | ||
puts "⚠️ Your git status must be clean to run bin/release script" | ||
return | ||
end | ||
|
||
system "git pull origin master" | ||
puts "You're about to deploy a new version of Edusign gem" | ||
puts "Before proceeding, check out `master`'s last commit" | ||
system "gh browse $(git rev-parse HEAD)" | ||
puts "Is the CI green? (y/n)" | ||
print "> " | ||
continue = gets.chomp | ||
return unless continue == "y" | ||
|
||
until version.match?(SEMVER_PATTERN) | ||
puts "Not a correct version number. Version number must follow the semver pattern. See https://semver.org/." unless version.empty? | ||
puts "" | ||
puts "Previous version released:" | ||
system "gh release list --limit 1 --repo lewagon/edusign | awk '{print $1}'" | ||
puts "" | ||
puts "Which version number do you want to release?" | ||
print "> " | ||
version = gets.chomp | ||
end | ||
|
||
puts "Release version v#{version}" | ||
gem_version_path = File.join(File.dirname(__FILE__), "../lib/edusign/version.rb") | ||
file_lines = File.open(gem_version_path, "r").readlines | ||
file_lines[3] = " VERSION = \"#{version}\"\n" | ||
File.open(gem_version_path, "wb") {|file| file.write(file_lines.join) } | ||
puts "Commit changes on GitHub" | ||
system "git add ../lib/edusign/version.rb" | ||
system "git commit -m 'Commit v#{version}'" | ||
puts "Push to master" | ||
system "git push origin master" | ||
puts "Create tag and release on GitHub" | ||
system "git tag v#{version}" | ||
system "git push origin v#{version}" | ||
system "gh release create v#{version} --generate-notes" | ||
|
||
puts "Version v#{version} released! 🎉" |