Skip to content

Commit

Permalink
Fix auto generate changelog workflow
Browse files Browse the repository at this point in the history
Part 6
  • Loading branch information
yell0wsuit committed Aug 11, 2024
1 parent d51bbfe commit b1d148c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 18 deletions.
33 changes: 16 additions & 17 deletions .github/workflows/offline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,25 +79,24 @@ jobs:
});
const latestTag = tags.length > 0 ? tags[0].name : null;
const latestTagDate = latestTag && latestTag.commit && latestTag.commit.committer
? new Date(latestTag.commit.committer.date)
: null;
const { data: commits } = await github.rest.repos.listCommits({
owner: context.repo.owner,
repo: context.repo.repo,
per_page: 100,
sha: 'main',
});
const changelog = commits
.filter(commit => latestTagDate ? new Date(commit.commit.author.date) > latestTagDate : true)
.map(commit => `- ${commit.commit.message}`)
.join("\n");
if (latestTag) {
const { data: compare } = await github.rest.repos.compareCommits({
owner: context.repo.owner,
repo: context.repo.repo,
base: latestTag,
head: 'main',
});
const finalChangelog = changelog || 'No significant changes.';
const changelog = compare.commits
.map(commit => `- ${commit.commit.message}`)
.join("\n");
core.setOutput('changelog', finalChangelog);
const finalChangelog = changelog || 'No significant changes.';
core.setOutput('changelog', finalChangelog);
} else {
core.setOutput('changelog', 'No previous tags found.');
}
- name: Create GitHub release
id: create_release
Expand All @@ -108,4 +107,4 @@ jobs:
tag_name: ${{ env.latest_tag }}
name: v${{ env.PACKAGE_VERSION }}
body: ${{ steps.generate_changelog.outputs.changelog }}
files: docusaurus-offline-site-v${{ env.PACKAGE_VERSION }}.zip
files: docugrammar-offline-v${{ env.PACKAGE_VERSION }}.zip
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "docugrammar",
"version": "3.1.9",
"version": "3.1.10",
"private": true,
"scripts": {
"docusaurus": "docusaurus",
Expand Down

0 comments on commit b1d148c

Please sign in to comment.