From 250b34ea716a03ec32c439ac3a877aa103103c59 Mon Sep 17 00:00:00 2001 From: Stephen Cefali Date: Mon, 16 Nov 2020 13:02:28 -0800 Subject: [PATCH] feat: url prefix for source maps (#33) --- README.md | 2 ++ __tests__/main.test.ts | 10 ++++++++++ package.json | 2 +- src/main.ts | 4 +++- src/validate.ts | 4 ++++ 5 files changed, 20 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 7266358..828e577 100644 --- a/README.md +++ b/README.md @@ -53,6 +53,8 @@ The following are all _required_. |`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".|-| |`set_commits`|Specify whether to set commits for the release. Either "auto" or "skip".|"auto"| +|`projects`|Space-separated list of paths of projects. When omitted, falls back to the environment variable `SENTRY_PROJECT` to determine the project.|-| +|`url_prefix`|Adds a prefix to source map urls after stripping them.|-| ### Examples - Create a new Sentry release for the `production` environment and upload JavaScript source maps from the `./lib` directory. diff --git a/__tests__/main.test.ts b/__tests__/main.test.ts index 4b08a40..6fa196f 100644 --- a/__tests__/main.test.ts +++ b/__tests__/main.test.ts @@ -8,6 +8,7 @@ import { getVersion, getSetCommitsOption, getProjects, + getUrlPrefixOption, } from '../src/validate'; describe('validate', () => { @@ -160,6 +161,15 @@ describe('validate', () => { ); }); }); + describe('getUrlPrefixOption', () => { + afterEach(() => { + delete process.env['URL_PREFIX']; + }); + it('get url prefix', () => { + process.env['INPUT_URL_PREFIX'] = 'build'; + expect(getUrlPrefixOption()).toEqual('build'); + }) + }) }); // shows how the runner will run a javascript action with env / stdout protocol diff --git a/package.json b/package.json index 282dddc..875da64 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "action-release", - "version": "1.1.2", + "version": "1.1.3", "private": true, "description": "GitHub Action for creating a release on Sentry", "main": "dist/index.js", diff --git a/src/main.ts b/src/main.ts index 7f6301a..d05ade2 100644 --- a/src/main.ts +++ b/src/main.ts @@ -14,6 +14,7 @@ import * as validate from './validate'; const deployStartedAtOption = validate.getStartedAt(); const setCommitsOption = validate.getSetCommitsOption(); const projects = validate.getProjects(); + const urlPrefix = validate.getUrlPrefixOption(); const version = await validate.getVersion(); @@ -25,7 +26,7 @@ import * as validate from './validate'; await cli.setCommits(version, {auto: true}); } - if (sourcemaps) { + if (sourcemaps.length) { core.debug(`Adding sourcemaps`); await Promise.all( projects.map(async project => { @@ -34,6 +35,7 @@ import * as validate from './validate'; const sourceMapOptions = { include: sourcemaps, projects: localProjects, + urlPrefix, }; return cli.uploadSourceMaps(version, sourceMapOptions); }) diff --git a/src/validate.ts b/src/validate.ts index 3b8e492..2371be2 100644 --- a/src/validate.ts +++ b/src/validate.ts @@ -155,3 +155,7 @@ export const getProjects = (): string[] => { } return [project]; }; + +export const getUrlPrefixOption = (): string => { + return core.getInput('url_prefix'); +} \ No newline at end of file