Skip to content

Commit

Permalink
Feature/auto changelog (#280)
Browse files Browse the repository at this point in the history
* Update requirements.txt

- Remove coverage from here, it got moved to the test one.

* Adding in Auto Changelog

- changelog must be markdown
- adding in the action

* Update auto_change_log.yml

- fix issue on line 20.

* Update auto_change_log.yml

- fixing more indentation issues.

* Update auto_change_log.yml

-  updating the install of gitchglog

* Update auto_change_log.yml

- how about via snap.

* Update auto_change_log.yml

- need to override

* Ran Init

- okay now maybe this will work.

* Update auto_change_log.yml

- path got lost for chglog. Add it in.

* Update auto_change_log.yml

- okay, try using another action to run linux commands.

* Update auto_change_log.yml

- need git

* Update auto_change_log.yml

-s at path maybe

* workflow and md

- created the changelog file
- another try at the workflow file

* Update auto_change_log.yml

- adding  with:
      fetch-depth: 0

* Update auto_change_log.yml

- missing semicolon

* Update auto_change_log.yml

- no longer build on PR to main.
  • Loading branch information
carlkidcrypto authored Jan 12, 2025
1 parent a45960e commit 62ef0b5
Show file tree
Hide file tree
Showing 6 changed files with 595 additions and 6 deletions.
38 changes: 38 additions & 0 deletions .chglog/CHANGELOG.tpl.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{{ range .Versions }}
<a name="{{ .Tag.Name }}"></a>
## {{ if .Tag.Previous }}[{{ .Tag.Name }}]({{ $.Info.RepositoryURL }}/compare/{{ .Tag.Previous.Name }}...{{ .Tag.Name }}){{ else }}{{ .Tag.Name }}{{ end }} ({{ datetime "2006-01-02" .Tag.Date }})

{{ range .CommitGroups -}}
### {{ .Title }}

{{ range .Commits -}}
* {{ .Subject }}
{{ end }}
{{ end -}}

{{- if .RevertCommits -}}
### Reverts

{{ range .RevertCommits -}}
* {{ .Revert.Header }}
{{ end }}
{{ end -}}

{{- if .MergeCommits -}}
### Pull Requests

{{ range .MergeCommits -}}
* {{ .Header }}
{{ end }}
{{ end -}}

{{- if .NoteGroups -}}
{{ range .NoteGroups -}}
### {{ .Title }}

{{ range .Notes }}
{{ .Body }}
{{ end }}
{{ end -}}
{{ end -}}
{{ end -}}
27 changes: 27 additions & 0 deletions .chglog/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
style: github
template: CHANGELOG.tpl.md
info:
title: CHANGELOG
repository_url: https://github.com/carlkidcrypto/ezsnmp
options:
commits:
# filters:
# Type:
# - feat
# - fix
# - perf
# - refactor
commit_groups:
# title_maps:
# feat: Features
# fix: Bug Fixes
# perf: Performance Improvements
# refactor: Code Refactoring
header:
pattern: "^((\\w+)\\s.*)$"
pattern_maps:
- Subject
- Type
notes:
keywords:
- BREAKING CHANGE
66 changes: 66 additions & 0 deletions .github/workflows/auto_change_log.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: "Update Changelog"

on:
release:
types: [published]
workflow_dispatch:

permissions:
contents: write
pull-requests: write

jobs:
update-changelog:
runs-on: ubuntu-latest
steps:
- name: Check out repository code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup git-chglog
uses: carlkidcrypto/[email protected]
with:
linux: |
sudo snap install go --classic;
go install github.com/git-chglog/git-chglog/cmd/git-chglog@latest;
- name: Generate CHANGELOG.md
id: generate
uses: carlkidcrypto/[email protected]
with:
linux: |
rm -f CHANGELOG.md;
echo "PATH=$PATH:/usr/bin" >> $GITHUB_ENV;
~/go/bin/git-chglog --config /home/runner/work/ezsnmp/ezsnmp/.chglog/config.yml -o CHANGELOG.md;
if git diff --quiet CHANGELOG.md; then
echo "changes=false" >> $GITHUB_OUTPUT
else
echo "changes=true" >> $GITHUB_OUTPUT
fi;
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Create Pull Request
if: steps.generate.outputs.changes == 'true'
uses: peter-evans/create-pull-request@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: "chore: update CHANGELOG.md"
title: "📝 Update Changelog"
body: |
This PR updates the CHANGELOG.md to include all releases.
- Generated using git-chglog
- Triggered by: ${{ github.event_name }}
- Auto-merge enabled
branch: update-changelog-${{ github.run_id }}
base: main
delete-branch: true
labels: documentation, automated-pr

- name: Enable Auto-merge
if: steps.generate.outputs.changes == 'true'
run: |
gh pr merge --auto --merge "${{ steps.create-pr.outputs.pull-request-number }}"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Loading

0 comments on commit 62ef0b5

Please sign in to comment.