Update version in `config.yml` via YAML load / dump (#6677)

Merge pull request 6677
This commit is contained in:
Florian Thomas 2018-01-06 16:10:31 +00:00 committed by jekyllbot
parent a84e9e1f6d
commit 6a827547ab
2 changed files with 46 additions and 55 deletions

View File

@ -1,49 +1,37 @@
sass:
style: compressed
version: 3.7.0 # latest version displayed in header
gauges_id: 503c5af6613f5d0f19000027
google_analytics_id: UA-50755011-1
google_site_verification: onQcXpAvtHBrUI5LlroHNE_FP0b2qvFyPq7VZw36iEY
repository: https://github.com/jekyll/jekyll
timezone: America/Los_Angeles
defaults:
-
scope:
path: "_docs"
type: "docs"
values:
layout: "docs"
-
scope:
path: "_posts"
type: "posts"
values:
layout: "news_item"
image: /img/twitter-card.png
collections:
docs:
permalink: /:collection/:path/
output: true
posts:
permalink: /news/:year/:month/:day/:title/
output: true
tutorials:
output: true
---
version: 3.7.0
name: Jekyll • Simple, blog-aware, static sites
description: Transform your plain text into static websites and blogs
url: https://jekyllrb.com
repository: https://github.com/jekyll/jekyll
timezone: America/Los_Angeles
twitter:
username: jekyllrb
logo: /img/logo-2x.png
logo: "/img/logo-2x.png"
gauges_id: 503c5af6613f5d0f19000027
google_analytics_id: UA-50755011-1
google_site_verification: onQcXpAvtHBrUI5LlroHNE_FP0b2qvFyPq7VZw36iEY
collections:
docs:
permalink: "/:collection/:path/"
output: true
posts:
permalink: "/news/:year/:month/:day/:title/"
output: true
tutorials:
output: true
defaults:
- scope:
path: _docs
type: docs
values:
layout: docs
- scope:
path: _posts
type: posts
values:
layout: news_item
image: "/img/twitter-card.png"
plugins:
- jekyll-avatar
- jekyll-feed
@ -52,9 +40,10 @@ plugins:
- jekyll-seo-tag
- jekyll-sitemap
- jemoji
sass:
style: compressed
exclude:
- .gitignore
- ".gitignore"
- CNAME
- icomoon-selection.json
- readme.md

View File

@ -87,9 +87,11 @@ namespace :site do
desc "Write the latest Jekyll version"
task :latest_version do
return if version =~ %r!(beta|rc|alpha)!i
require "safe_yaml/load"
config_file = File.join(docs_folder, "_config.yml")
contents = File.read(config_file)
File.write(config_file, contents.sub(%r!(?:version\s*:\s+)(.+)!, "version: #{version}"))
config = SafeYAML.load_file(config_file)
config["version"] = version
File.write(config_file, YAML.dump(config))
File.open("#{docs_folder}/latest_version.txt", "wb") { |f| f.puts(version) }
end