Skip to content
Merged
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
39 changes: 39 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,8 @@ jobs:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
runs-on: ${{ matrix.os }}
permissions:
contents: read
name: Test current action
steps:
- uses: actions/checkout@v4
Expand All @@ -160,6 +162,8 @@ jobs:
test-runs-on-container:
needs: docker-build
runs-on: ubuntu-latest
permissions:
contents: read
container:
image: node:20.19.2

Expand All @@ -183,6 +187,8 @@ jobs:
os: [ubuntu-latest, windows-latest, macos-latest]
runs-on: ${{ matrix.os }}
name: Mock a release
permissions:
contents: read
steps:
- uses: actions/checkout@v4
with:
Expand All @@ -202,6 +208,8 @@ jobs:
os: [ubuntu-latest, windows-latest, macos-latest]
runs-on: ${{ matrix.os }}
name: Mock a release in a different working directory
permissions:
contents: read
steps:
- name: Checkout directory we'll be running from
uses: actions/checkout@v4
Expand Down Expand Up @@ -231,6 +239,8 @@ jobs:
node-version: ['20.x', '22.x']
runs-on: ${{ matrix.os }}
name: Test Node version preserved on ${{ matrix.os }} with Node ${{ matrix.node-version }}
permissions:
contents: read
steps:
- uses: actions/checkout@v4
with:
Expand Down Expand Up @@ -266,4 +276,33 @@ jobs:
echo "ERROR: Node version changed from ${{ steps.node_before.outputs.VERSION }} to $VERSION_AFTER"
exit 1
fi

echo "SUCCESS: Node version preserved"

test-manual-commit-range:
needs: docker-build

strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
runs-on: ${{ matrix.os }}
name: Test manual commit range
permissions:
contents: read
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Create a release with manual commit range
uses: ./
env:
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
SENTRY_LOG_LEVEL: debug
MOCK: true
with:
environment: production
set_commits: manual
repo: getsentry/action-release
commit: ${{ github.sha }}
previous_commit: ${{ github.sha }}
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
# Changelog

## 3.4.0

