Skip to content
This repository has been archived by the owner on Jul 9, 2023. It is now read-only.

Commit

Permalink
update changelog format
Browse files Browse the repository at this point in the history
  • Loading branch information
n8maninger committed Sep 16, 2021
1 parent f30c4db commit fb51eb6
Show file tree
Hide file tree
Showing 2 changed files with 197 additions and 242 deletions.
46 changes: 46 additions & 0 deletions .github/workflows/package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,52 @@ jobs:
# package
cd $wd
npm run publish -- --win --linux --mac --x64
- name: publish changelog
uses: actions/github-script@v4
with:
script: |
// extract the repo and tag
const { repo: githubRepo, ref } = context,
{ owner, repo } = githubRepo,
tag = ref.replace('refs/tags/', '').trim(),
{ data } = await github.repos.getReleaseByTag({
owner, repo, tag
}),
{ name, id: release_id } = data,
// read the changelog
logLines = require('fs').readFileSync('CHANGELOG.md').toString('utf-8').split('\n');
// find matching release in the changelog
let body = [], found;
for (let i = 0; i < logLines.length; i++) {
const line = logLines[i];
// if this line matches the target release header, start collecting lines
if (line.indexOf(`# ${name}`) === 0) {
found = true;
continue;
}
// if the release hasn't been seen yet, skip
if (!found)
continue;
// if the line matches the next release header, stop
else if (/^# [0-9]+\.[0-9]+\.[0-9]+/.test(line)) {
body = body.join('\n').trim();
break;
}
// otherwise, add the line to the body
body.push(line);
}
// if we didn't find the body, throw an error
if (!body.length)
throw new Error(`Could not find release body for ${name}`);
// update the release
await github.repos.updateRelease({
owner, repo, body, release_id
});
- name: cleanup
if: ${{ always() }}
run: |
Expand Down
Loading

0 comments on commit fb51eb6

Please sign in to comment.