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
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ inputs:
description: 'The version to release as.'
required: false
default: ''
include-commit-authors:
description: 'If true, include commit authors in changelog entries (e.g., @username or author name).'
required: false
default: false
runs:
using: 'node20'
main: 'dist/index.js'
12 changes: 11 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ interface ActionInputs {
changelogHost: string;
versioningStrategy?: string;
releaseAs?: string;
includeCommitAuthors?: boolean;
}

function parseInputs(): ActionInputs {
Expand All @@ -69,6 +70,7 @@ function parseInputs(): ActionInputs {
changelogHost: core.getInput('changelog-host') || DEFAULT_GITHUB_SERVER_URL,
versioningStrategy: getOptionalInput('versioning-strategy'),
releaseAs: getOptionalInput('release-as'),
includeCommitAuthors: getOptionalBooleanInput('include-commit-authors'),
};
return inputs;
}
Expand Down Expand Up @@ -100,7 +102,8 @@ function loadOrBuildManifest(
changelogHost: inputs.changelogHost,
versioning: inputs.versioningStrategy,
releaseAs: inputs.releaseAs,
},
includeCommitAuthors: inputs.includeCommitAuthors,
} as any,
{
fork: inputs.fork,
skipLabeling: inputs.skipLabeling,
Expand Down Expand Up @@ -129,6 +132,13 @@ function loadOrBuildManifest(
manifest.repositoryConfig[path].changelogHost = inputs.changelogHost;
}
}
// Override includeCommitAuthors for all paths if provided as action input
if (inputs.includeCommitAuthors !== undefined) {
core.debug(`Overriding includeCommitAuthors to: ${inputs.includeCommitAuthors}`);
for (const path in manifest.repositoryConfig) {
(manifest.repositoryConfig[path] as any).includeCommitAuthors = inputs.includeCommitAuthors;
}
}
return manifest;
});
}
Expand Down
74 changes: 74 additions & 0 deletions test/release-please.ts
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,30 @@ describe('release-please-action', () => {
sinon.match.any,
);
});

it('allows specifying include-commit-authors', async () => {
restoreEnv = mockInputs({
'release-type': 'simple',
'include-commit-authors': 'true',
});
fakeManifest.createReleases.resolves([]);
fakeManifest.createPullRequests.resolves([]);
await action.main(fetch);
sinon.assert.calledOnce(fakeManifest.createReleases);
sinon.assert.calledOnce(fakeManifest.createPullRequests);

sinon.assert.calledWith(
fromConfigStub,
sinon.match.any,
sinon.match.string,
sinon.match({
releaseType: 'simple',
includeCommitAuthors: true,
}),
sinon.match.object,
sinon.match.any,
);
});
});

describe('with manifest', () => {
Expand Down Expand Up @@ -364,6 +388,56 @@ describe('release-please-action', () => {
assert.strictEqual(fakeManifest.repositoryConfig['.'].changelogHost, undefined);
assert.strictEqual(fakeManifest.repositoryConfig['packages/foo'].changelogHost, undefined);
});
it('modifies repositoryConfig with include-commit-authors', async () => {
restoreEnv = mockInputs({
'include-commit-authors': 'true',
});

// Create a mock repositoryConfig on the existing fakeManifest
const mockRepositoryConfig = {
'.': { releaseType: 'node' },
'packages/foo': { releaseType: 'node' }
};
// Use Object.defineProperty to set the readonly property
Object.defineProperty(fakeManifest, 'repositoryConfig', {
value: mockRepositoryConfig,
writable: true,
configurable: true
});
fakeManifest.createReleases.resolves([]);
fakeManifest.createPullRequests.resolves([]);

await action.main(fetch);

// Verify that includeCommitAuthors was added to all paths in repositoryConfig
assert.strictEqual((fakeManifest.repositoryConfig['.'] as any).includeCommitAuthors, true);
assert.strictEqual((fakeManifest.repositoryConfig['packages/foo'] as any).includeCommitAuthors, true);
});
it('modifies repositoryConfig with include-commit-authors set to false', async () => {
restoreEnv = mockInputs({
'include-commit-authors': 'false',
});

// Create a mock repositoryConfig on the existing fakeManifest
const mockRepositoryConfig = {
'.': { releaseType: 'node', includeCommitAuthors: true },
'packages/foo': { releaseType: 'node', includeCommitAuthors: true }
};
// Use Object.defineProperty to set the readonly property
Object.defineProperty(fakeManifest, 'repositoryConfig', {
value: mockRepositoryConfig,
writable: true,
configurable: true
});
fakeManifest.createReleases.resolves([]);
fakeManifest.createPullRequests.resolves([]);

await action.main(fetch);

// Verify that includeCommitAuthors was set to false for all paths
assert.strictEqual((fakeManifest.repositoryConfig['.'] as any).includeCommitAuthors, false);
assert.strictEqual((fakeManifest.repositoryConfig['packages/foo'] as any).includeCommitAuthors, false);
});
});

it('allows specifying manifest config paths', async () => {
Expand Down
Loading