Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
21 changes: 21 additions & 0 deletions __tests__/main.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
getSetCommitsOption,
getProjects,
getUrlPrefixOption,
getExtOption,
} from '../src/options';

describe('options', () => {
Expand Down Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}`);
Expand Down Expand Up @@ -75,6 +77,8 @@ const process = __importStar(require("process"));
dist,
urlPrefix,
stripCommonPrefix,
rewrite,
ext,
};
return cli.uploadSourceMaps(version, sourceMapOptions);
})));
Expand Down
9 changes: 8 additions & 1 deletion lib/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -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");
/**
Expand Down Expand Up @@ -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);
};
4 changes: 4 additions & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down Expand Up @@ -56,6 +58,8 @@ import * as process from 'process';
dist,
urlPrefix,
stripCommonPrefix,
rewrite,
ext,
};
return cli.uploadSourceMaps(version, sourceMapOptions);
})
Expand Down
9 changes: 9 additions & 0 deletions src/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
};