From 3e045998dee7f29207cb495ad65e3ebef74f4b36 Mon Sep 17 00:00:00 2001 From: Esau Suarez Date: Thu, 28 Sep 2023 14:16:37 +0000 Subject: [PATCH] feat: adds support for a debug input in the release action --- semantic-release/README.md | 1 + semantic-release/action.yaml | 4 ++++ semantic-release/src/index.ts | 3 +++ semantic-release/test/index.test.ts | 4 ++++ 4 files changed, 12 insertions(+) diff --git a/semantic-release/README.md b/semantic-release/README.md index 2efdca7..be5571b 100644 --- a/semantic-release/README.md +++ b/semantic-release/README.md @@ -38,6 +38,7 @@ jobs: | ---------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------- | ----------------------------------------- | | branches | Override the branches where semantic release runs on | `false` | | | ci | Set to false to skip Continuous Integration environment verifications | `false` | | +| debug | Whether to run semantic release in `debug` mode | `false` | | | dry-run | Whether to run semantic release in `dry-run` mode. It will override the dryRun attribute in your configuration file | `false` | | | extra-plugins | Extra plugins for pre-install. You can also specify specifying version range for the extra plugins if you prefer. Defaults to install @open-turo/semantic-release-config. | `false` | @open-turo/semantic-release-config@^1.4.0 | | github-token | GitHub token that can checkout the repository as well as create tags/releases against it. e.g. 'secrets.GITHUB_TOKEN' | `true` | | diff --git a/semantic-release/action.yaml b/semantic-release/action.yaml index 6159751..330e61c 100644 --- a/semantic-release/action.yaml +++ b/semantic-release/action.yaml @@ -15,6 +15,9 @@ inputs: ci: required: false description: "Set to false to skip Continuous Integration environment verifications" + debug: + required: false + description: "Set to true to output debug logs" dry-run: required: false description: "Whether to run semantic release in `dry-run` mode. It will override the dryRun attribute in your configuration file" @@ -67,6 +70,7 @@ runs: env: GITHUB_TOKEN: ${{ inputs.github-token }} SEMANTIC_ACTION_DRY_RUN: ${{ inputs.dry-run }} + SEMANTIC_ACTION_DEBUG: ${{ inputs.debug }} SEMANTIC_ACTION_EXTRA_PLUGINS: ${{ inputs.extra-plugins }} SEMANTIC_ACTION_BRANCHES: ${{ inputs.branches }} SEMANTIC_ACTION_SEMANTIC_VERSION: ${{ inputs.semantic-version }} diff --git a/semantic-release/src/index.ts b/semantic-release/src/index.ts index e39b587..629a5e1 100644 --- a/semantic-release/src/index.ts +++ b/semantic-release/src/index.ts @@ -29,6 +29,7 @@ const OUTPUTS = { interface Inputs { branches?: string; ci: boolean; + debug: boolean; dryRun: boolean; extraPlugins: string[]; semanticVersion?: string; @@ -71,6 +72,7 @@ function getInputs(): Inputs { branches: process.env.SEMANTIC_ACTION_BRANCHES || undefined, ci: process.env.SEMANTIC_ACTION_CI === "true", dryRun: process.env.SEMANTIC_ACTION_DRY_RUN === "true", + debug: process.env.SEMANTIC_ACTION_DEBUG === "true", extraPlugins: (process.env.SEMANTIC_ACTION_EXTRA_PLUGINS || "") .replaceAll(/["']/g, "") .replaceAll(/[\n\r]/g, " ") @@ -118,6 +120,7 @@ export async function main() { Object.entries({ branches: inputs.branches, ci: inputs.ci, + debug: inputs.debug, dryRun: inputs.dryRun, }).filter(([, value]) => value !== undefined && value !== null), ), diff --git a/semantic-release/test/index.test.ts b/semantic-release/test/index.test.ts index a7a5e6b..3c87060 100644 --- a/semantic-release/test/index.test.ts +++ b/semantic-release/test/index.test.ts @@ -77,6 +77,7 @@ describe("semantic-release", () => { jest.resetAllMocks(); delete process.env.SEMANTIC_ACTION_BRANCHES; delete process.env.SEMANTIC_ACTION_CI; + delete process.env.SEMANTIC_ACTION_DEBUG; delete process.env.SEMANTIC_ACTION_DRY_RUN; delete process.env.SEMANTIC_ACTION_EXTRA_PLUGINS; delete process.env.SEMANTIC_ACTION_SEMANTIC_VERSION; @@ -102,6 +103,7 @@ describe("semantic-release", () => { expect(semanticReleaseMock.mock.calls[0][0]).toMatchInlineSnapshot(` { "ci": false, + "debug": false, "dryRun": false, } `); @@ -150,6 +152,7 @@ describe("semantic-release", () => { test("runs semantic release with the extra options", async () => { process.env.SEMANTIC_ACTION_BRANCHES = "test"; process.env.SEMANTIC_ACTION_CI = "true"; + process.env.SEMANTIC_ACTION_DEBUG = "true"; process.env.SEMANTIC_ACTION_DRY_RUN = "true"; mockNpmInstall(); mockRelease({ nextRelease: undefined }); @@ -159,6 +162,7 @@ describe("semantic-release", () => { { "branches": "test", "ci": true, + "debug": true, "dryRun": true, } `);