11const core = require ( '@actions/core' )
22const { factory } = require ( 'release-please/build/src' )
33
4+ const CONFIG_FILE = 'release-please-config.json'
5+ const MANIFEST_FILE = '.release-please-manifest.json'
6+ const MANIFEST_COMMAND = 'manifest'
47const RELEASE_LABEL = 'autorelease: pending'
58const GITHUB_RELEASE_COMMAND = 'github-release'
69const GITHUB_RELEASE_PR_COMMAND = 'release-pr'
@@ -14,20 +17,62 @@ function getBooleanInput (input) {
1417 throw TypeError ( `Wrong boolean value of the input '${ input } '` )
1518}
1619
20+ function getGitHubInput ( ) {
21+ return {
22+ fork : getBooleanInput ( 'fork' ) ,
23+ defaultBranch : core . getInput ( 'default-branch' ) || undefined ,
24+ repoUrl : process . env . GITHUB_REPOSITORY ,
25+ apiUrl : 'https://api.github.com' ,
26+ token : core . getInput ( 'token' , { required : true } )
27+ }
28+ }
29+
30+ function getManifestInput ( ) {
31+ return {
32+ configFile : core . getInput ( 'config-file' ) || CONFIG_FILE ,
33+ manifestFile : core . getInput ( 'manifest-file' ) || MANIFEST_FILE
34+ }
35+ }
36+
37+ async function runManifest ( ) {
38+ const githubOpts = getGitHubInput ( )
39+ const manifestOpts = { ...githubOpts , ...getManifestInput ( ) }
40+ const pr = await factory . runCommand ( 'manifest-pr' , manifestOpts )
41+ if ( pr ) {
42+ core . setOutput ( 'pr' , pr )
43+ }
44+
45+ const releasesCreated = await factory . runCommand ( 'manifest-release' , manifestOpts )
46+ if ( releasesCreated ) {
47+ core . setOutput ( 'releases_created' , true )
48+ for ( const [ path , release ] of Object . entries ( releasesCreated ) ) {
49+ if ( ! release ) {
50+ continue
51+ }
52+ for ( const [ key , val ] of Object . entries ( release ) ) {
53+ core . setOutput ( `${ path } --${ key } ` , val )
54+ }
55+ }
56+ }
57+ }
58+
1759async function main ( ) {
60+ const command = core . getInput ( 'command' ) || undefined
61+ if ( command === MANIFEST_COMMAND ) {
62+ return await runManifest ( )
63+ }
64+
65+ const { token, fork, defaultBranch, apiUrl, repoUrl } = getGitHubInput ( )
66+
1867 const bumpMinorPreMajor = getBooleanInput ( 'bump-minor-pre-major' )
1968 const monorepoTags = getBooleanInput ( 'monorepo-tags' )
2069 const packageName = core . getInput ( 'package-name' )
2170 const path = core . getInput ( 'path' ) || undefined
2271 const releaseType = core . getInput ( 'release-type' , { required : true } )
23- const token = core . getInput ( 'token' , { required : true } )
24- const fork = getBooleanInput ( 'fork' )
2572 const changelogPath = core . getInput ( 'changelog-path' ) || undefined
2673 const changelogTypes = core . getInput ( 'changelog-types' ) || undefined
2774 const changelogSections = changelogTypes && JSON . parse ( changelogTypes )
28- const command = core . getInput ( 'command' ) || undefined
2975 const versionFile = core . getInput ( 'version-file' ) || undefined
30- const defaultBranch = core . getInput ( 'default-branch' ) || undefined
3176 const pullRequestTitlePattern = core . getInput ( 'pull-request-title-pattern' ) || undefined
3277
3378 // First we check for any merged release PRs (PRs merged with the label
@@ -62,10 +107,10 @@ async function main () {
62107 monorepoTags,
63108 packageName,
64109 path,
65- apiUrl : 'https://api.github.com' ,
66- repoUrl : process . env . GITHUB_REPOSITORY ,
110+ apiUrl,
111+ repoUrl,
67112 fork,
68- token : token ,
113+ token,
69114 label : RELEASE_LABEL ,
70115 bumpMinorPreMajor,
71116 changelogSections,
0 commit comments