From 98f8170880b1cf774f15f0dd775adf1364239b2f Mon Sep 17 00:00:00 2001 From: djamailer Date: Wed, 6 Dec 2023 13:36:16 +0100 Subject: [PATCH 1/7] chore: add option to provide fixed release name and changelog path Signed-off-by: djamailer --- src/index.ts | 2 ++ src/run.ts | 13 +++++++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/index.ts b/src/index.ts index 087eccc5..68a953bb 100644 --- a/src/index.ts +++ b/src/index.ts @@ -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, }); diff --git a/src/run.ts b/src/run.ts index 532396b0..6786d9e7 100644 --- a/src/run.ts +++ b/src/run.ts @@ -175,6 +175,8 @@ type VersionOptions = { prTitle?: string; commitMessage?: string; hasPublishScript?: boolean; + changelogPath?: string; + releaseVersion?: string; }; type RunVersionResult = { @@ -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 { let repo = `${github.context.repo.owner}/${github.context.repo.repo}`; let branch = github.context.ref.replace("refs/heads/", ""); @@ -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") ); @@ -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")); @@ -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})` : ""}`; From a54d351a24d07f95183051e3f979ba2bdeb20ae7 Mon Sep 17 00:00:00 2001 From: djamailer Date: Wed, 6 Dec 2023 16:03:42 +0100 Subject: [PATCH 2/7] chore: update snapshot Signed-off-by: djamailer --- src/__snapshots__/run.test.ts.snap | 41 +++--------------------------- 1 file changed, 3 insertions(+), 38 deletions(-) diff --git a/src/__snapshots__/run.test.ts.snap b/src/__snapshots__/run.test.ts.snap index 9ce562c1..de7a724f 100644 --- a/src/__snapshots__/run.test.ts.snap +++ b/src/__snapshots__/run.test.ts.snap @@ -4,26 +4,7 @@ exports[`version creates simple PR 1`] = ` Array [ Object { "base": "some-branch", - "body": "This PR was opened by the [Changesets release](https://github.com/changesets/action) GitHub action. When you're ready to do a release, you can merge this and publish to npm yourself or [setup this action to publish automatically](https://github.com/changesets/action#with-publishing). If you're not ready to do a release yet, that's fine, whenever you add more changesets to some-branch, this PR will be updated. - -# Releases -## simple-project-pkg-a@1.1.0 - -### Minor Changes - -- Awesome feature - -### Patch Changes - -- Updated dependencies - - simple-project-pkg-b@1.1.0 - - ## simple-project-pkg-b@1.1.0 - -### Minor Changes - -- Awesome feature -", + "body": "See [docs/releases/v[object Object]-changelog.md](https://github.com/backstage/backstage/blob/master/docs/releases/v[object Object]-changelog.md) for more information.", "head": "changeset-release/some-branch", "owner": "changesets", "repo": "action", @@ -36,15 +17,7 @@ exports[`version doesn't include ignored package that got a dependency update in Array [ Object { "base": "some-branch", - "body": "This PR was opened by the [Changesets release](https://github.com/changesets/action) GitHub action. When you're ready to do a release, you can merge this and publish to npm yourself or [setup this action to publish automatically](https://github.com/changesets/action#with-publishing). If you're not ready to do a release yet, that's fine, whenever you add more changesets to some-branch, this PR will be updated. - -# Releases -## ignored-package-pkg-b@1.1.0 - -### Minor Changes - -- Awesome feature -", + "body": "See [docs/releases/v[object Object]-changelog.md](https://github.com/backstage/backstage/blob/master/docs/releases/v[object Object]-changelog.md) for more information.", "head": "changeset-release/some-branch", "owner": "changesets", "repo": "action", @@ -57,15 +30,7 @@ exports[`version only includes bumped packages in the PR body 1`] = ` Array [ Object { "base": "some-branch", - "body": "This PR was opened by the [Changesets release](https://github.com/changesets/action) GitHub action. When you're ready to do a release, you can merge this and publish to npm yourself or [setup this action to publish automatically](https://github.com/changesets/action#with-publishing). If you're not ready to do a release yet, that's fine, whenever you add more changesets to some-branch, this PR will be updated. - -# Releases -## simple-project-pkg-a@1.1.0 - -### Minor Changes - -- Awesome feature -", + "body": "See [docs/releases/v[object Object]-changelog.md](https://github.com/backstage/backstage/blob/master/docs/releases/v[object Object]-changelog.md) for more information.", "head": "changeset-release/some-branch", "owner": "changesets", "repo": "action", From 797c690d4741d3d557b25c5e2f37fabcac5f317a Mon Sep 17 00:00:00 2001 From: djamailer Date: Wed, 6 Dec 2023 16:28:50 +0100 Subject: [PATCH 3/7] chore: update action.yml Signed-off-by: djamailer --- action.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/action.yml b/action.yml index c9ca1b68..8de68a0e 100644 --- a/action.yml +++ b/action.yml @@ -28,6 +28,13 @@ inputs: description: "A boolean value to indicate whether to create Github releases after `publish` or not" required: false default: true + releaseVersion: + description: Use this if you want to provide a static release version + required: false + changelogPath: + description: The path of where the changelog file will be created + required: false + default: docs/releases outputs: published: description: A boolean value to indicate whether a publishing is happened or not From 7f45207ffcbee2170fa29d296d77488eb0c7b4cf Mon Sep 17 00:00:00 2001 From: djamailer Date: Wed, 6 Dec 2023 16:39:48 +0100 Subject: [PATCH 4/7] chore: remove default value for changelogPath Signed-off-by: djamailer --- action.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/action.yml b/action.yml index 8de68a0e..794cea5b 100644 --- a/action.yml +++ b/action.yml @@ -34,7 +34,6 @@ inputs: changelogPath: description: The path of where the changelog file will be created required: false - default: docs/releases outputs: published: description: A boolean value to indicate whether a publishing is happened or not From e084421e25cd895ad81bdb5935a70477f36dfc63 Mon Sep 17 00:00:00 2001 From: djamailer Date: Wed, 6 Dec 2023 23:04:07 +0100 Subject: [PATCH 5/7] chore: bump version in package.json Signed-off-by: djamailer --- package.json | 2 +- src/run.ts | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index fa2a1b98..18cf27aa 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@changesets/action", - "version": "2.1.0", + "version": "2.2.0", "main": "dist/index.js", "license": "MIT", "devDependencies": { diff --git a/src/run.ts b/src/run.ts index 6786d9e7..22f88607 100644 --- a/src/run.ts +++ b/src/run.ts @@ -223,9 +223,10 @@ export async function runVersion({ }); let changedPackages = await getChangedPackages(cwd, versionsByDirectory); - releaseVersion = releaseVersion ? releaseVersion : await fs.readJson( + const { version: versionFromPackageJson } = await fs.readJson( path.resolve(cwd, "package.json") ); + const toUseReleaseVersion = releaseVersion || versionFromPackageJson; const changelogEntries = await Promise.all( changedPackages.map(async (pkg) => { @@ -245,9 +246,9 @@ export async function runVersion({ }) ); let changelogBody = ` -# Release v${releaseVersion} +# Release v${toUseReleaseVersion} -Upgrade Helper: [https://backstage.github.io/upgrade-helper/?to=${releaseVersion}](https://backstage.github.io/upgrade-helper/?to=${releaseVersion}) +Upgrade Helper: [https://backstage.github.io/upgrade-helper/?to=${toUseReleaseVersion}](https://backstage.github.io/upgrade-helper/?to=${toUseReleaseVersion}) ${changelogEntries .filter((x) => x) From 6aead9ab53a55ab7481ce25e4c4d003ed3402ed7 Mon Sep 17 00:00:00 2001 From: djamailer Date: Wed, 6 Dec 2023 23:08:42 +0100 Subject: [PATCH 6/7] chore: update snapshot Signed-off-by: djamailer --- docs/releases/vundefined-changelog.md | 9 +++++++++ src/__snapshots__/run.test.ts.snap | 6 +++--- 2 files changed, 12 insertions(+), 3 deletions(-) create mode 100644 docs/releases/vundefined-changelog.md diff --git a/docs/releases/vundefined-changelog.md b/docs/releases/vundefined-changelog.md new file mode 100644 index 00000000..5293af2d --- /dev/null +++ b/docs/releases/vundefined-changelog.md @@ -0,0 +1,9 @@ +# Release v1.0.0 + +Upgrade Helper: [https://backstage.github.io/upgrade-helper/?to=1.0.0](https://backstage.github.io/upgrade-helper/?to=1.0.0) + +## ignored-package-pkg-b@1.1.0 + +### Minor Changes + +- Awesome feature diff --git a/src/__snapshots__/run.test.ts.snap b/src/__snapshots__/run.test.ts.snap index de7a724f..efe6e4f4 100644 --- a/src/__snapshots__/run.test.ts.snap +++ b/src/__snapshots__/run.test.ts.snap @@ -4,7 +4,7 @@ exports[`version creates simple PR 1`] = ` Array [ Object { "base": "some-branch", - "body": "See [docs/releases/v[object Object]-changelog.md](https://github.com/backstage/backstage/blob/master/docs/releases/v[object Object]-changelog.md) for more information.", + "body": "See [docs/releases/vundefined-changelog.md](https://github.com/backstage/backstage/blob/master/docs/releases/vundefined-changelog.md) for more information.", "head": "changeset-release/some-branch", "owner": "changesets", "repo": "action", @@ -17,7 +17,7 @@ exports[`version doesn't include ignored package that got a dependency update in Array [ Object { "base": "some-branch", - "body": "See [docs/releases/v[object Object]-changelog.md](https://github.com/backstage/backstage/blob/master/docs/releases/v[object Object]-changelog.md) for more information.", + "body": "See [docs/releases/vundefined-changelog.md](https://github.com/backstage/backstage/blob/master/docs/releases/vundefined-changelog.md) for more information.", "head": "changeset-release/some-branch", "owner": "changesets", "repo": "action", @@ -30,7 +30,7 @@ exports[`version only includes bumped packages in the PR body 1`] = ` Array [ Object { "base": "some-branch", - "body": "See [docs/releases/v[object Object]-changelog.md](https://github.com/backstage/backstage/blob/master/docs/releases/v[object Object]-changelog.md) for more information.", + "body": "See [docs/releases/vundefined-changelog.md](https://github.com/backstage/backstage/blob/master/docs/releases/vundefined-changelog.md) for more information.", "head": "changeset-release/some-branch", "owner": "changesets", "repo": "action", From a4d8ab3f4155fe4b5d10b9983ad8052d5499b854 Mon Sep 17 00:00:00 2001 From: djamailer Date: Thu, 7 Dec 2023 10:28:33 +0100 Subject: [PATCH 7/7] chore: remove test file Signed-off-by: djamailer --- docs/releases/vundefined-changelog.md | 9 --------- 1 file changed, 9 deletions(-) delete mode 100644 docs/releases/vundefined-changelog.md diff --git a/docs/releases/vundefined-changelog.md b/docs/releases/vundefined-changelog.md deleted file mode 100644 index 5293af2d..00000000 --- a/docs/releases/vundefined-changelog.md +++ /dev/null @@ -1,9 +0,0 @@ -# Release v1.0.0 - -Upgrade Helper: [https://backstage.github.io/upgrade-helper/?to=1.0.0](https://backstage.github.io/upgrade-helper/?to=1.0.0) - -## ignored-package-pkg-b@1.1.0 - -### Minor Changes - -- Awesome feature