forked from googleapis/release-please-action
-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.js
50 lines (45 loc) · 1.59 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
const core = require('@actions/core')
const { GitHubRelease } = require('release-please/build/src/github-release')
const { ReleasePRFactory } = require('release-please/build/src/release-pr-factory')
const RELEASE_LABEL = 'autorelease: pending'
async function main () {
const bumpMinorPreMajor = Boolean(core.getInput('bump-minor-pre-major'))
const monorepoTags = Boolean(core.getInput('monorepo-tags'))
const packageName = core.getInput('package-name')
const path = core.getInput('path') ? core.getInput('path') : undefined
const releaseType = core.getInput('release-type')
const token = core.getInput('token')
// First we check for any merged release PRs (PRs merged with the label
// "autorelease: pending"):
const gr = new GitHubRelease({
label: RELEASE_LABEL,
repoUrl: process.env.GITHUB_REPOSITORY,
packageName,
path,
token
})
const releaseCreated = await gr.createRelease()
if (releaseCreated) {
// eslint-disable-next-line
const { upload_url, tag_name } = releaseCreated
core.setOutput('release_created', true)
core.setOutput('upload_url', upload_url)
core.setOutput('tag_name', tag_name)
}
// Next we check for PRs merged since the last release, and groom the
// release PR:
const release = ReleasePRFactory.buildStatic(releaseType, {
monorepoTags,
packageName,
path,
apiUrl: 'https://api.github.com',
repoUrl: process.env.GITHUB_REPOSITORY,
token: token,
label: RELEASE_LABEL,
bumpMinorPreMajor
})
await release.run()
}
main().catch(err => {
core.setFailed(`release-please failed: ${err.message}`)
})