Skip to content

Commit

Permalink
auto generate changelog
Browse files Browse the repository at this point in the history
  • Loading branch information
yell0wsuit authored Aug 10, 2024
1 parent e827947 commit 0f3c592
Showing 1 changed file with 30 additions and 3 deletions.
33 changes: 30 additions & 3 deletions .github/workflows/offline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,34 @@ jobs:
git tag ${{ env.latest_tag }}
git push origin ${{ env.latest_tag }}
- name: Generate changelog
id: generate_changelog
uses: actions/github-script@v7
with:
script: |
const { data: commits } = await github.repos.listCommits({
owner: context.repo.owner,
repo: context.repo.repo,
per_page: 100,
sha: 'main',
});
const lastTagCommitSha = await github.git.getCommit({
owner: context.repo.owner,
repo: context.repo.repo,
commit_sha: '${{ env.latest_tag }}',
}).then(({ data }) => data.sha);

const changelog = commits
.filter(commit => commit.sha !== lastTagCommitSha)
.map(commit => `- ${commit.commit.message}`)
.join("\n");

return changelog || 'No significant changes.';

result-encoding: string
result: changelog

- name: Create GitHub release
id: create_release
uses: softprops/action-gh-release@v2
Expand All @@ -75,6 +103,5 @@ jobs:
with:
tag_name: ${{ env.latest_tag }}
name: v${{ env.PACKAGE_VERSION }}
body: |
Release version ${{ env.PACKAGE_VERSION }} of the project.
files: docugrammar-offline-v${{ env.PACKAGE_VERSION }}.zip
body: ${{ steps.generate_changelog.outputs.changelog }}
files: docusaurus-offline-site-v${{ env.PACKAGE_VERSION }}.zip

0 comments on commit 0f3c592

Please sign in to comment.