scripts/patch-release-for-pr: fix version check point and keep diff points
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
@@ -25,7 +25,7 @@ jobs:
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
ref: '${{ github.event.pull_request.head.sha }}'
|
||||
ref: '${{ github.event.pull_request.merge_commit_sha }}'
|
||||
|
||||
- name: fetch base
|
||||
run: git fetch --depth 1 origin ${{ github.event.pull_request.base.sha }}
|
||||
@@ -36,7 +36,7 @@ jobs:
|
||||
run: |
|
||||
rm -f generate.js
|
||||
wget -O generate.js https://raw.githubusercontent.com/backstage/backstage/master/scripts/generate-merge-message.js 1>&2
|
||||
node generate.js FETCH_HEAD > message.txt
|
||||
node generate.js ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }} > message.txt
|
||||
|
||||
- name: Post Message
|
||||
uses: actions/github-script@v6
|
||||
|
||||
@@ -21,15 +21,20 @@ const { resolve: resolvePath } = require('path');
|
||||
|
||||
const execFile = promisify(execFileCb);
|
||||
|
||||
async function hasNewChangesets(ref) {
|
||||
if (!ref) {
|
||||
throw new Error('ref is required');
|
||||
async function hasNewChangesets(baseRef, headRef) {
|
||||
if (!baseRef) {
|
||||
throw new Error('baseRef is required');
|
||||
}
|
||||
if (!headRef) {
|
||||
throw new Error('headRef is required');
|
||||
}
|
||||
|
||||
const { stdout } = await execFile('git', [
|
||||
'diff',
|
||||
'--compact-summary',
|
||||
ref,
|
||||
baseRef,
|
||||
headRef,
|
||||
'--',
|
||||
'.changeset/*.md',
|
||||
]);
|
||||
return stdout.includes('(new)');
|
||||
@@ -88,8 +93,9 @@ function findNextRelease(currentRelease, releaseSchedule) {
|
||||
}
|
||||
|
||||
async function main() {
|
||||
const [diffRef = 'origin/master'] = process.argv.slice(2);
|
||||
const needsMessage = await hasNewChangesets(diffRef);
|
||||
const [diffBaseRefRef = 'origin/master', diffHeadRef = 'HEAD'] =
|
||||
process.argv.slice(2);
|
||||
const needsMessage = await hasNewChangesets(diffBaseRefRef, diffHeadRef);
|
||||
if (!needsMessage) {
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user