Merge pull request #10 from getsentry/feat/strip-ref
This commit is contained in:
@@ -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.|<code>${{ github.sha }}</code>|
|
||||
|`version`|Identifier that uniquely identifies the releases. _Note: the `refs/tags/` prefix is automatically stripped when `version` is `github.ref`._|<code>${{ github.sha }}</code>|
|
||||
|
||||
### Examples
|
||||
- Create a new Sentry release for the `production` environment and upload JavaScript source maps from the `./lib` directory.
|
||||
|
||||
+26
-1
@@ -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
|
||||
|
||||
+2
-1
@@ -9,7 +9,8 @@ import {getCLI} from './cli';
|
||||
export const getVersion = async (): Promise<string> => {
|
||||
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...');
|
||||
|
||||
Reference in New Issue
Block a user