ci: Improve release automation (#29752)
parent
2ae66ab53a
commit
0f2f37d4db
@ -0,0 +1,5 @@ |
||||
--- |
||||
'@rocket.chat/release-action': minor |
||||
--- |
||||
|
||||
Use `release-automation` branch to perform the release |
||||
@ -1,6 +1,42 @@ |
||||
import { exec } from '@actions/exec'; |
||||
import { exec, getExecOutput } from '@actions/exec'; |
||||
|
||||
export async function setupGitUser() { |
||||
await exec('git', ['config', 'user.name', '"rocketchat-github-ci"']); |
||||
await exec('git', ['config', 'user.email', '"buildmaster@rocket.chat"']); |
||||
} |
||||
|
||||
export async function createBranch(newBranch: string) { |
||||
await exec('git', ['checkout', '-b', newBranch]); |
||||
} |
||||
|
||||
export async function checkoutBranch(branchName: string) { |
||||
await exec('git', ['checkout', branchName]); |
||||
} |
||||
|
||||
export async function mergeBranch(branchName: string) { |
||||
await exec('git', ['merge', '--no-edit', branchName]); |
||||
} |
||||
|
||||
export async function commitChanges(commitMessage: string) { |
||||
await exec('git', ['add', '.']); |
||||
await exec('git', ['commit', '-m', commitMessage]); |
||||
} |
||||
|
||||
export async function createTag(version: string) { |
||||
// create an annotated tag so git push --follow-tags will push the tag
|
||||
await exec('git', ['tag', version, '-m', version]); |
||||
} |
||||
|
||||
export async function getCurrentBranch() { |
||||
const { stdout: branchName } = await getExecOutput('git', ['rev-parse', '--abbrev-ref', 'HEAD']); |
||||
|
||||
return branchName.trim(); |
||||
} |
||||
|
||||
export async function pushChanges() { |
||||
await exec('git', ['push', '--follow-tags']); |
||||
} |
||||
|
||||
export async function pushNewBranch(newBranch: string) { |
||||
await exec('git', ['push', '--force', '--follow-tags', 'origin', `HEAD:refs/heads/${newBranch}`]); |
||||
} |
||||
|
||||
Loading…
Reference in new issue