From 546de4e1ec962156112b6e5b306e8dae6e73beae Mon Sep 17 00:00:00 2001 From: Jeff Ching Date: Thu, 30 Nov 2023 12:33:12 -0800 Subject: [PATCH] build: actually run main() in index.ts (#882) When converting to typescript we didn't call the main() method if index.ts/js is invoked directly. --- .github/workflows/release-please.yaml | 4 ++-- dist/index.js | 9 +++++++++ src/index.ts | 10 ++++++++++ 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release-please.yaml b/.github/workflows/release-please.yaml index f7a5920..67177da 100644 --- a/.github/workflows/release-please.yaml +++ b/.github/workflows/release-please.yaml @@ -62,7 +62,7 @@ jobs: runs-on: ubuntu-latest needs: [build] steps: - - uses: GoogleCloudPlatform/release-please-action@main + - uses: google-github-actions/release-please-action@main id: release with: token: ${{ secrets.GITHUB_TOKEN }} @@ -90,7 +90,7 @@ jobs: - release-please-release steps: - id: release-pr - uses: GoogleCloudPlatform/release-please-action@main + uses: google-github-actions/release-please-action@main with: token: ${{ secrets.ACTIONS_BOT_TOKEN }} release-type: node diff --git a/dist/index.js b/dist/index.js index 6242a5d..ecc8b6b 100644 --- a/dist/index.js +++ b/dist/index.js @@ -116257,6 +116257,7 @@ function getOptionalBooleanInput(name) { } function loadOrBuildManifest(github, inputs) { if (inputs.releaseType) { + core.debug('Building manifest from config'); return release_please_1.Manifest.fromConfig(github, github.repository.defaultBranch, { releaseType: inputs.releaseType, }, { @@ -116268,6 +116269,7 @@ function loadOrBuildManifest(github, inputs) { fork: inputs.fork, } : {}; + core.debug('Loading manifest from config file'); return release_please_1.Manifest.fromManifest(github, github.repository.defaultBranch, inputs.configFile, inputs.manifestFile, manifestOverrides); } async function main() { @@ -116275,10 +116277,12 @@ async function main() { const github = await getGitHubInstance(inputs); if (!inputs.skipGitHubRelease) { const manifest = await loadOrBuildManifest(github, inputs); + core.debug('Creating pull requests'); outputReleases(await manifest.createReleases()); } if (!inputs.skipGitHubPullRequest) { const manifest = await loadOrBuildManifest(github, inputs); + core.debug('Creating pull requests'); outputPRs(await manifest.createPullRequests()); } } @@ -116356,6 +116360,11 @@ function outputPRs(prs) { core.setOutput('prs', JSON.stringify(prs)); } } +if (require.main === require.cache[eval('__filename')]) { + main().catch(err => { + core.setFailed(`release-please failed: ${err.message}`); + }); +} })(); diff --git a/src/index.ts b/src/index.ts index 24f1ec9..8f3975b 100644 --- a/src/index.ts +++ b/src/index.ts @@ -107,6 +107,7 @@ function loadOrBuildManifest( inputs: ActionInputs ): Promise { if (inputs.releaseType) { + core.debug('Building manifest from config'); return Manifest.fromConfig( github, github.repository.defaultBranch, @@ -124,6 +125,7 @@ function loadOrBuildManifest( fork: inputs.fork, } : {}; + core.debug('Loading manifest from config file'); return Manifest.fromManifest( github, github.repository.defaultBranch, @@ -139,11 +141,13 @@ export async function main() { if (!inputs.skipGitHubRelease) { const manifest = await loadOrBuildManifest(github, inputs); + core.debug('Creating pull requests'); outputReleases(await manifest.createReleases()); } if (!inputs.skipGitHubPullRequest) { const manifest = await loadOrBuildManifest(github, inputs); + core.debug('Creating pull requests'); outputPRs(await manifest.createPullRequests()); } } @@ -220,3 +224,9 @@ function outputPRs(prs: (PullRequest | undefined)[]) { core.setOutput('prs', JSON.stringify(prs)); } } + +if (require.main === module) { + main().catch(err => { + core.setFailed(`release-please failed: ${err.message}`) + }) +} \ No newline at end of file