Add a task to update versions (#47)
This commit is contained in:
parent
744e5ff868
commit
20aba6629d
50
Rakefile
50
Rakefile
@ -12,6 +12,8 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
require "date"
|
||||
|
||||
require_relative "helper"
|
||||
|
||||
version = ENV["VERSION"] || Helper.detect_version
|
||||
@ -26,3 +28,51 @@ end
|
||||
|
||||
desc "Create #{archive_tar_gz}"
|
||||
task :dist => archive_tar_gz
|
||||
|
||||
namespace :release do
|
||||
namespace :version do
|
||||
desc "Update versions for a new release"
|
||||
task :update do
|
||||
new_version = ENV["NEW_VERSION"]
|
||||
if new_version.nil?
|
||||
raise "You must specify NEW_VERSION=..."
|
||||
end
|
||||
new_release_date = ENV["NEW_RELEASE_DATE"] || Date.today.iso8601
|
||||
Helper.update_cmake_lists_txt_version(new_version)
|
||||
Helper.update_content("python/meson.build") do |content|
|
||||
content.sub(/^( version: ').*?('.*)$/) do
|
||||
"#{$1}#{new_version}#{$2}"
|
||||
end
|
||||
end
|
||||
Helper.update_content("python/pyproject.toml") do |content|
|
||||
content.sub(/^(version = ").*?(")$/) do
|
||||
"#{$1}#{new_version}#{$2}"
|
||||
end
|
||||
end
|
||||
Helper.update_content("python/openarm/can/__init__.py") do |content|
|
||||
content.sub(/^(__version__ = ").*?(")$/) do
|
||||
"#{$1}#{new_version}#{$2}"
|
||||
end
|
||||
end
|
||||
ruby("-C",
|
||||
"packages",
|
||||
"-S",
|
||||
"rake",
|
||||
"version:update",
|
||||
"RELEASE_DATE=#{new_release_date}")
|
||||
sh("git",
|
||||
"add",
|
||||
"CMakeLists.txt",
|
||||
"packages/debian/changelog",
|
||||
"packages/fedora/openarm-can.spec",
|
||||
"python/meson.build",
|
||||
"python/pyproject.toml",
|
||||
"python/openarm/can/__init__.py")
|
||||
sh("git",
|
||||
"commit",
|
||||
"-m",
|
||||
"Update version info to #{version} (#{new_release_date})")
|
||||
sh("git", "push")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
21
helper.rb
21
helper.rb
@ -14,8 +14,25 @@
|
||||
|
||||
module Helper
|
||||
module_function
|
||||
def cmake_lists_txt
|
||||
File.join(__dir__, "CMakeLists.txt")
|
||||
end
|
||||
|
||||
def detect_version
|
||||
cmakelists = File.join(__dir__, "CMakeLists.txt")
|
||||
File.read(cmakelists)[/^project\(.+ VERSION (.+?)\)/, 1]
|
||||
File.read(cmake_lists_txt)[/^project\(.+ VERSION (.+?)\)/, 1]
|
||||
end
|
||||
|
||||
def update_content(path)
|
||||
content = File.read(path)
|
||||
content = yield(content)
|
||||
File.write(path, content)
|
||||
end
|
||||
|
||||
def update_cmake_lists_txt_version(new_version)
|
||||
update_content(cmake_lists_txt) do |content|
|
||||
content.sub(/^(project\(.* VERSION )(?:.*?)(\))/) do
|
||||
"#{$1}#{new_version}#{$2}"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@ -45,6 +45,14 @@ class OpenArmCANPackageTask < PackageTask
|
||||
false
|
||||
end
|
||||
|
||||
def update_spec
|
||||
update_content("fedora/openarm-can.spec") do |content|
|
||||
content.gsub!(/^(Version:\s+)[\d.]+$/) do
|
||||
"#{$1}#{@version}"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def define_archive_task
|
||||
file @archive_name do
|
||||
if File.exist?("../#{@archive_name}")
|
||||
|
||||
Loading…
Reference in New Issue
Block a user