- feat: Add support for setting manual commit range (#291) by @andreiborza

Work in this release was contributed by @trevorkwhite. Thank you for your contribution!

## 3.3.0

### Various fixes & improvements

- chore: pin cache action (#290) by @saibotk
- chore: Set docker tag for master [skip ci] (ae1d1cd5) by @getsantry[bot]

Work in this release was contributed by @saibotk. Thank you for your contribution!

## 3.2.0

### Various fixes & improvements
Expand Down
158 changes: 85 additions & 73 deletions README.md

Large diffs are not rendered by default.

27 changes: 26 additions & 1 deletion __tests__/main.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
getProjects,
getUrlPrefixOption,
getWorkingDirectory,
getSetCommitsManualOptions,
} from '../src/options';

describe('options', () => {
Expand Down Expand Up @@ -196,13 +197,37 @@ describe('options', () => {
process.env['INPUT_SET_COMMITS'] = 'skip';
expect(getSetCommitsOption()).toBe('skip');
});
it('manual', () => {
process.env['INPUT_SET_COMMITS'] = 'manual';
expect(getSetCommitsOption()).toBe('manual');
});
it('bad option', () => {
const errorMessage = 'set_commits must be "auto" or "skip"';
const errorMessage = 'set_commits must be "auto", "skip" or "manual"';
process.env['INPUT_SET_COMMITS'] = 'bad';
expect(() => getSetCommitsOption()).toThrow(errorMessage);
});
});

describe('getSetCommitsManualOptions', () => {
afterEach(() => {
delete process.env['INPUT_SET_COMMITS'];
delete process.env['INPUT_REPO'];
delete process.env['INPUT_COMMIT'];
delete process.env['INPUT_PREVIOUS_COMMIT'];
});
it('manual', () => {
process.env['INPUT_SET_COMMITS'] = 'manual';
process.env['INPUT_REPO'] = 'repo';
process.env['INPUT_COMMIT'] = 'commit';
process.env['INPUT_PREVIOUS_COMMIT'] = 'previous-commit';
expect(getSetCommitsManualOptions()).toEqual({
repo: 'repo',
commit: 'commit',
previousCommit: 'previous-commit',
});
});
});

describe('getProjects', () => {
afterEach(() => {
delete process.env['SENTRY_PROJECT'];
Expand Down
26 changes: 24 additions & 2 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,23 @@ inputs:
set_commits:
description: |-
Specify whether to set commits for the release.
One of: "auto", "skip"
When "manual", you need to provide the repository, commit, and previous commit.
One of: "auto", "skip", "manual"
required: false
repo:
description: |-
The repository to set commits for in "repo-owner/repo-name" format.
Only used when "set_commits" is "manual".
required: false
commit:
description: |-
The commit SHA of the current release you are creating.
Only used when "set_commits" is "manual".
required: false
previous_commit:
description: |-
The commit SHA of the previous release.
Required when "set_commits" is "manual".
required: false
projects:
description: |-
Expand Down Expand Up @@ -142,13 +158,16 @@ runs:
INPUT_VERSION_PREFIX: ${{ inputs.version_prefix }}
INPUT_RELEASE_PREFIX: ${{ inputs.release_prefix }}
INPUT_SET_COMMITS: ${{ inputs.set_commits }}
INPUT_REPO: ${{ inputs.repo }}
INPUT_COMMIT: ${{ inputs.commit }}
INPUT_PREVIOUS_COMMIT: ${{ inputs.previous_commit }}
INPUT_PROJECTS: ${{ inputs.projects }}
INPUT_URL_PREFIX: ${{ inputs.url_prefix }}
INPUT_STRIP_COMMON_PREFIX: ${{ inputs.strip_common_prefix }}
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:ab-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 Expand Up @@ -204,6 +223,9 @@ runs:
INPUT_VERSION_PREFIX: ${{ inputs.version_prefix }}
INPUT_RELEASE_PREFIX: ${{ inputs.release_prefix }}
INPUT_SET_COMMITS: ${{ inputs.set_commits }}
INPUT_REPO: ${{ inputs.repo }}
INPUT_COMMIT: ${{ inputs.commit }}
INPUT_PREVIOUS_COMMIT: ${{ inputs.previous_commit }}
INPUT_PROJECTS: ${{ inputs.projects }}
INPUT_URL_PREFIX: ${{ inputs.url_prefix }}
INPUT_STRIP_COMMON_PREFIX: ${{ inputs.strip_common_prefix }}
Expand Down
33 changes: 26 additions & 7 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -122752,11 +122752,21 @@ const telemetry_1 = __nccwpck_require__(12417);
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, {
auto: true,
ignoreMissing,
ignoreEmpty,
});
if (setCommitsOption === 'auto') {
yield (0, cli_1.getCLI)().setCommits(release, {
auto: true,
ignoreMissing,
ignoreEmpty,
});
}
else if (setCommitsOption === 'manual') {
const { repo, commit, previousCommit } = options.getSetCommitsManualOptions();
if (!repo || !commit) {
throw new Error('Options `repo` and `commit` are required when `set_commits` is `manual`');
}
yield (0, cli_1.getCLI)().setCommits(release, Object.assign({ auto: false, repo,
commit }, (previousCommit && { previousCommit })));
}
}));
}
Sentry.setTag('sourcemaps', sourcemaps.length > 0);
Expand Down Expand Up @@ -122860,7 +122870,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.getSetCommitsManualOptions = 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);
Expand Down Expand Up @@ -122993,11 +123003,20 @@ const getSetCommitsOption = () => {
return 'auto';
case 'skip':
return 'skip';
case 'manual':
return 'manual';
default:
throw Error('set_commits must be "auto" or "skip"');
throw Error('set_commits must be "auto", "skip" or "manual"');
}
};
exports.getSetCommitsOption = getSetCommitsOption;
const getSetCommitsManualOptions = () => {
const repo = core.getInput('repo');
const commit = core.getInput('commit');
const previousCommit = core.getInput('previous_commit');
return { repo, commit, previousCommit };
};
exports.getSetCommitsManualOptions = getSetCommitsManualOptions;
/**
* Check for required environment variables.
*/
Expand Down
26 changes: 21 additions & 5 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,27 @@ withTelemetry(
if (setCommitsOption !== 'skip') {
await traceStep('set-commits', async () => {
core.debug(`Setting commits with option '${setCommitsOption}'`);
await getCLI().setCommits(release, {
auto: true,
ignoreMissing,
ignoreEmpty,
});

if (setCommitsOption === 'auto') {
await getCLI().setCommits(release, {
auto: true,
ignoreMissing,
ignoreEmpty,
});
} else if (setCommitsOption === 'manual') {
const { repo, commit, previousCommit } = options.getSetCommitsManualOptions();

if (!repo || !commit) {
throw new Error('Options `repo` and `commit` are required when `set_commits` is `manual`');
}

await getCLI().setCommits(release, {
auto: false,
repo,
commit,
...(previousCommit && { previousCommit }),
});
}
});
}

Expand Down
13 changes: 11 additions & 2 deletions src/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -140,11 +140,20 @@ export const getSetCommitsOption = (): 'auto' | 'skip' => {
return 'auto';
case 'skip':
return 'skip';
case 'manual':
return 'manual';
default:
throw Error('set_commits must be "auto" or "skip"');
throw Error('set_commits must be "auto", "skip" or "manual"');
}
};

export const getSetCommitsManualOptions = (): { repo: string; commit: string; previousCommit: string } => {
const repo = core.getInput('repo');
const commit = core.getInput('commit');
const previousCommit = core.getInput('previous_commit');

return { repo, commit, previousCommit };
};
/**
* Check for required environment variables.
*/
Expand Down