diff --git a/README.md b/README.md index 77fbee6a..75257c60 100644 --- a/README.md +++ b/README.md @@ -62,6 +62,7 @@ Adding the following to your workflow will create a new Sentry release and tell |`ignore_missing`|When the flag is set and the previous release commit was not found in the repository, will create a release with the default commits count instead of failing the command.|`false`| |`ignore_empty`|When the flag is set, command will not fail and just exit silently if no new commits for a given release have been found.|`false`| |`sourcemaps`|Space-separated list of paths to JavaScript sourcemaps. Omit to skip uploading sourcemaps.|-| +|`dist`|Unique identifier for the distribution, used to further segment your release. Usually your build number. _Note: Required when uploading sourcemaps._|-| |`started_at`|Unix timestamp of the release start date. Omit for current time.|-| |`version`|Identifier that uniquely identifies the releases. _Note: the `refs/tags/` prefix is automatically stripped when `version` is `github.ref`._|${{ github.sha }}| |`version_prefix`|Value prepended to auto-generated version. For example "v".|-| @@ -80,6 +81,7 @@ Adding the following to your workflow will create a new Sentry release and tell with: environment: 'production' sourcemaps: './lib' + dist: ${{ github.sha }} ``` - Create a new Sentry release for the `production` environment of your project at version `v1.0.1`. diff --git a/__tests__/main.test.ts b/__tests__/main.test.ts index f573e80c..daf0fe89 100644 --- a/__tests__/main.test.ts +++ b/__tests__/main.test.ts @@ -3,6 +3,7 @@ import * as path from 'path'; import * as process from 'process'; import { getBooleanOption, + getDist, getSourcemaps, getStartedAt, getVersion, @@ -66,6 +67,21 @@ describe('options', () => { }); }); + describe('getDist', () => { + afterEach(() => { + delete process.env['INPUT_DIST']; + }); + + test('should return null when dist is omitted', async () => { + expect(getDist()).toBeNull(); + }); + + test('should return a string when dist is provided', () => { + process.env['INPUT_DIST'] = 'foo-dist'; + expect(getDist()).toEqual('foo-dist'); + }); + }); + describe('getStartedAt', () => { const errorMessage = 'started_at not in valid format. Unix timestamp or ISO 8601 date expected'; diff --git a/action.yml b/action.yml index 72fd500e..89bbe57e 100644 --- a/action.yml +++ b/action.yml @@ -8,6 +8,9 @@ inputs: sourcemaps: description: 'Space-separated list of paths to JavaScript sourcemaps. Omit to skip uploading sourcemaps.' required: false + dist: + description: 'Unique identifier for the distribution, used to further segment your release. Usually your build number.' + required: false finalize: description: 'When false, omit marking the release as finalized and released.' default: true diff --git a/src/main.ts b/src/main.ts index b4a94397..e716dd69 100644 --- a/src/main.ts +++ b/src/main.ts @@ -12,6 +12,7 @@ import * as process from 'process'; const environment = options.getEnvironment(); const sourcemaps = options.getSourcemaps(); + const dist = options.getDist(); const shouldFinalize = options.getBooleanOption('finalize', true); const ignoreMissing = options.getBooleanOption('ignore_missing', false); const ignoreEmpty = options.getBooleanOption('ignore_empty', false); @@ -52,6 +53,7 @@ import * as process from 'process'; const sourceMapOptions = { include: sourcemaps, projects: localProjects, + dist, urlPrefix, stripCommonPrefix, }; diff --git a/src/options.ts b/src/options.ts index 80e62aba..bcec4e55 100644 --- a/src/options.ts +++ b/src/options.ts @@ -81,6 +81,19 @@ export const getSourcemaps = (): string[] => { return sourcemapsOption.split(' '); }; +/** + * Dist is optional, but should be a string when provided. + * @returns string + */ +export const getDist = (): string | null => { + const distOption: string = core.getInput('dist'); + if (!distOption) { + return null; + } + + return distOption; +}; + /** * Fetch boolean option from input. Throws error if option value is not a boolean. * @param input string