From 50bc76c8801582fa7dcde888c3d8893ad37d4b7f Mon Sep 17 00:00:00 2001 From: Trevor White Date: Mon, 23 Jun 2025 07:58:02 -0700 Subject: [PATCH 1/5] Add support for "manual" in set-commits --- action.yml | 9 ++++++++- src/main.ts | 13 ++++++++++++- src/options.ts | 21 +++++++++++++++++++-- 3 files changed, 39 insertions(+), 4 deletions(-) diff --git a/action.yml b/action.yml index 573331e2..fb8ffa61 100644 --- a/action.yml +++ b/action.yml @@ -76,7 +76,12 @@ inputs: set_commits: description: |- Specify whether to set commits for the release. - One of: "auto", "skip" + One of: "auto", "skip", "manual" + required: false + commit_range: + description: |- + If set commits equals manual, include a comma separated list of repo,current commit,previous commit. + Example: octocat/my-repo,ae1d1cd5d658e784dcfdff36afe93f75b764cb82,7711b5c927410659df736751ec8124469f87e233 required: false projects: description: |- @@ -142,6 +147,7 @@ runs: INPUT_VERSION_PREFIX: ${{ inputs.version_prefix }} INPUT_RELEASE_PREFIX: ${{ inputs.release_prefix }} INPUT_SET_COMMITS: ${{ inputs.set_commits }} + INPUT_COMMIT_RANGE: ${{ inputs.commit_range }} INPUT_PROJECTS: ${{ inputs.projects }} INPUT_URL_PREFIX: ${{ inputs.url_prefix }} INPUT_STRIP_COMMON_PREFIX: ${{ inputs.strip_common_prefix }} @@ -204,6 +210,7 @@ runs: INPUT_VERSION_PREFIX: ${{ inputs.version_prefix }} INPUT_RELEASE_PREFIX: ${{ inputs.release_prefix }} INPUT_SET_COMMITS: ${{ inputs.set_commits }} + INPUT_COMMIT_RANGE: ${{ inputs.commit_range }} INPUT_PROJECTS: ${{ inputs.projects }} INPUT_URL_PREFIX: ${{ inputs.url_prefix }} INPUT_STRIP_COMMON_PREFIX: ${{ inputs.strip_common_prefix }} diff --git a/src/main.ts b/src/main.ts index daff77ce..a0daf76e 100644 --- a/src/main.ts +++ b/src/main.ts @@ -31,6 +31,7 @@ withTelemetry( const ignoreEmpty = options.getBooleanOption('ignore_empty', false); const deployStartedAtOption = options.getStartedAt(); const setCommitsOption = options.getSetCommitsOption(); + const commitRange = options.getCommitRange(); const projects = options.getProjects(); const urlPrefix = options.getUrlPrefixOption(); const stripCommonPrefix = options.getBooleanOption('strip_common_prefix', false); @@ -47,7 +48,17 @@ withTelemetry( Sentry.setTag('set-commits', setCommitsOption); - if (setCommitsOption !== 'skip') { + if (setCommitsOption === 'manual') { + await traceStep('set-commits', async () => { + core.debug(`Setting commits with option '${setCommitsOption}'`); + await getCLI().setCommits(release, { + auto: false, + repo: commitRange.get('repo'), + commit: commitRange.get('currentCommit'), + previousCommit: commitRange.get('previousCommit'), + }); + }); + } else if (setCommitsOption !== 'skip') { await traceStep('set-commits', async () => { core.debug(`Setting commits with option '${setCommitsOption}'`); await getCLI().setCommits(release, { diff --git a/src/options.ts b/src/options.ts index a1afad80..a44e5967 100644 --- a/src/options.ts +++ b/src/options.ts @@ -127,7 +127,7 @@ export const getBooleanOption = (input: string, defaultValue: boolean): boolean throw Error(`${input} is not a boolean`); }; -export const getSetCommitsOption = (): 'auto' | 'skip' => { +export const getSetCommitsOption = (): 'auto' | 'skip' | 'manual' => { let setCommitOption = core.getInput('set_commits'); // default to auto if (!setCommitOption) { @@ -138,13 +138,30 @@ export const getSetCommitsOption = (): 'auto' | 'skip' => { switch (setCommitOption) { case 'auto': return 'auto'; + case 'manual': + return 'manual'; case 'skip': return 'skip'; default: - throw Error('set_commits must be "auto" or "skip"'); + throw Error('set_commits must be "auto" or "skip" or "manual"'); } }; +export const getCommitRange = (): Map => { + const commitRange = core.getInput('commit_range'); + + // Split the input by a common comma delimiter + const [repo, currentCommit, previousCommit] = commitRange.split(','); + + // Create a map and update with the provided values + const commitRangeDetails = new Map(); + commitRangeDetails.set('repo', repo.trim()); + commitRangeDetails.set('currentCommit', currentCommit.trim()); + commitRangeDetails.set('previousCommit', previousCommit.trim()); + + return commitRangeDetails; +}; + /** * Check for required environment variables. */ From 80e299a9b42d10b1679284b4ad6c22a6dedb6497 Mon Sep 17 00:00:00 2001 From: Trevor White Date: Mon, 23 Jun 2025 08:39:02 -0700 Subject: [PATCH 2/5] Run yarn commands --- action.yml | 2 +- dist/index.js | 32 +++++++++++++++++++++++++++++--- 2 files changed, 30 insertions(+), 4 deletions(-) diff --git a/action.yml b/action.yml index fb8ffa61..ea08b604 100644 --- a/action.yml +++ b/action.yml @@ -154,7 +154,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 diff --git a/dist/index.js b/dist/index.js index c1b31187..34689fee 100644 --- a/dist/index.js +++ b/dist/index.js @@ -122736,6 +122736,7 @@ const telemetry_1 = __nccwpck_require__(12417); const ignoreEmpty = options.getBooleanOption('ignore_empty', false); const deployStartedAtOption = options.getStartedAt(); const setCommitsOption = options.getSetCommitsOption(); + const commitRange = options.getCommitRange(); const projects = options.getProjects(); const urlPrefix = options.getUrlPrefixOption(); const stripCommonPrefix = options.getBooleanOption('strip_common_prefix', false); @@ -122749,7 +122750,18 @@ 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') { + if (setCommitsOption === 'manual') { + 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, { + auto: false, + repo: commitRange.get('repo'), + commit: commitRange.get('currentCommit'), + previousCommit: commitRange.get('previousCommit'), + }); + })); + } + else if (setCommitsOption !== '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, { @@ -122860,7 +122872,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; 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.getRelease = void 0; +exports.getWorkingDirectory = exports.getUrlPrefixOption = exports.getProjects = exports.checkEnvironmentVariables = exports.getCommitRange = exports.getSetCommitsOption = exports.getBooleanOption = exports.getDist = exports.getSourcemaps = exports.getStartedAt = exports.getEnvironment = exports.getRelease = void 0; const core = __importStar(__nccwpck_require__(42186)); const path_1 = __importDefault(__nccwpck_require__(71017)); const cli_1 = __nccwpck_require__(56733); @@ -122991,13 +123003,27 @@ const getSetCommitsOption = () => { switch (setCommitOption) { case 'auto': return 'auto'; + case 'manual': + return 'manual'; case 'skip': return 'skip'; default: - throw Error('set_commits must be "auto" or "skip"'); + throw Error('set_commits must be "auto" or "skip" or "manual"'); } }; exports.getSetCommitsOption = getSetCommitsOption; +const getCommitRange = () => { + const commitRange = core.getInput('commit_range'); + // Split the input by a common comma delimiter + const [repo, currentCommit, previousCommit] = commitRange.split(','); + // Create a map and update with the provided values + const commitRangeDetails = new Map(); + commitRangeDetails.set('repo', repo.trim()); + commitRangeDetails.set('currentCommit', currentCommit.trim()); + commitRangeDetails.set('previousCommit', previousCommit.trim()); + return commitRangeDetails; +}; +exports.getCommitRange = getCommitRange; /** * Check for required environment variables. */ From 078a11b3844a514d9b3fe2f6e355ec5c275c192e Mon Sep 17 00:00:00 2001 From: Trevor White Date: Tue, 24 Jun 2025 20:53:59 -0700 Subject: [PATCH 3/5] Update the API per PR conversations --- action.yml | 7 +---- src/main.ts | 16 ++++++------ src/options.ts | 69 ++++++++++++++++++++++++++++++++------------------ 3 files changed, 53 insertions(+), 39 deletions(-) diff --git a/action.yml b/action.yml index ea08b604..797c1bbd 100644 --- a/action.yml +++ b/action.yml @@ -76,12 +76,7 @@ inputs: set_commits: description: |- Specify whether to set commits for the release. - One of: "auto", "skip", "manual" - required: false - commit_range: - description: |- - If set commits equals manual, include a comma separated list of repo,current commit,previous commit. - Example: octocat/my-repo,ae1d1cd5d658e784dcfdff36afe93f75b764cb82,7711b5c927410659df736751ec8124469f87e233 + One of: "auto", "skip", "repo-owner/repo-name@commit", "repo-owner/repo-name@.." required: false projects: description: |- diff --git a/src/main.ts b/src/main.ts index a0daf76e..c9c313e8 100644 --- a/src/main.ts +++ b/src/main.ts @@ -31,7 +31,6 @@ withTelemetry( const ignoreEmpty = options.getBooleanOption('ignore_empty', false); const deployStartedAtOption = options.getStartedAt(); const setCommitsOption = options.getSetCommitsOption(); - const commitRange = options.getCommitRange(); const projects = options.getProjects(); const urlPrefix = options.getUrlPrefixOption(); const stripCommonPrefix = options.getBooleanOption('strip_common_prefix', false); @@ -46,19 +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 === 'manual') { + if (setCommitsOption.get('mode') === 'manual') { await traceStep('set-commits', async () => { - core.debug(`Setting commits with option '${setCommitsOption}'`); + core.debug(`Setting commits with options '${setCommitsOption}'`); + const previousCommit = setCommitsOption.get('previous_commit'); await getCLI().setCommits(release, { auto: false, - repo: commitRange.get('repo'), - commit: commitRange.get('currentCommit'), - previousCommit: commitRange.get('previousCommit'), + repo: setCommitsOption.get('repo'), + commit: setCommitsOption.get('commit'), + ...(previousCommit && { previousCommit }), }); }); - } else if (setCommitsOption !== 'skip') { + } else if (setCommitsOption.get('mode') !== 'skip') { await traceStep('set-commits', async () => { core.debug(`Setting commits with option '${setCommitsOption}'`); await getCLI().setCommits(release, { diff --git a/src/options.ts b/src/options.ts index a44e5967..3b09783d 100644 --- a/src/options.ts +++ b/src/options.ts @@ -127,39 +127,58 @@ export const getBooleanOption = (input: string, defaultValue: boolean): boolean throw Error(`${input} is not a boolean`); }; -export const getSetCommitsOption = (): 'auto' | 'skip' | 'manual' => { +export const getSetCommitsOption = (): Map => { 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'; - case 'manual': - return 'manual'; + result.set('mode', 'auto'); + break; case 'skip': - return 'skip'; - default: - throw Error('set_commits must be "auto" or "skip" or "manual"'); - } -}; - -export const getCommitRange = (): Map => { - const commitRange = core.getInput('commit_range'); - - // Split the input by a common comma delimiter - const [repo, currentCommit, previousCommit] = commitRange.split(','); + 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@..".' + ); + } - // Create a map and update with the provided values - const commitRangeDetails = new Map(); - commitRangeDetails.set('repo', repo.trim()); - commitRangeDetails.set('currentCommit', currentCommit.trim()); - commitRangeDetails.set('previousCommit', previousCommit.trim()); + // 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 commitRangeDetails; + return result; }; /** From fa244bbe496327acf5ed165130c96576666dcec4 Mon Sep 17 00:00:00 2001 From: Trevor White Date: Tue, 24 Jun 2025 20:56:27 -0700 Subject: [PATCH 4/5] Remove input_commit_range --- action.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/action.yml b/action.yml index 797c1bbd..8ced9857 100644 --- a/action.yml +++ b/action.yml @@ -142,7 +142,6 @@ runs: INPUT_VERSION_PREFIX: ${{ inputs.version_prefix }} INPUT_RELEASE_PREFIX: ${{ inputs.release_prefix }} INPUT_SET_COMMITS: ${{ inputs.set_commits }} - INPUT_COMMIT_RANGE: ${{ inputs.commit_range }} INPUT_PROJECTS: ${{ inputs.projects }} INPUT_URL_PREFIX: ${{ inputs.url_prefix }} INPUT_STRIP_COMMON_PREFIX: ${{ inputs.strip_common_prefix }} @@ -205,7 +204,6 @@ runs: INPUT_VERSION_PREFIX: ${{ inputs.version_prefix }} INPUT_RELEASE_PREFIX: ${{ inputs.release_prefix }} INPUT_SET_COMMITS: ${{ inputs.set_commits }} - INPUT_COMMIT_RANGE: ${{ inputs.commit_range }} INPUT_PROJECTS: ${{ inputs.projects }} INPUT_URL_PREFIX: ${{ inputs.url_prefix }} INPUT_STRIP_COMMON_PREFIX: ${{ inputs.strip_common_prefix }} From e3743dfd2bf7afdf0f6ff36e1af9f47b96054497 Mon Sep 17 00:00:00 2001 From: Trevor White Date: Tue, 24 Jun 2025 20:58:19 -0700 Subject: [PATCH 5/5] Add yarn-build changes --- dist/index.js | 76 ++++++++++++++++++++++++++++----------------------- 1 file changed, 42 insertions(+), 34 deletions(-) diff --git a/dist/index.js b/dist/index.js index 34689fee..f701504d 100644 --- a/dist/index.js +++ b/dist/index.js @@ -122736,7 +122736,6 @@ const telemetry_1 = __nccwpck_require__(12417); const ignoreEmpty = options.getBooleanOption('ignore_empty', false); const deployStartedAtOption = options.getStartedAt(); const setCommitsOption = options.getSetCommitsOption(); - const commitRange = options.getCommitRange(); const projects = options.getProjects(); const urlPrefix = options.getUrlPrefixOption(); const stripCommonPrefix = options.getBooleanOption('strip_common_prefix', false); @@ -122749,19 +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 === 'manual') { + 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 option '${setCommitsOption}'`); - yield (0, cli_1.getCLI)().setCommits(release, { - auto: false, - repo: commitRange.get('repo'), - commit: commitRange.get('currentCommit'), - previousCommit: commitRange.get('previousCommit'), - }); + 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 !== 'skip') { + 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, { @@ -122872,7 +122867,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.getWorkingDirectory = exports.getUrlPrefixOption = exports.getProjects = exports.checkEnvironmentVariables = exports.getCommitRange = exports.getSetCommitsOption = exports.getBooleanOption = exports.getDist = exports.getSourcemaps = exports.getStartedAt = exports.getEnvironment = exports.getRelease = void 0; +exports.getWorkingDirectory = exports.getUrlPrefixOption = exports.getProjects = exports.checkEnvironmentVariables = exports.getSetCommitsOption = exports.getBooleanOption = exports.getDist = exports.getSourcemaps = exports.getStartedAt = exports.getEnvironment = exports.getRelease = void 0; const core = __importStar(__nccwpck_require__(42186)); const path_1 = __importDefault(__nccwpck_require__(71017)); const cli_1 = __nccwpck_require__(56733); @@ -122994,36 +122989,49 @@ 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'; - case 'manual': - return 'manual'; + result.set('mode', 'auto'); + break; case 'skip': - return 'skip'; - default: - throw Error('set_commits must be "auto" or "skip" or "manual"'); + 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@..".'); + } + // 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; -const getCommitRange = () => { - const commitRange = core.getInput('commit_range'); - // Split the input by a common comma delimiter - const [repo, currentCommit, previousCommit] = commitRange.split(','); - // Create a map and update with the provided values - const commitRangeDetails = new Map(); - commitRangeDetails.set('repo', repo.trim()); - commitRangeDetails.set('currentCommit', currentCommit.trim()); - commitRangeDetails.set('previousCommit', previousCommit.trim()); - return commitRangeDetails; -}; -exports.getCommitRange = getCommitRange; /** * Check for required environment variables. */