Compare commits

..
4 Commits
Author SHA1 Message Date
github-actions[bot] cd8d86bdc8 v1.2.0 2022-01-23 13:28:24 +00:00
github-actions[bot]andgithub-actions[bot] e8ffc2d207 Version Packages (#140)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2022-01-23 14:27:10 +01:00
David RegisterandMateusz Burzyński 1ed9bc24b7 Added cwd input option (#134)
* feat: add cwd for projects that not in the root directory

* docs: add cwd to README

* reword the added log

* tweak changeset

Co-authored-by: Mateusz Burzyński <mateuszburzynski@gmail.com>
2022-01-23 14:25:45 +01:00
An PhiandMateusz Burzyński 5c0997b25e Added createGithubReleases input option (defaults to true) to control whether to create Github releases during publish or not (#130)
* allow skipping creation of Github releases

* fixes for PR review

* minor improvements

* add changeset

* nits

Co-authored-by: Mateusz Burzyński <mateuszburzynski@gmail.com>
2022-01-23 11:07:42 +01:00
7 changed files with 45 additions and 16 deletions
+8
View File
@@ -1,5 +1,13 @@
# @changesets/action # @changesets/action
## 1.2.0
### Minor Changes
- [#130](https://github.com/changesets/action/pull/130) [`5c0997b`](https://github.com/changesets/action/commit/5c0997b25e175ecf5e1723ba07210bbcea5d92fb) Thanks [@akphi](https://github.com/akphi)! - Added `createGithubReleases` input option (defaults to `true`) to control whether to create Github releases during publish or not.
* [#134](https://github.com/changesets/action/pull/134) [`1ed9bc2`](https://github.com/changesets/action/commit/1ed9bc24b7a56462c183eb815c8f4bdf0e2e5785) Thanks [@dmregister](https://github.com/dmregister)! - Added `cwd` input option that can be used in projects that are not in the root directory.
## 1.1.0 ## 1.1.0
### Minor Changes ### Minor Changes
+1
View File
@@ -11,6 +11,7 @@ This action for [Changesets](https://github.com/atlassian/changesets) creates a
- commit - The commit message to use. Default to `Version Packages` - commit - The commit message to use. Default to `Version Packages`
- title - The pull request title. Default to `Version Packages` - title - The pull request title. Default to `Version Packages`
- setupGitUser - Sets up the git user for commits as `"github-actions[bot]"`. Default to `true` - setupGitUser - Sets up the git user for commits as `"github-actions[bot]"`. Default to `true`
- cwd - Changes node's `process.cwd()` if the project is not located on the root. Default to `process.cwd()`
### Outputs ### Outputs
+7
View File
@@ -10,6 +10,9 @@ inputs:
version: version:
description: "The command to update version, edit CHANGELOG, read and delete changesets. Default to `changeset version` if not provided" description: "The command to update version, edit CHANGELOG, read and delete changesets. Default to `changeset version` if not provided"
required: false required: false
cwd:
description: Sets the cwd for the node process. Default to `process.cwd()`
required: false
commit: commit:
description: | description: |
The commit message. Default to `Version Packages` The commit message. Default to `Version Packages`
@@ -21,6 +24,10 @@ inputs:
description: Sets up the git user for commits as `"github-actions[bot]"`. Default to `true` description: Sets up the git user for commits as `"github-actions[bot]"`. Default to `true`
required: false required: false
default: true default: true
createGithubReleases:
description: "A boolean value to indicate whether to create Github releases after `publish` or not"
required: false
default: true
outputs: outputs:
published: published:
description: A boolean value to indicate whether a publishing is happened or not description: A boolean value to indicate whether a publishing is happened or not
+2 -2
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "@changesets/action", "name": "@changesets/action",
"version": "1.1.0", "version": "1.2.0",
"main": "dist/index.js", "main": "dist/index.js",
"license": "MIT", "license": "MIT",
"devDependencies": { "devDependencies": {
+8 -1
View File
@@ -14,7 +14,7 @@ const getOptionalInput = (name: string) => core.getInput(name) || undefined;
return; return;
} }
let setupGitUser = core.getBooleanInput('setupGitUser'); let setupGitUser = core.getBooleanInput("setupGitUser");
if (setupGitUser) { if (setupGitUser) {
console.log("setting git user"); console.log("setting git user");
@@ -27,6 +27,12 @@ const getOptionalInput = (name: string) => core.getInput(name) || undefined;
`machine github.com\nlogin github-actions[bot]\npassword ${githubToken}` `machine github.com\nlogin github-actions[bot]\npassword ${githubToken}`
); );
const inputCwd = core.getInput("cwd");
if (inputCwd) {
console.log("changing directory to the one given as the input");
process.chdir(inputCwd);
}
let { changesets } = await readChangesetState(); let { changesets } = await readChangesetState();
let publishScript = core.getInput("publish"); let publishScript = core.getInput("publish");
@@ -78,6 +84,7 @@ const getOptionalInput = (name: string) => core.getInput(name) || undefined;
const result = await runPublish({ const result = await runPublish({
script: publishScript, script: publishScript,
githubToken, githubToken,
createGithubReleases: core.getBooleanInput("createGithubReleases"),
}); });
if (result.published) { if (result.published) {
+18 -12
View File
@@ -51,6 +51,7 @@ const createRelease = async (
type PublishOptions = { type PublishOptions = {
script: string; script: string;
githubToken: string; githubToken: string;
createGithubReleases: boolean;
cwd?: string; cwd?: string;
}; };
@@ -68,6 +69,7 @@ type PublishResult =
export async function runPublish({ export async function runPublish({
script, script,
githubToken, githubToken,
createGithubReleases,
cwd = process.cwd(), cwd = process.cwd(),
}: PublishOptions): Promise<PublishResult> { }: PublishOptions): Promise<PublishResult> {
let octokit = github.getOctokit(githubToken); let octokit = github.getOctokit(githubToken);
@@ -104,14 +106,16 @@ export async function runPublish({
releasedPackages.push(pkg); releasedPackages.push(pkg);
} }
await Promise.all( if (createGithubReleases) {
releasedPackages.map((pkg) => await Promise.all(
createRelease(octokit, { releasedPackages.map((pkg) =>
pkg, createRelease(octokit, {
tagName: `${pkg.packageJson.name}@${pkg.packageJson.version}`, pkg,
}) tagName: `${pkg.packageJson.name}@${pkg.packageJson.version}`,
) })
); )
);
}
} else { } else {
if (packages.length === 0) { if (packages.length === 0) {
throw new Error( throw new Error(
@@ -127,10 +131,12 @@ export async function runPublish({
if (match) { if (match) {
releasedPackages.push(pkg); releasedPackages.push(pkg);
await createRelease(octokit, { if (createGithubReleases) {
pkg, await createRelease(octokit, {
tagName: `v${pkg.packageJson.version}`, pkg,
}); tagName: `v${pkg.packageJson.version}`,
});
}
break; break;
} }
} }