Skip to content

Commit

Permalink
release blog: generate release post without content (#85)
Browse files Browse the repository at this point in the history
GitHub: GH-83

In this PR, we implement a Rake task for generating release announces in
blog without contents.
At the following PRs, we will implement contents step by step.
  • Loading branch information
otegami authored Dec 4, 2024
1 parent e405ee4 commit da5c96d
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@

require_relative "release_task"

release_task = ReleaseTask.new("groonga")
release_task = ReleaseTask.new("Groonga", __dir__)
release_task.define
44 changes: 41 additions & 3 deletions release_task.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,19 @@
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA

require "date"
require "yaml"

class ReleaseTask
include Rake::DSL

def initialize(package)
@package = package
def initialize(product, jekyll_path)
@product = product
@product_id = product.downcase
@jekyll_path = jekyll_path
@jekyll_config = load_jekyll_config
@version = detect_version
@release_date = detect_release_date
end

def define
Expand All @@ -28,14 +36,44 @@ def define

private

def load_jekyll_config
YAML.safe_load_file(File.join(@jekyll_path, "_config.yml"), permitted_classes: [Date])
end

def detect_version
@jekyll_config["#{@product_id}_version"]
end

def detect_release_date
@jekyll_config["#{@product_id}_release_date"]
end

def define_generate_blog_task
namespace :release do
namespace :blog do
desc "Generate release announce posts from a release note"
task :generate do
puts "TODO: Generate release announce posts for #{@package}"
generate_blog_posts
end
end
end
end

def post_filename
"#{@release_date.strftime("%F")}-#{@product_id}-#{@version}.md"
end

def post_content(locale)
# TODO: We will write blog post contents here.
# After writing contents, we will remove this TODO comment.
"#{locale}, #{@product}, #{@version}"
end

def generate_blog_posts
["ja", "en"].each do |locale|
File.open("#{@jekyll_path}/#{locale}/_posts/#{post_filename}", "w") do |post|
post.write(post_content(locale))
end
end
end
end

0 comments on commit da5c96d

Please sign in to comment.