Skip to content

Commit b78f480

Browse files
authored
Upgrade @actions/* dependencies (#123)
* Upgrade `@actions/*` dependencies * bumps deps again * add changeset
1 parent ca3c2e0 commit b78f480

File tree

7 files changed

+157
-132
lines changed

7 files changed

+157
-132
lines changed

.changeset/big-scissors-pay.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@changesets/action": patch
3+
---
4+
5+
Updated `@actions/*` dependencies to avoid using deprecated features of the runner.

package.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@
2424
"node": ">= 16"
2525
},
2626
"dependencies": {
27-
"@actions/core": "^1.3.0",
28-
"@actions/exec": "^1.1.0",
29-
"@actions/github": "^4.0.0",
27+
"@actions/core": "^1.10.0",
28+
"@actions/exec": "^1.1.1",
29+
"@actions/github": "^5.1.1",
3030
"@babel/core": "^7.13.10",
3131
"@babel/preset-env": "^7.13.10",
3232
"@babel/preset-typescript": "^7.13.0",

src/gitUtils.ts

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import { exec } from "@actions/exec";
2-
import { execWithOutput } from "./utils";
1+
import { exec, getExecOutput } from "@actions/exec";
32

43
export const setupUser = async () => {
54
await exec("git", [
@@ -35,7 +34,7 @@ export const pushTags = async () => {
3534
};
3635

3736
export const switchToMaybeExistingBranch = async (branch: string) => {
38-
let { stderr } = await execWithOutput("git", ["checkout", branch], {
37+
let { stderr } = await getExecOutput("git", ["checkout", branch], {
3938
ignoreReturnCode: true,
4039
});
4140
let isCreatingBranch = !stderr
@@ -59,6 +58,6 @@ export const commitAll = async (message: string) => {
5958
};
6059

6160
export const checkIfClean = async (): Promise<boolean> => {
62-
const { stdout } = await execWithOutput("git", ["status", "--porcelain"]);
61+
const { stdout } = await getExecOutput("git", ["status", "--porcelain"]);
6362
return !stdout.length;
6463
};

src/run.test.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@ let mockedGithubMethods = {
3030
createRelease: jest.fn(),
3131
},
3232
};
33-
(github.getOctokit as any).mockImplementation(() => mockedGithubMethods);
33+
(github.getOctokit as any).mockImplementation(() => ({
34+
rest: mockedGithubMethods,
35+
}));
3436

3537
let f = fixturez(__dirname);
3638

src/run.ts

+8-9
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { exec } from "@actions/exec";
1+
import { exec, getExecOutput } from "@actions/exec";
22
import * as github from "@actions/github";
33
import fs from "fs-extra";
44
import { getPackages, Package } from "@manypkg/get-packages";
@@ -7,7 +7,6 @@ import * as semver from "semver";
77
import { PreState } from "@changesets/types";
88
import {
99
getChangelogEntry,
10-
execWithOutput,
1110
getChangedPackages,
1211
sortTheThings,
1312
getVersionsByDirectory,
@@ -40,14 +39,14 @@ const createRelease = async (
4039
);
4140
}
4241

43-
await octokit.repos.createRelease({
42+
await octokit.rest.repos.createRelease({
4443
name: tagName,
4544
tag_name: tagName,
4645
body: changelogEntry.content,
4746
prerelease: pkg.packageJson.version.includes("-"),
4847
...github.context.repo,
4948
});
50-
} catch (err: any) {
49+
} catch (err) {
5150
// if we can't find a changelog, the user has probably disabled changelogs
5251
if (err.code !== "ENOENT") {
5352
throw err;
@@ -82,7 +81,7 @@ export async function runPublish({
8281
let octokit = github.getOctokit(githubToken);
8382
let [publishCommand, ...publishArgs] = script.split(/\s+/);
8483

85-
let changesetPublishOutput = await execWithOutput(
84+
let changesetPublishOutput = await getExecOutput(
8685
publishCommand,
8786
publishArgs,
8887
{ cwd }
@@ -165,7 +164,7 @@ export async function runPublish({
165164
const requireChangesetsCliPkgJson = (cwd: string) => {
166165
try {
167166
return require(resolveFrom(cwd, "@changesets/cli/package.json"));
168-
} catch (err: any) {
167+
} catch (err) {
169168
if (err && err.code === "MODULE_NOT_FOUND") {
170169
throw new Error(
171170
`Have you forgotten to install \`@changesets/cli\` in "${cwd}"?`
@@ -292,7 +291,7 @@ export async function runVersion({
292291
}
293292

294293
let searchQuery = `repo:${repo}+state:open+head:${versionBranch}+base:${branch}+is:pull-request`;
295-
let searchResultPromise = octokit.search.issuesAndPullRequests({
294+
let searchResultPromise = octokit.rest.search.issuesAndPullRequests({
296295
q: searchQuery,
297296
});
298297
let changedPackages = await getChangedPackages(cwd, versionsByDirectory);
@@ -342,7 +341,7 @@ export async function runVersion({
342341

343342
if (searchResult.data.items.length === 0) {
344343
console.log("creating pull request");
345-
const { data: newPullRequest } = await octokit.pulls.create({
344+
const { data: newPullRequest } = await octokit.rest.pulls.create({
346345
base: branch,
347346
head: versionBranch,
348347
title: finalPrTitle,
@@ -357,7 +356,7 @@ export async function runVersion({
357356
const [pullRequest] = searchResult.data.items;
358357

359358
console.log(`updating found pull request #${pullRequest.number}`);
360-
await octokit.pulls.update({
359+
await octokit.rest.pulls.update({
361360
pull_number: pullRequest.number,
362361
title: finalPrTitle,
363362
body: prBody,

src/utils.ts

-26
Original file line numberDiff line numberDiff line change
@@ -87,32 +87,6 @@ export function getChangelogEntry(changelog: string, version: string) {
8787
};
8888
}
8989

90-
export async function execWithOutput(
91-
command: string,
92-
args?: string[],
93-
options?: { ignoreReturnCode?: boolean; cwd?: string }
94-
) {
95-
let myOutput = "";
96-
let myError = "";
97-
98-
return {
99-
code: await exec(command, args, {
100-
listeners: {
101-
stdout: (data: Buffer) => {
102-
myOutput += data.toString();
103-
},
104-
stderr: (data: Buffer) => {
105-
myError += data.toString();
106-
},
107-
},
108-
109-
...options,
110-
}),
111-
stdout: myOutput,
112-
stderr: myError,
113-
};
114-
}
115-
11690
export function sortTheThings(
11791
a: { private: boolean; highestLevel: number },
11892
b: { private: boolean; highestLevel: number }

0 commit comments

Comments
 (0)