From 64a8f595b0aae7bb27501a790706e3a6344b5ccd Mon Sep 17 00:00:00 2001 From: Marcos Gaeta Date: Mon, 20 Jul 2020 14:31:37 -0700 Subject: [PATCH 1/3] Strip ref from version --- src/validate.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/validate.ts b/src/validate.ts index 4d8ab41..3b5f473 100644 --- a/src/validate.ts +++ b/src/validate.ts @@ -9,7 +9,8 @@ import {getCLI} from './cli'; export const getVersion = async (): Promise => { const versionOption: string = core.getInput('version'); if (versionOption) { - return versionOption; + // If the users passes in `${{github.ref}}, then it will have an unwanted prefix. + return versionOption.replace(/^(refs\/tags\/)/, ''); } core.debug('Version not provided, proposing one...'); From 41fce50a4b698561680ba123c753b31f8badbd50 Mon Sep 17 00:00:00 2001 From: Marcos Gaeta Date: Mon, 20 Jul 2020 14:39:56 -0700 Subject: [PATCH 2/3] Test getVersion --- __tests__/main.test.ts | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/__tests__/main.test.ts b/__tests__/main.test.ts index f27a278..e09eee6 100644 --- a/__tests__/main.test.ts +++ b/__tests__/main.test.ts @@ -1,7 +1,12 @@ import {execSync} from 'child_process'; import * as path from 'path'; import * as process from 'process'; -import {getShouldFinalize, getSourcemaps, getStartedAt} from '../src/validate' +import { + getShouldFinalize, + getSourcemaps, + getStartedAt, + getVersion, +} from '../src/validate' describe('validate', () => { describe('getShouldFinalize', () => { @@ -75,6 +80,26 @@ describe('validate', () => { expect(getStartedAt()).toEqual(1500000000); }); }); + + describe('getVersion', () => { + afterEach(() => { + delete process.env['INPUT_VERSION']; + }); + + test('should strip refs from version', async () => { + process.env['INPUT_VERSION'] = 'refs/tags/v1.0.0'; + expect(getVersion()).toBe('v1.0.0') + }); + + test('should get version from inputs', async () => { + process.env['INPUT_VERSION'] = 'v1.0.0'; + expect(getVersion()).toBe('v1.0.0') + }); + + test('should propose-version when version is omitted', async () => { + expect(getVersion()).toBe('propose-version') + }); + }); }); // shows how the runner will run a javascript action with env / stdout protocol From 72d20f2bc2458ccb3a88b4f2daa667df8f199ff5 Mon Sep 17 00:00:00 2001 From: Marcos Gaeta Date: Fri, 11 Sep 2020 14:45:27 -0700 Subject: [PATCH 3/3] Update readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index ff9c659..695cbf4 100644 --- a/README.md +++ b/README.md @@ -50,7 +50,7 @@ The following are all _required_. |`finalize`|When false, omit marking the release as finalized and released.|`true`| |`sourcemaps`|Space-separated list of paths to JavaScript sourcemaps. Omit to skip uploading sourcemaps.|-| |`started_at`|Unix timestamp of the release start date. Omit for current time.|-| -|`version`|Identifier that uniquely identifies the releases.|${{ github.sha }}| +|`version`|Identifier that uniquely identifies the releases. _Note: the `refs/tags/` prefix is automatically stripped when `version` is `github.ref`._|${{ github.sha }}| ### Examples - Create a new Sentry release for the `production` environment and upload JavaScript source maps from the `./lib` directory.