From c01a16b879af26283a780d9951d1360cebd3a123 Mon Sep 17 00:00:00 2001 From: WickyNilliams Date: Fri, 31 Oct 2025 10:04:39 +0000 Subject: [PATCH 1/2] add support for rewrite and ext options --- __tests__/main.test.ts | 21 +++++++++++++++++++++ action.yml | 7 +++++++ lib/main.js | 4 ++++ lib/options.js | 9 ++++++++- src/main.ts | 4 ++++ src/options.ts | 9 +++++++++ 6 files changed, 53 insertions(+), 1 deletion(-) diff --git a/__tests__/main.test.ts b/__tests__/main.test.ts index 13a1260a..acf19059 100644 --- a/__tests__/main.test.ts +++ b/__tests__/main.test.ts @@ -10,6 +10,7 @@ import { getSetCommitsOption, getProjects, getUrlPrefixOption, + getExtOption, } from '../src/options'; describe('options', () => { @@ -209,6 +210,26 @@ describe('options', () => { expect(getUrlPrefixOption()).toEqual('build'); }); }); + + describe('getExtOption', () => { + afterEach(() => { + delete process.env['INPUT_EXT']; + }); + + test('should return undefined when ext is omitted', () => { + expect(getExtOption()).toBeUndefined(); + }); + + test('should return array when ext is provided', () => { + process.env['INPUT_EXT'] = 'js map'; + expect(getExtOption()).toEqual(['js', 'map']); + }); + + test('should filter out empty strings', () => { + process.env['INPUT_EXT'] = 'js map'; + expect(getExtOption()).toEqual(['js', 'map']); + }); + }); }); // shows how the runner will run a javascript action with env / stdout protocol diff --git a/action.yml b/action.yml index be04ced5..1b04cac0 100644 --- a/action.yml +++ b/action.yml @@ -41,6 +41,13 @@ inputs: strip_common_prefix: description: 'Will remove a common prefix from uploaded filenames. Useful for removing a path that is build-machine-specific.' required: false + rewrite: + description: 'Enables rewriting of matching sourcemaps so that indexed maps are flattened and missing sources are inlined if possible. Defaults to true.' + required: false + default: true + ext: + description: 'Space-separated list of file extensions to be considered for source map upload. By default: js, map, jsbundle, bundle.' + required: false working_directory: description: 'Directory to collect sentry release information from. Useful when collecting information from a non-standard checkout directory.' required: false diff --git a/lib/main.js b/lib/main.js index f3324fe9..63d9dd51 100644 --- a/lib/main.js +++ b/lib/main.js @@ -48,6 +48,8 @@ const process = __importStar(require("process")); const projects = options.getProjects(); const urlPrefix = options.getUrlPrefixOption(); const stripCommonPrefix = options.getBooleanOption('strip_common_prefix', false); + const rewrite = options.getBooleanOption('rewrite', true); + const ext = options.getExtOption(); const version = yield options.getVersion(); const workingDirectory = options.getWorkingDirectory(); core.debug(`Version is ${version}`); @@ -75,6 +77,8 @@ const process = __importStar(require("process")); dist, urlPrefix, stripCommonPrefix, + rewrite, + ext, }; return cli.uploadSourceMaps(version, sourceMapOptions); }))); diff --git a/lib/options.js b/lib/options.js index ec8e1536..e75cbb5e 100644 --- a/lib/options.js +++ b/lib/options.js @@ -28,7 +28,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge }); }; Object.defineProperty(exports, "__esModule", { value: true }); -exports.getWorkingDirectory = exports.getUrlPrefixOption = exports.getProjects = exports.checkEnvironmentVariables = exports.getSetCommitsOption = exports.getBooleanOption = exports.getDist = exports.getSourcemaps = exports.getStartedAt = exports.getEnvironment = exports.getVersion = void 0; +exports.getExtOption = exports.getWorkingDirectory = exports.getUrlPrefixOption = exports.getProjects = exports.checkEnvironmentVariables = exports.getSetCommitsOption = exports.getBooleanOption = exports.getDist = exports.getSourcemaps = exports.getStartedAt = exports.getEnvironment = exports.getVersion = void 0; const core = __importStar(require("@actions/core")); const cli_1 = require("./cli"); /** @@ -182,3 +182,10 @@ exports.getUrlPrefixOption = () => { exports.getWorkingDirectory = () => { return core.getInput('working_directory'); }; +exports.getExtOption = () => { + const extOption = core.getInput('ext'); + if (!extOption) { + return undefined; + } + return extOption.split(' ').filter(ext => ext.length > 0); +}; diff --git a/src/main.ts b/src/main.ts index e716dd69..f24bd832 100644 --- a/src/main.ts +++ b/src/main.ts @@ -24,6 +24,8 @@ import * as process from 'process'; 'strip_common_prefix', false ); + const rewrite = options.getBooleanOption('rewrite', true); + const ext = options.getExtOption(); const version = await options.getVersion(); const workingDirectory = options.getWorkingDirectory(); @@ -56,6 +58,8 @@ import * as process from 'process'; dist, urlPrefix, stripCommonPrefix, + rewrite, + ext, }; return cli.uploadSourceMaps(version, sourceMapOptions); }) diff --git a/src/options.ts b/src/options.ts index b2901de5..b97df9af 100644 --- a/src/options.ts +++ b/src/options.ts @@ -182,3 +182,12 @@ export const getUrlPrefixOption = (): string => { export const getWorkingDirectory = (): string => { return core.getInput('working_directory'); }; + +export const getExtOption = (): string[] | undefined => { + const extOption: string = core.getInput('ext'); + if (!extOption) { + return undefined; + } + + return extOption.split(' ').filter(ext => ext.length > 0); +}; From 3bf6900fafe9b45a3663751f583daabb6a5f206e Mon Sep 17 00:00:00 2001 From: WickyNilliams Date: Fri, 7 Nov 2025 09:40:51 +0000 Subject: [PATCH 2/2] update readme --- README.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/README.md b/README.md index 866a338d..14a55681 100644 --- a/README.md +++ b/README.md @@ -75,6 +75,8 @@ Adding the following to your workflow will create a new Sentry release and tell |`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.|-| |`strip_common_prefix`|Will remove a common prefix from uploaded filenames. Useful for removing a path that is build-machine-specific.|`false`| +|`rewrite`|Enables rewriting of matching sourcemaps so that indexed maps are flattened and missing sources are inlined if possible.|`true`| +|`ext`|Space-separated list of file extensions to be considered for source map upload. By default: js, map, jsbundle, bundle.|-| |`working_directory`|Directory to collect sentry release information from. Useful when collecting information from a non-standard checkout directory.|-| ### Examples @@ -88,6 +90,18 @@ Adding the following to your workflow will create a new Sentry release and tell sourcemaps: './lib' ``` +- Upload source maps with custom file extensions and disable rewriting. + + ```yaml + - uses: getsentry/action-release@v1 + with: + environment: 'production' + sourcemaps: './build' + url_prefix: '~/' + rewrite: false + ext: 'js map' + ``` + - Create a new Sentry release for the `production` environment of your project at version `v1.0.1`. ```yaml