Skip to content

Commit b9864f3

Browse files
committed
update changelog updater
1 parent 3bc2405 commit b9864f3

File tree

1 file changed

+20
-8
lines changed

1 file changed

+20
-8
lines changed

.github/workflows/update-changelog.yaml

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,32 +4,44 @@ on:
44
branches:
55
- main
66
- master
7+
tags:
8+
- '*'
79

810
jobs:
911
update-changelog:
1012
runs-on: ubuntu-latest
1113
steps:
14+
- name: get-default-branch
15+
run: |
16+
branch=$(curl -s "https://api.github.com/repos/$GITHUB_REPOSITORY" | jq -r '.default_branch')
17+
echo "default_branch=$branch" >> $GITHUB_ENV
1218
- name: checkout
1319
uses: actions/checkout@v3
20+
with:
21+
ref: ${{ env.default_branch }}
1422
- uses: 8BitJonny/[email protected]
1523
id: PR
24+
- uses: little-core-labs/[email protected]
25+
id: current-tag
1626
- uses: actions-ecosystem/action-get-latest-tag@v1
1727
id: get-latest-tag
1828
with:
1929
semver_only: true
2030
initial_version: 0.0.0
2131
- name: update-changelog
22-
if: steps.PR.outputs.number != ''
32+
if: steps.PR.outputs.number != '' || steps.current-tag.outputs.tag != ''
2333
run: |
2434
MAJOR_VERSION=$(ls | grep CHANGELOG | cut -d'-' -f 2 | cut -f 1 -d '.' | grep v | sort -V -r | head -n 1)
2535
if [ -z "$MAJOR_VERSION" ]; then
2636
MAJOR_VERSION=0
37+
else
38+
MAJOR_VERSION=${MAJOR_VERSION#"v"}
39+
MAJOR_VERSION=$((MAJOR_VERSION+1))
2740
fi
28-
MAJOR_VERSION=${MAJOR_VERSION#"v"}
29-
MAJOR_VERSION=$((MAJOR_VERSION+1))
30-
# if latest tag is 2.6.0 and current unreleased major version is 3.0.0, use 2.6.0; if current major version is 2.0.0 and latest tag is 2.6.0, use 2.0.0
31-
VERSION=$(printf '$MAJOR_VERSION.0.0\n${{ steps.get-latest-tag.outputs.tag }}\n' | sort -V | head -n 1)
32-
docker run --rm -v $(pwd):/src -w /src githubchangeloggenerator/github-changelog-generator -u ${{ github.repository_owner }} -p ${{ github.event.repository.name }} -t ${{ secrets.GITHUB_TOKEN }} --no-issues --no-compare-link --since-tag $VERSION
33-
- uses: stefanzweifel/git-auto-commit-action@v4
41+
docker run --rm -v $(pwd):/src -w /src githubchangeloggenerator/github-changelog-generator -u ${{ github.repository_owner }} -p ${{ github.event.repository.name }} -t ${{ secrets.GITHUB_TOKEN }} --no-issues --no-compare-link --include-tags-regex "$MAJOR_VERSION\..*\..*"
42+
- name: Commit & Push changes
43+
uses: actions-js/push@master
3444
with:
35-
commit_message: Update Changelog
45+
github_token: ${{ secrets.GITHUB_TOKEN }}
46+
message: 'Update changelog'
47+
branch: ${{ env.default_branch }}

0 commit comments

Comments
 (0)