Skip to content

Commit

Permalink
ci: Add latest changelog entry to Github release
Browse files Browse the repository at this point in the history
  • Loading branch information
MorevM committed Apr 7, 2024
1 parent e98c481 commit 9336acb
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .github/extract-latest-changelog-entry.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
const { readFileSync } = require('node:fs');
const { join } = require('node:path');

module.exports = () => {
const contents = readFileSync(join(__dirname, '..', 'CHANGELOG.md'), { encoding: 'utf8' });
return contents.match(/## .*?\n(.*?)## [\d[]/s)[1].trim();
};
11 changes: 11 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,21 @@ jobs:
- name: Build
run: yarn build

- name: Getting latest changelog entry
uses: actions/github-script@v7
id: latest-changelog-entry
with:
result-encoding: string
script: |
const extractLatestChangelogEntry = require('./.github/extract-latest-changelog-entry.cjs');
return extractLatestChangelogEntry();
- name: Create release
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
body: ${{steps.latest-changelog-entry.outputs.result}}

- name: Publish package
run: yarn publish --access public
Expand Down

0 comments on commit 9336acb

Please sign in to comment.