Skip to content

Commit

Permalink
chore: Prepare v0.4.0 release
Browse files Browse the repository at this point in the history
Signed-off-by: Ben Johnson <[email protected]>
  • Loading branch information
binarylogic committed Sep 24, 2019
1 parent f6b0739 commit d1acf03
Show file tree
Hide file tree
Showing 3 changed files with 132 additions and 2 deletions.
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,10 @@ release-meta: ## Prepares the release metadata
@bundle install --gemfile=scripts/Gemfile > /dev/null
@scripts/release-meta.rb

release-rollback:
@bundle install --gemfile=scripts/Gemfile > /dev/null
@scripts/release-rollback.rb

release-rpm: ## Release .rpm via Package Cloud
@scripts/release-rpm.sh

Expand Down
10 changes: 8 additions & 2 deletions scripts/release-commit.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@ def release_exists?(release)

commands =
<<~EOF
git add docs/*
git add . -A
git commit -sam 'chore: Prepare v#{release.version} release'
git push origin master
git push origin master --force
git tag -a v#{release.version} -m "v#{release.version}"
git push origin v#{release.version}
git branch v#{branch_name}
Expand All @@ -86,12 +86,18 @@ def release_exists?(release)

commands.chomp!

status = `git status --short`.chomp!

words =
<<~EOF
We'll be releasing v#{release.version} with the following commands:
#{commands.indent(2)}
Your current `git status` is:
#{status.indent(2)}
Proceed to execute the above commands?
EOF

Expand Down
120 changes: 120 additions & 0 deletions scripts/release-rollback.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
#!/usr/bin/env ruby

# release-rollback.sh
#
# SUMMARY
#
# Rolls back a fresh release. This should only be used in situations
# where the release process failed.

#
# Setup
#

# Changes into the scripts directory so that we can load the Bundler
# dependencies. Unfortunately, Bundler does not provide a way load a Gemfile
# outside of the cwd.
Dir.chdir "scripts"

#
# Requires
#

require "rubygems"
require "bundler"
Bundler.require(:default)

require_relative "util"

#
# Includes
#

include Printer

#
# Constants
#

ROOT_DIR = Pathname.new("#{Dir.pwd}/..").cleanpath

DOCS_ROOT = File.join(ROOT_DIR, "docs")
META_ROOT = File.join(ROOT_DIR, ".meta")

#
# Commit
#

metadata =
begin
Metadata.load(META_ROOT, DOCS_ROOT)
rescue Exception => e
error!(e.message)
end

release = metadata.latest_release
version = release.version

#
# Rollback
#

input = get("Do you want to rollback #{version}?")

if input == "n"
error!("You can only rollback the latest release")
end

branch_commands =
if release.version.patch == 0
commands =
<<~EOF
git branch -d v#{version.major}.#{version.minor}
git push origin --delete v#{version.major}.#{version.minor}
EOF

commands.chomp
else
""
end

commands =
<<~EOF
git tag -d v#{version}
git push --delete origin v#{version}
#{branch_commands}
git reset HEAD~
EOF

commands.chomp!

words =
<<~EOF
We'll be rolling back v#{version} with the following commands:
#{commands.indent(2)}
Proceed to execute the above commands?
EOF

if get(words, ["y", "n"]) == "n"
error!("Ok, I've aborted. Please re-run this command when you're ready.")
end

commands.chomp.split("\n").each do |command|
system(command)

if !$?.success?
error!(
<<~EOF
Command failed!
#{command}
Produced the following error:
#{$?.inspect}
EOF
)
end
end

0 comments on commit d1acf03

Please sign in to comment.