Skip to content

Commit

Permalink
feature: Added automatic draft release and changelog updater (#23)
Browse files Browse the repository at this point in the history
  • Loading branch information
tiller1010 authored Jul 12, 2022
1 parent c67354b commit 65c0900
Show file tree
Hide file tree
Showing 4 changed files with 116 additions and 0 deletions.
31 changes: 31 additions & 0 deletions .github/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name-template: '$RESOLVED_VERSION'
tag-template: '$RESOLVED_VERSION'
categories:
- title: '🚀 Features'
labels:
- 'feature'
- 'enhancement'
- title: '🐛 Bug Fixes'
labels:
- 'fix'
- 'bugfix'
- 'bug'
- title: '🧰 Maintenance'
label: 'chore'
change-template: '- $TITLE @$AUTHOR (#$NUMBER)'
change-title-escapes: '\<*_&' # You can add # and @ to disable mentions, and add ` to disable code blocks.
version-resolver:
major:
labels:
- 'major'
minor:
labels:
- 'minor'
patch:
labels:
- 'patch'
default: patch
template: |
## What’s Changed
$CHANGES
32 changes: 32 additions & 0 deletions .github/tag-changelog-config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
module.exports = {
types: [
{ types: ["feat", "feature"], label: "🎉 New Features" },
{ types: ["fix", "bugfix", "bug"], label: "🐛 Bugfixes" },
{ types: ["improvements", "enhancement"], label: "🔨 Improvements" },
{ types: ["perf"], label: "🏎️ Performance Improvements" },
{ types: ["build", "ci"], label: "🏗️ Build System" },
{ types: ["refactor"], label: "🪚 Refactors" },
{ types: ["doc", "docs"], label: "📚 Documentation Changes" },
{ types: ["test", "tests"], label: "🔍 Tests" },
{ types: ["style"], label: "💅 Code Style Changes" },
{ types: ["chore"], label: "🧹 Chores" },
{ types: ["other"], label: "Other Changes" },
],

excludeTypes: ["other"],

renderTypeSection: function (label, commits) {
let text = `\n## ${label}\n`;

commits.forEach((commit) => {
text += `- ${commit.subject}\n`;
});

return text;
},

renderChangelog: function (release, changes) {
const now = new Date();
return `## ${release} - ${now.toISOString().substr(0, 10)}\n` + changes + "\n\n";
},
};
33 changes: 33 additions & 0 deletions .github/workflows/changelog.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Generate Changelog

on:
release:
types: [published]

permissions:
contents: write

jobs:
update_changelog:
runs-on: ubuntu-latest
outputs:
output: ${{ steps.changelog.outputs.changelog }}
steps:
- name: Checkout
uses: actions/checkout@v2
with:
ref: main
- name: Generate Changelog
id: changelog
uses: loopwerk/[email protected]
with:
token: ${{ secrets.GITHUB_TOKEN }}
exclude_types: other,doc,chore
config_file: .github/tag-changelog-config.js
- name: Output Changelog
id: output_changelog
run: TAGCONTENT="${{ steps.changelog.outputs.changelog }}";CHANGELOG=$(cat CHANGELOG.md);CHANGELOG=$(echo "$CHANGELOG" | sed -e "s/# Changelog//");echo -e "# Changelog\n\n$TAGCONTENT$CHANGELOG" > CHANGELOG.md
- name: Commit Updated Changelog
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: Updated CHANGELOG.md
20 changes: 20 additions & 0 deletions .github/workflows/draftrelease.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Release Drafter

on:
push:
branches:
- main

permissions:
contents: read

jobs:
update_release_draft:
permissions:
contents: write
runs-on: ubuntu-latest
steps:
- name: Draft Release
uses: release-drafter/release-drafter@v5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 comments on commit 65c0900

Please sign in to comment.