Skip to content

Commit

Permalink
feat: adds support for a debug input in the release action
Browse files Browse the repository at this point in the history
  • Loading branch information
Toolo committed Sep 28, 2023
1 parent 2287ead commit 3e04599
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions semantic-release/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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` | |
Expand Down
4 changes: 4 additions & 0 deletions semantic-release/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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 }}
3 changes: 3 additions & 0 deletions semantic-release/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ const OUTPUTS = {
interface Inputs {
branches?: string;
ci: boolean;
debug: boolean;
dryRun: boolean;
extraPlugins: string[];
semanticVersion?: string;
Expand Down Expand Up @@ -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, " ")
Expand Down Expand Up @@ -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),
),
Expand Down
4 changes: 4 additions & 0 deletions semantic-release/test/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -102,6 +103,7 @@ describe("semantic-release", () => {
expect(semanticReleaseMock.mock.calls[0][0]).toMatchInlineSnapshot(`
{
"ci": false,
"debug": false,
"dryRun": false,
}
`);
Expand Down Expand Up @@ -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 });
Expand All @@ -159,6 +162,7 @@ describe("semantic-release", () => {
{
"branches": "test",
"ci": true,
"debug": true,
"dryRun": true,
}
`);
Expand Down

0 comments on commit 3e04599

Please sign in to comment.