11const core = require ( '@actions/core' )
2- const { GitHubRelease } = require ( 'release-please/build/src/github-release' )
3- const { ReleasePR } = require ( 'release-please/build/src/release-pr' )
2+ const { factory } = require ( 'release-please/build/src' )
43
54const RELEASE_LABEL = 'autorelease: pending'
5+ const GITHUB_RELEASE_COMMAND = 'github-release'
6+ const GITHUB_RELEASE_PR_COMMAND = 'release-pr'
67
78async function main ( ) {
89 const bumpMinorPreMajor = Boolean ( core . getInput ( 'bump-minor-pre-major' ) )
@@ -26,9 +27,8 @@ async function main () {
2627
2728 // First we check for any merged release PRs (PRs merged with the label
2829 // "autorelease: pending"):
29- if ( ! command || command === 'github-release' ) {
30- const Release = releasePlease . getGitHubRelease ( )
31- const gr = new Release ( {
30+ if ( ! command || command === GITHUB_RELEASE_COMMAND ) {
31+ const releaseCreated = await factory . runCommand ( GITHUB_RELEASE_COMMAND , {
3232 label : RELEASE_LABEL ,
3333 repoUrl : process . env . GITHUB_REPOSITORY ,
3434 packageName,
@@ -39,7 +39,7 @@ async function main () {
3939 releaseType,
4040 defaultBranch
4141 } )
42- const releaseCreated = await gr . run ( )
42+
4343 if ( releaseCreated ) {
4444 core . setOutput ( 'release_created' , true )
4545 for ( const key of Object . keys ( releaseCreated ) ) {
@@ -50,9 +50,8 @@ async function main () {
5050
5151 // Next we check for PRs merged since the last release, and groom the
5252 // release PR:
53- if ( ! command || command === 'release-pr' ) {
54- const GithubReleasePR = releasePlease . getReleasePR ( )
55- const release = new GithubReleasePR ( {
53+ if ( ! command || command === GITHUB_RELEASE_PR_COMMAND ) {
54+ const pr = await factory . runCommand ( GITHUB_RELEASE_PR_COMMAND , {
5655 releaseType,
5756 monorepoTags,
5857 packageName,
@@ -68,25 +67,14 @@ async function main () {
6867 defaultBranch
6968 } )
7069
71- const pr = await release . run ( )
7270 if ( pr ) {
7371 core . setOutput ( 'pr' , pr )
7472 }
7573 }
7674}
7775
78- function getGitHubRelease ( ) {
79- return GitHubRelease
80- }
81-
82- function getReleasePR ( ) {
83- return ReleasePR
84- }
85-
8676const releasePlease = {
87- main,
88- getGitHubRelease,
89- getReleasePR
77+ main
9078}
9179
9280if ( require . main === module ) {
0 commit comments