Skip to content

Commit

Permalink
enhance(scripts/release): update existing PR
Browse files Browse the repository at this point in the history
  • Loading branch information
caugner committed Oct 23, 2024
1 parent 6c52fd0 commit ad1899d
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions scripts/release/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,26 @@ const commitAndPR = async (
console.log('');
}

const [title, ...bodyParts] = message.split('\n');
const body = bodyParts.join('\n').trim();

/**
* Quotes a string.
* @param str string to quote
* @returns quoted string
*/
const quote = (str: string) => `'${str.replace(/'/g, "\\'")}'`;

exec(`
git switch main
git switch -c ${branch}
git add package.json package-lock.json RELEASE_NOTES.md
git commit ${message
.split('\n')
.map((line) => `-m '${line.replace(/'/g, "\\'")}'`)
.map((line) => `-m ${quote(line)}`)
.join(' ')}
git push --set-upstream origin ${branch}
gh pr create --fill
gh pr edit --title ${quote(title)} --body ${quote(body)}${'' /* || gh pr create --title ${quote(title)} --body ${quote(body)}*/}
git switch main
git branch -d ${branch}
`);
Expand Down

0 comments on commit ad1899d

Please sign in to comment.