Skip to content

feat: Add ability to manually submit release repo/commits #286

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
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
4 changes: 2 additions & 2 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ inputs:
set_commits:
description: |-
Specify whether to set commits for the release.
One of: "auto", "skip"
One of: "auto", "skip", "repo-owner/repo-name@commit", "repo-owner/repo-name@<commit_of_previous_release>..<commit_of_current_release>"
required: false
projects:
description: |-
Expand Down Expand Up @@ -148,7 +148,7 @@ runs:
INPUT_WORKING_DIRECTORY: ${{ inputs.working_directory }}
INPUT_DISABLE_TELEMETRY: ${{ inputs.disable_telemetry }}
INPUT_DISABLE_SAFE_DIRECTORY: ${{ inputs.disable_safe_directory }}
uses: docker://ghcr.io/getsentry/action-release-image:master
uses: docker://ghcr.io/getsentry/action-release-image:feature-add-manual-commit-range

# For actions running on macos or windows runners, we use a composite
# action approach which allows us to install the arch specific sentry-cli
Expand Down
54 changes: 44 additions & 10 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -122748,8 +122748,15 @@ const telemetry_1 = __nccwpck_require__(12417);
}
core.debug(`Release version is ${release}`);
yield (0, cli_1.getCLI)().new(release, { projects });
Sentry.setTag('set-commits', setCommitsOption);
if (setCommitsOption !== 'skip') {
Sentry.setTag('set-commits', setCommitsOption.get('mode'));
if (setCommitsOption.get('mode') === 'manual') {
yield (0, telemetry_1.traceStep)('set-commits', () => __awaiter(void 0, void 0, void 0, function* () {
core.debug(`Setting commits with options '${setCommitsOption}'`);
const previousCommit = setCommitsOption.get('previous_commit');
yield (0, cli_1.getCLI)().setCommits(release, Object.assign({ auto: false, repo: setCommitsOption.get('repo'), commit: setCommitsOption.get('commit') }, (previousCommit && { previousCommit })));
}));
}
else if (setCommitsOption.get('mode') !== 'skip') {
yield (0, telemetry_1.traceStep)('set-commits', () => __awaiter(void 0, void 0, void 0, function* () {
core.debug(`Setting commits with option '${setCommitsOption}'`);
yield (0, cli_1.getCLI)().setCommits(release, {
Expand Down Expand Up @@ -122982,20 +122989,47 @@ const getBooleanOption = (input, defaultValue) => {
exports.getBooleanOption = getBooleanOption;
const getSetCommitsOption = () => {
let setCommitOption = core.getInput('set_commits');
// default to auto
// Default to "auto" if the input is empty or undefined
if (!setCommitOption) {
return 'auto';
return new Map([['mode', 'auto']]);
}
// convert to lower case
setCommitOption = setCommitOption.toLowerCase();
// Convert input to lower case for uniformity
setCommitOption = setCommitOption.trim().toLowerCase();
// Create a map for the output structure
const result = new Map();
// Handle the different cases for set_commits
switch (setCommitOption) {
case 'auto':
return 'auto';
result.set('mode', 'auto');
break;
case 'skip':
return 'skip';
default:
throw Error('set_commits must be "auto" or "skip"');
result.set('mode', 'skip');
break;
default: {
// Handle repo-owner/repo-name@commit or commit range
const regex = /^([\w\-]+\/[\w\-]+)@([\w\-.]+(?:\.\.|@[\w\-.]+)?)$/;
const match = regex.exec(setCommitOption);
if (!match) {
throw new Error('Invalid value for set_commits. Expected "auto", "skip", or "repo-owner/repo-name@commit" / "repo-owner/repo-name@<commit1>..<commit2>".');
}
// Parse repo and commit(s) from the input
const [, repository, commitRange] = match;
result.set('mode', 'manual');
result.set('repository', repository);
if (commitRange.includes('..')) {
// Handle commit range
const [previousCommit, currentCommit] = commitRange.split('..');
result.set('previous_commit', previousCommit);
result.set('commit', currentCommit);
}
else {
// Single commit
result.set('commit', commitRange);
}
break;
}
}
return result;
};
exports.getSetCommitsOption = getSetCommitsOption;
/**
Expand Down
15 changes: 13 additions & 2 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,20 @@ withTelemetry(
core.debug(`Release version is ${release}`);
await getCLI().new(release, { projects });

Sentry.setTag('set-commits', setCommitsOption);
Sentry.setTag('set-commits', setCommitsOption.get('mode'));

if (setCommitsOption !== 'skip') {
if (setCommitsOption.get('mode') === 'manual') {
await traceStep('set-commits', async () => {
core.debug(`Setting commits with options '${setCommitsOption}'`);
const previousCommit = setCommitsOption.get('previous_commit');
await getCLI().setCommits(release, {
auto: false,
repo: setCommitsOption.get('repo'),
commit: setCommitsOption.get('commit'),
...(previousCommit && { previousCommit }),
});
});
} else if (setCommitsOption.get('mode') !== 'skip') {
await traceStep('set-commits', async () => {
core.debug(`Setting commits with option '${setCommitsOption}'`);
await getCLI().setCommits(release, {
Expand Down
54 changes: 45 additions & 9 deletions src/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,22 +127,58 @@ export const getBooleanOption = (input: string, defaultValue: boolean): boolean
throw Error(`${input} is not a boolean`);
};

export const getSetCommitsOption = (): 'auto' | 'skip' => {
export const getSetCommitsOption = (): Map<string, string> => {
let setCommitOption = core.getInput('set_commits');
// default to auto

// Default to "auto" if the input is empty or undefined
if (!setCommitOption) {
return 'auto';
return new Map([['mode', 'auto']]);
}
// convert to lower case
setCommitOption = setCommitOption.toLowerCase();

// Convert input to lower case for uniformity
setCommitOption = setCommitOption.trim().toLowerCase();

// Create a map for the output structure
const result = new Map<string, string>();

// Handle the different cases for set_commits
switch (setCommitOption) {
case 'auto':
return 'auto';
result.set('mode', 'auto');
break;
case 'skip':
return 'skip';
default:
throw Error('set_commits must be "auto" or "skip"');
result.set('mode', 'skip');
break;
default: {
// Handle repo-owner/repo-name@commit or commit range
const regex = /^([\w\-]+\/[\w\-]+)@([\w\-.]+(?:\.\.|@[\w\-.]+)?)$/;
const match = regex.exec(setCommitOption);

if (!match) {
throw new Error(
'Invalid value for set_commits. Expected "auto", "skip", or "repo-owner/repo-name@commit" / "repo-owner/repo-name@<commit1>..<commit2>".'
);
}

// Parse repo and commit(s) from the input
const [, repository, commitRange] = match;
result.set('mode', 'manual');
result.set('repository', repository);

if (commitRange.includes('..')) {
// Handle commit range
const [previousCommit, currentCommit] = commitRange.split('..');
result.set('previous_commit', previousCommit);
result.set('commit', currentCommit);
} else {
// Single commit
result.set('commit', commitRange);
}
break;
}
}

return result;
};

/**
Expand Down