Compare commits

..
1 Commits
Author SHA1 Message Date
github-actions[bot] 62a9eee638 v1.4.2 2023-05-06 09:21:28 +00:00
5 changed files with 22 additions and 29 deletions
-6
View File
@@ -1,11 +1,5 @@
# @changesets/action # @changesets/action
## 1.4.3
### Patch Changes
- [#289](https://github.com/changesets/action/pull/289) [`8b28186`](https://github.com/changesets/action/commit/8b2818674de86a7fc69aebb9ed6b486ee32eb96e) Thanks [@varl](https://github.com/varl)! - Use logging provided by `@actions/core`
## 1.4.2 ## 1.4.2
### Patch Changes ### Patch Changes
+3 -3
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.4.3", "version": "1.4.2",
"main": "dist/index.js", "main": "dist/index.js",
"license": "MIT", "license": "MIT",
"devDependencies": { "devDependencies": {
+11 -11
View File
@@ -16,18 +16,18 @@ const getOptionalInput = (name: string) => core.getInput(name) || undefined;
const inputCwd = core.getInput("cwd"); const inputCwd = core.getInput("cwd");
if (inputCwd) { if (inputCwd) {
core.info("changing directory to the one given as the input"); console.log("changing directory to the one given as the input");
process.chdir(inputCwd); process.chdir(inputCwd);
} }
let setupGitUser = core.getBooleanInput("setupGitUser"); let setupGitUser = core.getBooleanInput("setupGitUser");
if (setupGitUser) { if (setupGitUser) {
core.info("setting git user"); console.log("setting git user");
await gitUtils.setupUser(); await gitUtils.setupUser();
} }
core.info("setting GitHub credentials"); console.log("setting GitHub credentials");
await fs.writeFile( await fs.writeFile(
`${process.env.HOME}/.netrc`, `${process.env.HOME}/.netrc`,
`machine github.com\nlogin github-actions[bot]\npassword ${githubToken}` `machine github.com\nlogin github-actions[bot]\npassword ${githubToken}`
@@ -48,27 +48,27 @@ const getOptionalInput = (name: string) => core.getInput(name) || undefined;
switch (true) { switch (true) {
case !hasChangesets && !hasPublishScript: case !hasChangesets && !hasPublishScript:
core.info("No changesets found"); console.log("No changesets found");
return; return;
case !hasChangesets && hasPublishScript: { case !hasChangesets && hasPublishScript: {
core.info( console.log(
"No changesets found, attempting to publish any unpublished packages to npm" "No changesets found, attempting to publish any unpublished packages to npm"
); );
let userNpmrcPath = `${process.env.HOME}/.npmrc`; let userNpmrcPath = `${process.env.HOME}/.npmrc`;
if (fs.existsSync(userNpmrcPath)) { if (fs.existsSync(userNpmrcPath)) {
core.info("Found existing user .npmrc file"); console.log("Found existing user .npmrc file");
const userNpmrcContent = await fs.readFile(userNpmrcPath, "utf8"); const userNpmrcContent = await fs.readFile(userNpmrcPath, "utf8");
const authLine = userNpmrcContent.split("\n").find((line) => { const authLine = userNpmrcContent.split("\n").find((line) => {
// check based on https://github.com/npm/cli/blob/8f8f71e4dd5ee66b3b17888faad5a7bf6c657eed/test/lib/adduser.js#L103-L105 // check based on https://github.com/npm/cli/blob/8f8f71e4dd5ee66b3b17888faad5a7bf6c657eed/test/lib/adduser.js#L103-L105
return /^\s*\/\/registry\.npmjs\.org\/:[_-]authToken=/i.test(line); return /^\s*\/\/registry\.npmjs\.org\/:[_-]authToken=/i.test(line);
}); });
if (authLine) { if (authLine) {
core.info( console.log(
"Found existing auth token for the npm registry in the user .npmrc file" "Found existing auth token for the npm registry in the user .npmrc file"
); );
} else { } else {
core.info( console.log(
"Didn't find existing auth token for the npm registry in the user .npmrc file, creating one" "Didn't find existing auth token for the npm registry in the user .npmrc file, creating one"
); );
fs.appendFileSync( fs.appendFileSync(
@@ -77,7 +77,7 @@ const getOptionalInput = (name: string) => core.getInput(name) || undefined;
); );
} }
} else { } else {
core.info("No user .npmrc file found, creating one"); console.log("No user .npmrc file found, creating one");
fs.writeFileSync( fs.writeFileSync(
userNpmrcPath, userNpmrcPath,
`//registry.npmjs.org/:_authToken=${process.env.NPM_TOKEN}\n` `//registry.npmjs.org/:_authToken=${process.env.NPM_TOKEN}\n`
@@ -100,7 +100,7 @@ const getOptionalInput = (name: string) => core.getInput(name) || undefined;
return; return;
} }
case hasChangesets && !hasNonEmptyChangesets: case hasChangesets && !hasNonEmptyChangesets:
core.info("All changesets are empty; not creating PR"); console.log("All changesets are empty; not creating PR");
return; return;
case hasChangesets: case hasChangesets:
const { pullRequestNumber } = await runVersion({ const { pullRequestNumber } = await runVersion({
@@ -116,6 +116,6 @@ const getOptionalInput = (name: string) => core.getInput(name) || undefined;
return; return;
} }
})().catch((err) => { })().catch((err) => {
core.error(err); console.error(err);
core.setFailed(err.message); core.setFailed(err.message);
}); });
+7 -8
View File
@@ -1,7 +1,6 @@
import { exec, getExecOutput } from "@actions/exec"; import { exec, getExecOutput } from "@actions/exec";
import { GitHub, getOctokitOptions } from "@actions/github/lib/utils"; import { GitHub, getOctokitOptions } from "@actions/github/lib/utils";
import * as github from "@actions/github"; import * as github from "@actions/github";
import * as core from "@actions/core";
import fs from "fs-extra"; import fs from "fs-extra";
import { getPackages, Package } from "@manypkg/get-packages"; import { getPackages, Package } from "@manypkg/get-packages";
import path from "path"; import path from "path";
@@ -87,12 +86,12 @@ export async function runPublish({
getOctokitOptions(githubToken, { getOctokitOptions(githubToken, {
throttle: { throttle: {
onRateLimit: (retryAfter, options: any, octokit, retryCount) => { onRateLimit: (retryAfter, options: any, octokit, retryCount) => {
core.warning( console.log(
`Request quota exhausted for request ${options.method} ${options.url}` `Request quota exhausted for request ${options.method} ${options.url}`
); );
if (retryCount <= 2) { if (retryCount <= 2) {
core.info(`Retrying after ${retryAfter} seconds!`); console.log(`Retrying after ${retryAfter} seconds!`);
return true; return true;
} }
}, },
@@ -102,12 +101,12 @@ export async function runPublish({
octokit, octokit,
retryCount retryCount
) => { ) => {
core.warning( console.log(
`SecondaryRateLimit detected for request ${options.method} ${options.url}` `SecondaryRateLimit detected for request ${options.method} ${options.url}`
); );
if (retryCount <= 2) { if (retryCount <= 2) {
core.info(`Retrying after ${retryAfter} seconds!`); console.log(`Retrying after ${retryAfter} seconds!`);
return true; return true;
} }
}, },
@@ -361,7 +360,7 @@ export async function runVersion({
await gitUtils.push(versionBranch, { force: true }); await gitUtils.push(versionBranch, { force: true });
let searchResult = await searchResultPromise; let searchResult = await searchResultPromise;
core.info(JSON.stringify(searchResult.data, null, 2)); console.log(JSON.stringify(searchResult.data, null, 2));
const changedPackagesInfo = (await changedPackagesInfoPromises) const changedPackagesInfo = (await changedPackagesInfoPromises)
.filter((x) => x) .filter((x) => x)
@@ -376,7 +375,7 @@ export async function runVersion({
}); });
if (searchResult.data.items.length === 0) { if (searchResult.data.items.length === 0) {
core.info("creating pull request"); console.log("creating pull request");
const { data: newPullRequest } = await octokit.rest.pulls.create({ const { data: newPullRequest } = await octokit.rest.pulls.create({
base: branch, base: branch,
head: versionBranch, head: versionBranch,
@@ -391,7 +390,7 @@ export async function runVersion({
} else { } else {
const [pullRequest] = searchResult.data.items; const [pullRequest] = searchResult.data.items;
core.info(`updating found pull request #${pullRequest.number}`); console.log(`updating found pull request #${pullRequest.number}`);
await octokit.rest.pulls.update({ await octokit.rest.pulls.update({
pull_number: pullRequest.number, pull_number: pullRequest.number,
title: finalPrTitle, title: finalPrTitle,