Skip to content

Commit

Permalink
chore: add option to provide fixed release name and changelog path
Browse files Browse the repository at this point in the history
Signed-off-by: djamailer <[email protected]>
  • Loading branch information
djamaile committed Dec 6, 2023
1 parent b3963c2 commit 63f5dbc
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
9 changes: 9 additions & 0 deletions docs/releases/v[object Object]-changelog.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Release v[object Object]

Upgrade Helper: [https://backstage.github.io/upgrade-helper/?to=[object Object]](https://backstage.github.io/upgrade-helper/?to=[object Object])

## [email protected]

### Minor Changes

- Awesome feature
2 changes: 2 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ const getOptionalInput = (name: string) => core.getInput(name) || undefined;
githubToken,
prTitle: getOptionalInput("title"),
commitMessage: getOptionalInput("commit"),
releaseVersion: getOptionalInput("releaseVersion"),
changelogPath: getOptionalInput("changelogPath"),
hasPublishScript,
});

Expand Down
13 changes: 9 additions & 4 deletions src/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,8 @@ type VersionOptions = {
prTitle?: string;
commitMessage?: string;
hasPublishScript?: boolean;
changelogPath?: string;
releaseVersion?: string;
};

type RunVersionResult = {
Expand All @@ -185,9 +187,11 @@ export async function runVersion({
script,
githubToken,
cwd = process.cwd(),
releaseVersion,
prTitle = "Version Packages",
commitMessage = "Version Packages",
hasPublishScript = false,
changelogPath = "docs/releases",
}: VersionOptions): Promise<RunVersionResult> {
let repo = `${github.context.repo.owner}/${github.context.repo.repo}`;
let branch = github.context.ref.replace("refs/heads/", "");
Expand Down Expand Up @@ -219,7 +223,7 @@ export async function runVersion({
});
let changedPackages = await getChangedPackages(cwd, versionsByDirectory);

const { version: releaseVersion } = await fs.readJson(
releaseVersion = releaseVersion ? releaseVersion : await fs.readJson(
path.resolve(cwd, "package.json")
);

Expand Down Expand Up @@ -252,7 +256,8 @@ ${changelogEntries
.join("\n")}
`;

const changelogPath = `docs/releases/v${releaseVersion}-changelog.md`;
const file = `v${releaseVersion}-changelog.md`;
const fullChangelogPath = `${changelogPath}/${file}`;

try {
const prettier = require(resolveFrom(cwd, "prettier"));
Expand All @@ -263,9 +268,9 @@ ${changelogEntries
});
} catch {}

await fs.writeFile(changelogPath, changelogBody);
await fs.writeFile(fullChangelogPath, changelogBody);

const prBody = `See [${changelogPath}](https://github.com/backstage/backstage/blob/master/${changelogPath}) for more information.`;
const prBody = `See [${fullChangelogPath}](https://github.com/backstage/backstage/blob/master/${fullChangelogPath}) for more information.`;

const finalPrTitle = `${prTitle}${!!preState ? ` (${preState.tag})` : ""}`;

Expand Down

0 comments on commit 63f5dbc

Please sign in to comment.