feature: create auto-changie to automatically generate changelog
This commit is contained in:
parent
0f8a64c81c
commit
d94180114d
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
.idea/
|
||||
*.iml
|
29
action.yml
Normal file
29
action.yml
Normal file
@ -0,0 +1,29 @@
|
||||
name: 'Auto changie'
|
||||
description: 'Changie action with auto numbering'
|
||||
inputs:
|
||||
changie-version:
|
||||
description: 'Changie version'
|
||||
default: 'latest'
|
||||
required: false
|
||||
runs:
|
||||
using: "composite"
|
||||
steps:
|
||||
- name: Setup node
|
||||
uses: actions/setup-node@v4.0.2
|
||||
with:
|
||||
node-version: 20
|
||||
|
||||
- name: Install changie
|
||||
run: npm i -g changie@${{ input.changie-version }}
|
||||
shell: bash
|
||||
|
||||
- name: Set GitHub Path
|
||||
run: echo "$GITHUB_ACTION_PATH" >> $GITHUB_PATH
|
||||
shell: bash
|
||||
env:
|
||||
GITHUB_ACTION_PATH: ${{ github.action_path }}
|
||||
|
||||
- name: Update changelog with last commit
|
||||
run: script.sh
|
||||
shell: bash
|
||||
|
39
script.sh
Executable file
39
script.sh
Executable file
@ -0,0 +1,39 @@
|
||||
#!/bin/bash
|
||||
|
||||
if [ ! -f .changie.yaml ];
|
||||
then
|
||||
echo "changie init"
|
||||
changie init
|
||||
# require to format unreleased file with more accurate name than seconds to avoid overriding file during multiple `changie new` in same seconds
|
||||
echo "fragmentFileFormat: '{{.Kind}}-{{.Time.Format \"02012006-150405.000\"}}'" >> .changie.yaml
|
||||
fi
|
||||
|
||||
noRelease=$(cat CHANGELOG.md | grep 'No releases yet')
|
||||
|
||||
# if never release take the first commit of all time
|
||||
if [ -z "$noRelease" ];
|
||||
then
|
||||
lastVersion=$(changie latest)
|
||||
lastSeenCommit=$(cat .changes/$lastVersion.md | grep --only-matching --max-count 1 -E '\b[0-9a-f]{5,40}\b')
|
||||
else
|
||||
lastSeenCommit=$(git rev-list --max-parents=0 HEAD --abbrev-commit)
|
||||
fi
|
||||
|
||||
commit=$(git log --oneline --pretty=format:'%h - %s' --abbrev-commit $lastSeenCommit..HEAD)
|
||||
|
||||
# deal with case of no new commit
|
||||
if [ -n "$commit" ]; then
|
||||
|
||||
# add all new commit as unreleased change
|
||||
while IFS= read -r line ; do
|
||||
echo "$line";
|
||||
changie new --kind Changed --body "$line"
|
||||
done <<< "$commit"
|
||||
|
||||
# group unreleased change in version file
|
||||
changie batch auto | true
|
||||
|
||||
# create changelog file
|
||||
changie merge
|
||||
fi
|
||||
|
Loading…
Reference in New Issue
Block a user