Skip to content

Commit

Permalink
release blog: generate release post
Browse files Browse the repository at this point in the history
GitHub: groongaGH-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.

Generate release announces

```console
$ VERSION=14.1.1 rake release:blog:generate
$ tree . | grep 2024-12-04-groonga-14.1.1.md
  │      └── 2024-12-04-groonga-14.1.1.md
  │   │  └── 2024-12-04-groonga-14.1.1.md
```
  • Loading branch information
otegami committed Dec 4, 2024
1 parent e405ee4 commit bc19de5
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 3 deletions.
8 changes: 7 additions & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,11 @@

require_relative "release_task"

release_task = ReleaseTask.new("groonga")
def env_var(name, default=nil)
value = ENV[name] || default
raise "${#{name}} is missing" if value.nil?
value
end

release_task = ReleaseTask.new("groonga", env_var("VERSION"), __dir__)
release_task.define
24 changes: 22 additions & 2 deletions release_task.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@
class ReleaseTask
include Rake::DSL

def initialize(package)
def initialize(package, version, jekyll_path)
@package = package
@version = version
@jekyll_path = jekyll_path
end

def define
Expand All @@ -33,9 +35,27 @@ def define_generate_blog_task
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
"#{Time.now.strftime("%F")}-#{@package}-#{@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}, #{@package}, #{@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 bc19de5

Please sign in to comment.