diff --git a/.chglog/CHANGELOG.tpl.md b/.chglog/CHANGELOG.tpl.md new file mode 100755 index 0000000..a092888 --- /dev/null +++ b/.chglog/CHANGELOG.tpl.md @@ -0,0 +1,38 @@ +{{ range .Versions }} + +## {{ 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 -}} +* {{ if .Scope }}**{{ .Scope }}:** {{ end }}{{ .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 -}} \ No newline at end of file diff --git a/.chglog/config.yml b/.chglog/config.yml new file mode 100755 index 0000000..9cf5d96 --- /dev/null +++ b/.chglog/config.yml @@ -0,0 +1,28 @@ +style: github +template: CHANGELOG.tpl.md +info: + title: CHANGELOG + repository_url: https://dev.ksite.de/ralf.kirchner/demo +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*)(?:\\(([\\w\\$\\.\\-\\*\\s]*)\\))?\\:\\s(.*)$" + pattern_maps: + - Type + - Scope + - Subject + notes: + keywords: + - BREAKING CHANGE \ No newline at end of file diff --git a/.gitea/workflows/release.yml b/.gitea/workflows/release.yml index bcf4249..a6187ac 100644 --- a/.gitea/workflows/release.yml +++ b/.gitea/workflows/release.yml @@ -1,29 +1,44 @@ -name: Release +name: Build Changelog and Release on: push: - branches: - - main + tags: + - 'v*.*.*' jobs: release: runs-on: ubuntu-latest + steps: - - name: Check out code + - name: Checkout code uses: actions/checkout@v3 - - name: Setup Node.js - uses: actions/setup-node@v3 - with: - node-version: '20' + - name: Install git-chglog + run: | + curl -sSL https://github.com/git-chglog/git-chglog/releases/download/v0.15.1/git-chglog_0.15.1_linux_amd64.tar.gz | tar -xz + sudo mv git-chglog /usr/local/bin/ - - name: Install dependencies - run: npm ci + - name: Generate changelog + run: | + git-chglog $(git describe --tags --abbrev=0) > RELEASE_NOTES.md - - name: Run semantic-release - run: npx semantic-release - - - name: Create Gitea release - run: .gitea/workflows/create-gitea-release.sh + - name: Create Release on Gitea env: - GITEA_TOKEN: ${{ secrets.GIT_TOKEN }} + GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }} + run: | + TAG=$(git describe --tags) + REPO=${GITEA_REPOSITORY#*/} + OWNER=${GITEA_REPOSITORY%/*} + BODY=$(cat RELEASE_NOTES.md | jq -Rs .) + + curl -X POST "https://gitea.example.com/api/v1/repos/$OWNER/$REPO/releases" \ + -H "Authorization: token $GITEA_TOKEN" \ + -H "Content-Type: application/json" \ + -d "{ + \"tag_name\": \"$TAG\", + \"name\": \"$TAG\", + \"body\": $BODY, + \"draft\": false, + \"prerelease\": false + }" +