Skip to content

Commit

Permalink
fetch release name and build type from changelog (#400)
Browse files Browse the repository at this point in the history
* fetch release name and build type from changelog

* seperate changelog logic
  • Loading branch information
gintama91 authored Oct 10, 2023
1 parent 5c72dd9 commit 761b738
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lacci/lib/shoes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ module Kernel
# small visual applications in Ruby.
#
module Shoes
include Shoes::Constants

class << self
# Creates a Shoes app with a new window. The block parameter is used to create
# widgets and set up handlers. Arguments are passed to Shoes::App.new internally.
Expand Down
36 changes: 36 additions & 0 deletions lacci/lib/shoes/changelog.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# frozen_string_literal: true

require_relative "log"
# require "scarpe/components/modular_logger"

module Shoes
class Changelog
# include Shoes::Log

def initialize
#TODO : refer to https://github.com/scarpe-team/scarpe/pull/400
# and figure out how to use scarpe logger here wtihout getting duplicate or nil error
# Shoes::Log.instance = Scarpe::Components::ModularLogImpl.new
# log_init("Changelog")
end

def get_latest_release_info
changelog_content = File.read("CHANGELOG.md")

release_name_pattern = /^## \[(\d+\.\d+\.\d+)\] - (\d{4}-\d{2}-\d{2})$/m

release_matches = changelog_content.scan(release_name_pattern)

latest_release = release_matches.max_by { |version, _date| Gem::Version.new(version) }

if latest_release
puts "Found release #{latest_release[0]} in CHANGELOG.md"
# @log.debug("Found release #{latest_release[0]} in CHANGELOG.md")
{ RELEASE_NAME: latest_release[0], RELEASE_BUILD_DATE: latest_release[1] }
else
puts "No release found in CHANGELOG.md"
{ RELEASE_NAME: nil, RELEASE_BUILD_DATE: nil }
end
end
end
end
8 changes: 8 additions & 0 deletions lacci/lib/shoes/constants.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# frozen_string_literal: true

require_relative "changelog"
module Shoes
module Constants
def self.find_lib_dir
Expand All @@ -14,6 +15,7 @@ def self.find_lib_dir
[ENV["HOME"], ".shoes"],
[Dir.tmpdir, "shoes"],
]

top, file = homes.detect { |home_top, _| home_top && File.exist?(home_top) }
File.join(top, file)
end
Expand All @@ -30,4 +32,10 @@ def self.find_lib_dir
HALF_PI = 1.57079632679489661923
PI = 3.14159265358979323846
end

# Access and assign the release constants
changelog_instance = Shoes::Changelog.new
RELEASE_INFO = changelog_instance.get_latest_release_info
RELEASE_NAME = RELEASE_INFO[:RELEASE_NAME]
RELEASE_BUILD_DATE = RELEASE_INFO[:RELEASE_BUILD_DATE]
end

0 comments on commit 761b738

Please sign in to comment.