Skip to content

Commit

Permalink
Fix heading level in auto-generated README
Browse files Browse the repository at this point in the history
The per-release headings in the auto-generated changelog used the
wrong level. The code worked by accident since there was an existing
'### Unreleased' heading, but it would have been broken next time.
  • Loading branch information
mgeisler committed Aug 5, 2020
1 parent a1d5b3e commit f733ad5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/prepare-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,11 @@ jobs:
var readme = fs.readFileSync('README.md', 'utf8')
const today = new Date().toISOString().split('T')[0]
const heading = `## Version ${new_version} (${today})\n`
if (readme.match('## Unreleased')) {
readme = readme.replace('## Unreleased', `${heading}\n${changelog}`)
const heading = `### Version ${new_version} (${today})\n`
if (readme.match('### Unreleased')) {
readme = readme.replace('### Unreleased', `${heading}\n${changelog}`)
} else {
readme = readme.replace('# Changelog', `# Changelog\n\n${heading}\n${changelog}`)
readme = readme.replace('## Changelog', `## Changelog\n\n${heading}\n${changelog}`)
}
fs.writeFileSync('README.md', readme)
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish-crate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
run: |
NAME=$(cargo metadata -q --no-deps | jq -r '.packages[0].name')
VERSION=$(cargo metadata -q --no-deps | jq -r '.packages[0].version')
CHANGELOG=$(awk '/^## Version/ {i++}; i==1 {print}; i>1 {exit}' README.md \
CHANGELOG=$(awk '/^### Version/ {i++}; i==1 {print}; i>1 {exit}' README.md \
| python3 -c 'import sys, json; print(json.dumps(sys.stdin.read()))')
echo "::set-output name=name::$NAME"
echo "::set-output name=version::$VERSION"
Expand Down

0 comments on commit f733ad5

Please sign in to comment.