Skip to content

Commit 31619c5

Browse files
committed
fix: changelog script
1 parent 226a7e3 commit 31619c5

File tree

2 files changed

+34
-5
lines changed

2 files changed

+34
-5
lines changed

.github/workflows/release.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ jobs:
2323
outputs:
2424
upload_url: ${{ steps.release.outputs.upload_url }}
2525
steps:
26+
- name: Parse Changelog # Exits if changelog not found
27+
id: changelog
28+
env:
29+
INPUT_VERSION: ${{ needs.check.outputs.version }}
30+
run: node ./scripts/changelog
2631
- name: Tag and Release
2732
uses: avakar/tag-and-release@v1
2833
with:
@@ -46,11 +51,6 @@ jobs:
4651
uses: actions/checkout@v2
4752
with:
4853
ref: ${{ needs.check.outputs.commit }}
49-
- name: Parse Changelog # Exits if changelog not found
50-
id: changelog
51-
env:
52-
INPUT_VERSION: ${{ needs.check.outputs.version }}
53-
run: node ./scripts/changelog
5454
- name: Set up Node.js
5555
uses: actions/setup-node@v1
5656
with:

scripts/changelog/io.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/* eslint-env node */
2+
const os = require('os');
3+
4+
exports.getInput = (key = '') => {
5+
const val = process.env[`INPUT_${key.replace(' ', '_').toUpperCase()}`] || '';
6+
7+
return val;
8+
};
9+
10+
exports.setOutput = (key = '', value = '') => {
11+
process.stdout.write(`::set-output${key ? ` name=${escape(key)}` : ''}::${escape(value)}${os.EOL}`);
12+
};
13+
14+
function toSafeString(s = '') {
15+
if (!s) {
16+
return '';
17+
}
18+
if (typeof s === 'string' || s instanceof String) {
19+
return s;
20+
}
21+
return JSON.stringify(s);
22+
}
23+
24+
function escape(s = '') {
25+
return toSafeString(s)
26+
.replace(/%/g, '%25')
27+
.replace(/\r/g, '%0D')
28+
.replace(/\n/g, '%0A');
29+
}

0 commit comments

Comments
 (0)