diff --git a/script/release.sh b/script/release.sh deleted file mode 100755 index 600b40885..000000000 --- a/script/release.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/usr/bin/env bash - -set -e - -# Exit if the working tree is dirty -test -n "$(git status --porcelain)" && echo "Working tree dirty!" && exit 1 - -# Exit if is not a releasable branch -[[ "$(git rev-parse --abbrev-ref HEAD)" == master* ]] || echo "Wrong branch to release!" && exit 1 - -# Set the root path -dir="$(dirname -- "$0")" -ROOT="$(cd -P -- "$(dirname -- "$dir")" && printf '%s\n' "$(pwd -P)")" -cd $ROOT - -rake build release - -rm -rfv "$ROOT/pkg" diff --git a/tasks/gem_management.rake b/tasks/gem_management.rake deleted file mode 100644 index 40a581e1b..000000000 --- a/tasks/gem_management.rake +++ /dev/null @@ -1,26 +0,0 @@ -# frozen_string_literal: true - -# gGem build and release tasks, with added checks and patches -# Notice: this task is functional but the .github/workflows/release-gem.yml provides an easier way to do the same - -require 'bundler/gem_tasks' -require 'rake/manifest' - -Rake::Manifest::Task.new do |t| - t.patterns = FileList.new.include('lib/**/*', 'LICENSE.txt').exclude('**/*.md') - t.manifest_file = 'pagy.manifest' -end - -desc 'Build the gem, checking the manifest first' -task build: 'manifest:check' - -module Bundler # :nodoc: all - class GemHelper - def version_tag - "#{@tag_prefix}#{version}" # remove that stupid 'v' prepended to the version number - end - end -end - -desc 'Release the gem, checking the manifest first' -task release: 'manifest:check' diff --git a/tasks/safe_release.rake b/tasks/safe_release.rake new file mode 100644 index 000000000..99212caaf --- /dev/null +++ b/tasks/safe_release.rake @@ -0,0 +1,33 @@ +# frozen_string_literal: true + +# Gem release cycle + +require 'bundler/gem_tasks' +require 'rake/manifest' + +Rake::Manifest::Task.new do |t| + t.patterns = FileList.new.include('lib/**/*', 'LICENSE.txt').exclude('**/*.md') + t.manifest_file = 'pagy.manifest' +end + +module Bundler # :nodoc: all + class GemHelper + def version_tag + "#{@tag_prefix}#{version}" # remove that stupid 'v' prepended to the version number + end + end +end + +desc 'Checks-build-release-tag-cleanup cycle' +task :safe_release do + output = `git status --porcelain` + abort 'Working tree dirty!' unless output.empty? + + branch = `git rev-parse --abbrev-ref HEAD` + abort 'Wrong branch to release!' unless /^master/.match?(branch) + + Rake::Task['manifest:check'].invoke + Rake::Task['build'].invoke + Rake::Task['release'].invoke + FileUtils.rm_rf('pkg', secure: true) +end