Skip to content

Commit

Permalink
ci: Extract latest changelog entry as GH release description
Browse files Browse the repository at this point in the history
  • Loading branch information
MorevM committed Jun 7, 2024
1 parent 5cb450b commit 08b2caa
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: Testing
run: yarn test

- 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 08b2caa

Please sign in to comment.