Compare commits

..
1 Commits
Author SHA1 Message Date
github-actions[bot] f13b1baaa6 v1.4.5 2023-06-23 10:57:56 +00:00
11 changed files with 56 additions and 97 deletions
+4 -4
View File
@@ -10,12 +10,12 @@ jobs:
steps: steps:
- name: Checkout Repo - name: Checkout Repo
uses: actions/checkout@v4 uses: actions/checkout@v2
- name: Use Node.js 20 - name: Use Node.js 16
uses: actions/setup-node@v4 uses: actions/setup-node@v1
with: with:
node-version: 20.x node-version: 16.x
- name: Install Dependencies - name: Install Dependencies
run: yarn --frozen-lockfile run: yarn --frozen-lockfile
+4 -4
View File
@@ -12,12 +12,12 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout Repo - name: Checkout Repo
uses: actions/checkout@v4 uses: actions/checkout@v2
- name: Use Node.js 20 - name: Use Node.js 16
uses: actions/setup-node@v4 uses: actions/setup-node@v1
with: with:
node-version: 20.x node-version: 16.x
- name: Install Dependencies - name: Install Dependencies
run: yarn --frozen-lockfile run: yarn --frozen-lockfile
-20
View File
@@ -1,25 +1,5 @@
# @changesets/action # @changesets/action
## 1.4.8
### Patch Changes
- [#393](https://github.com/changesets/action/pull/393) [`48ab0d2`](https://github.com/changesets/action/commit/48ab0d2f2e77ae169182d022591ef5c18c931ff2) Thanks [@s0](https://github.com/s0)! - Ensure the PR remains open when updated
- [#393](https://github.com/changesets/action/pull/393) [`48ab0d2`](https://github.com/changesets/action/commit/48ab0d2f2e77ae169182d022591ef5c18c931ff2) Thanks [@s0](https://github.com/s0)! - Switch to cheaper API for querying existing PRs
## 1.4.7
### Patch Changes
- [#255](https://github.com/changesets/action/pull/255) [`f2660aa`](https://github.com/changesets/action/commit/f2660aa7e78365f53dbeb4cfa774c1499ec6483a) Thanks [@ernestognw](https://github.com/ernestognw)! - Allow customize PR `branch` field
## 1.4.6
### Patch Changes
- [#350](https://github.com/changesets/action/pull/350) [`9385be9`](https://github.com/changesets/action/commit/9385be9e757839189ea5ee63ec4e3caa8a6ca71b) Thanks [@m-shaka](https://github.com/m-shaka)! - Bump the used node.js from 16 to 20
## 1.4.5 ## 1.4.5
### Patch Changes ### Patch Changes
+10 -10
View File
@@ -16,7 +16,7 @@ This action for [Changesets](https://github.com/atlassian/changesets) creates a
### Outputs ### Outputs
- published - A boolean value to indicate whether a publishing has happened or not - published - A boolean value to indicate whether a publishing is happened or not
- publishedPackages - A JSON array to present the published packages. The format is `[{"name": "@xx/xx", "version": "1.2.0"}, {"name": "@xx/xy", "version": "0.8.9"}]` - publishedPackages - A JSON array to present the published packages. The format is `[{"name": "@xx/xx", "version": "1.2.0"}, {"name": "@xx/xy", "version": "0.8.9"}]`
### Example workflow: ### Example workflow:
@@ -43,10 +43,10 @@ jobs:
- name: Checkout Repo - name: Checkout Repo
uses: actions/checkout@v3 uses: actions/checkout@v3
- name: Setup Node.js 20 - name: Setup Node.js 16
uses: actions/setup-node@v3 uses: actions/setup-node@v3
with: with:
node-version: 20 node-version: 16
- name: Install Dependencies - name: Install Dependencies
run: yarn run: yarn
@@ -79,10 +79,10 @@ jobs:
- name: Checkout Repo - name: Checkout Repo
uses: actions/checkout@v3 uses: actions/checkout@v3
- name: Setup Node.js 20.x - name: Setup Node.js 16.x
uses: actions/setup-node@v3 uses: actions/setup-node@v3
with: with:
node-version: 20.x node-version: 16.x
- name: Install Dependencies - name: Install Dependencies
run: yarn run: yarn
@@ -124,7 +124,7 @@ For example, you can add a step before running the Changesets GitHub Action:
#### Custom Publishing #### Custom Publishing
If you want to hook into when publishing should occur but have your own publishing functionality, you can utilize the `hasChangesets` output. If you want to hook into when publishing should occur but have your own publishing functionality you can utilize the `hasChangesets` output.
Note that you might need to account for things already being published in your script because a commit without any new changesets can always land on your base branch after a successful publish. In such a case you need to figure out on your own how to skip over the actual publishing logic or handle errors gracefully as most package registries won't allow you to publish over already published version. Note that you might need to account for things already being published in your script because a commit without any new changesets can always land on your base branch after a successful publish. In such a case you need to figure out on your own how to skip over the actual publishing logic or handle errors gracefully as most package registries won't allow you to publish over already published version.
@@ -144,10 +144,10 @@ jobs:
- name: Checkout Repo - name: Checkout Repo
uses: actions/checkout@v3 uses: actions/checkout@v3
- name: Setup Node.js 20.x - name: Setup Node.js 16.x
uses: actions/setup-node@v3 uses: actions/setup-node@v3
with: with:
node-version: 20.x node-version: 16.x
- name: Install Dependencies - name: Install Dependencies
run: yarn run: yarn
@@ -188,10 +188,10 @@ jobs:
- name: Checkout Repo - name: Checkout Repo
uses: actions/checkout@v3 uses: actions/checkout@v3
- name: Setup Node.js 20.x - name: Setup Node.js 16.x
uses: actions/setup-node@v3 uses: actions/setup-node@v3
with: with:
node-version: 20.x node-version: 16.x
- name: Install Dependencies - name: Install Dependencies
run: yarn run: yarn
+1 -4
View File
@@ -1,7 +1,7 @@
name: Changesets name: Changesets
description: A GitHub action to automate releases with Changesets description: A GitHub action to automate releases with Changesets
runs: runs:
using: "node20" using: "node16"
main: "dist/index.js" main: "dist/index.js"
inputs: inputs:
publish: publish:
@@ -28,9 +28,6 @@ inputs:
description: "A boolean value to indicate whether to create Github releases after `publish` or not" description: "A boolean value to indicate whether to create Github releases after `publish` or not"
required: false required: false
default: true default: true
branch:
description: Sets the branch in which the action will run. Default to `github.ref_name` if not provided
required: false
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
+5 -5
View File
File diff suppressed because one or more lines are too long
+5 -5
View File
@@ -1,6 +1,6 @@
{ {
"name": "@changesets/action", "name": "@changesets/action",
"version": "1.4.8", "version": "1.4.5",
"main": "dist/index.js", "main": "dist/index.js",
"license": "MIT", "license": "MIT",
"devDependencies": { "devDependencies": {
@@ -16,8 +16,8 @@
"@babel/preset-typescript": "^7.13.0", "@babel/preset-typescript": "^7.13.0",
"@types/fs-extra": "^8.0.0", "@types/fs-extra": "^8.0.0",
"@types/jest": "^29.5.1", "@types/jest": "^29.5.1",
"@types/node": "^20.11.17", "@types/node": "^12.7.1",
"@types/semver": "^7.5.0", "@types/semver": "^6.0.2",
"babel-jest": "^29.5.0", "babel-jest": "^29.5.0",
"husky": "^3.0.3", "husky": "^3.0.3",
"jest": "^29.5.0" "jest": "^29.5.0"
@@ -31,7 +31,7 @@
"release": "node ./scripts/release.js" "release": "node ./scripts/release.js"
}, },
"engines": { "engines": {
"node": ">= 20" "node": ">= 16"
}, },
"dependencies": { "dependencies": {
"@actions/core": "^1.10.0", "@actions/core": "^1.10.0",
@@ -46,7 +46,7 @@
"remark-parse": "^7.0.1", "remark-parse": "^7.0.1",
"remark-stringify": "^7.0.3", "remark-stringify": "^7.0.3",
"resolve-from": "^5.0.0", "resolve-from": "^5.0.0",
"semver": "^7.5.3", "semver": "^6.3.0",
"unified": "^8.3.2" "unified": "^8.3.2"
}, },
"husky": { "husky": {
-1
View File
@@ -109,7 +109,6 @@ const getOptionalInput = (name: string) => core.getInput(name) || undefined;
prTitle: getOptionalInput("title"), prTitle: getOptionalInput("title"),
commitMessage: getOptionalInput("commit"), commitMessage: getOptionalInput("commit"),
hasPublishScript, hasPublishScript,
branch: getOptionalInput("branch"),
}); });
core.setOutput("pullRequestNumber", String(pullRequestNumber)); core.setOutput("pullRequestNumber", String(pullRequestNumber));
+18 -6
View File
@@ -33,9 +33,11 @@ jest.mock("@actions/github/lib/utils", () => ({
jest.mock("./gitUtils"); jest.mock("./gitUtils");
let mockedGithubMethods = { let mockedGithubMethods = {
search: {
issuesAndPullRequests: jest.fn(),
},
pulls: { pulls: {
create: jest.fn(), create: jest.fn(),
list: jest.fn(),
}, },
repos: { repos: {
createRelease: jest.fn(), createRelease: jest.fn(),
@@ -63,7 +65,9 @@ describe("version", () => {
let cwd = f.copy("simple-project"); let cwd = f.copy("simple-project");
linkNodeModules(cwd); linkNodeModules(cwd);
mockedGithubMethods.pulls.list.mockImplementationOnce(() => ({ data: [] })); mockedGithubMethods.search.issuesAndPullRequests.mockImplementationOnce(
() => ({ data: { items: [] } })
);
mockedGithubMethods.pulls.create.mockImplementationOnce(() => ({ mockedGithubMethods.pulls.create.mockImplementationOnce(() => ({
data: { number: 123 }, data: { number: 123 },
@@ -100,7 +104,9 @@ describe("version", () => {
let cwd = f.copy("simple-project"); let cwd = f.copy("simple-project");
linkNodeModules(cwd); linkNodeModules(cwd);
mockedGithubMethods.pulls.list.mockImplementationOnce(() => ({ data: [] })); mockedGithubMethods.search.issuesAndPullRequests.mockImplementationOnce(
() => ({ data: { items: [] } })
);
mockedGithubMethods.pulls.create.mockImplementationOnce(() => ({ mockedGithubMethods.pulls.create.mockImplementationOnce(() => ({
data: { number: 123 }, data: { number: 123 },
@@ -133,7 +139,9 @@ describe("version", () => {
let cwd = f.copy("ignored-package"); let cwd = f.copy("ignored-package");
linkNodeModules(cwd); linkNodeModules(cwd);
mockedGithubMethods.pulls.list.mockImplementationOnce(() => ({ data: [] })); mockedGithubMethods.search.issuesAndPullRequests.mockImplementationOnce(
() => ({ data: { items: [] } })
);
mockedGithubMethods.pulls.create.mockImplementationOnce(() => ({ mockedGithubMethods.pulls.create.mockImplementationOnce(() => ({
data: { number: 123 }, data: { number: 123 },
@@ -166,7 +174,9 @@ describe("version", () => {
let cwd = f.copy("simple-project"); let cwd = f.copy("simple-project");
linkNodeModules(cwd); linkNodeModules(cwd);
mockedGithubMethods.pulls.list.mockImplementationOnce(() => ({ data: [] })); mockedGithubMethods.search.issuesAndPullRequests.mockImplementationOnce(
() => ({ data: { items: [] } })
);
mockedGithubMethods.pulls.create.mockImplementationOnce(() => ({ mockedGithubMethods.pulls.create.mockImplementationOnce(() => ({
data: { number: 123 }, data: { number: 123 },
@@ -223,7 +233,9 @@ fluminis divesque vulnere aquis parce lapsis rabie si visa fulmineis.
let cwd = f.copy("simple-project"); let cwd = f.copy("simple-project");
linkNodeModules(cwd); linkNodeModules(cwd);
mockedGithubMethods.pulls.list.mockImplementationOnce(() => ({ data: [] })); mockedGithubMethods.search.issuesAndPullRequests.mockImplementationOnce(
() => ({ data: { items: [] } })
);
mockedGithubMethods.pulls.create.mockImplementationOnce(() => ({ mockedGithubMethods.pulls.create.mockImplementationOnce(() => ({
data: { number: 123 }, data: { number: 123 },
+8 -13
View File
@@ -299,7 +299,6 @@ type VersionOptions = {
commitMessage?: string; commitMessage?: string;
hasPublishScript?: boolean; hasPublishScript?: boolean;
prBodyMaxCharacters?: number; prBodyMaxCharacters?: number;
branch?: string;
}; };
type RunVersionResult = { type RunVersionResult = {
@@ -314,12 +313,11 @@ export async function runVersion({
commitMessage = "Version Packages", commitMessage = "Version Packages",
hasPublishScript = false, hasPublishScript = false,
prBodyMaxCharacters = MAX_CHARACTERS_PER_MESSAGE, prBodyMaxCharacters = MAX_CHARACTERS_PER_MESSAGE,
branch,
}: VersionOptions): Promise<RunVersionResult> { }: VersionOptions): Promise<RunVersionResult> {
const octokit = setupOctokit(githubToken); const octokit = setupOctokit(githubToken);
let repo = `${github.context.repo.owner}/${github.context.repo.repo}`; let repo = `${github.context.repo.owner}/${github.context.repo.repo}`;
branch = branch ?? github.context.ref.replace("refs/heads/", ""); let branch = github.context.ref.replace("refs/heads/", "");
let versionBranch = `changeset-release/${branch}`; let versionBranch = `changeset-release/${branch}`;
let { preState } = await readChangesetState(cwd); let { preState } = await readChangesetState(cwd);
@@ -342,11 +340,9 @@ export async function runVersion({
}); });
} }
const existingPullRequestsPromise = octokit.rest.pulls.list({ let searchQuery = `repo:${repo}+state:open+head:${versionBranch}+base:${branch}+is:pull-request`;
...github.context.repo, let searchResultPromise = octokit.rest.search.issuesAndPullRequests({
state: "open", q: searchQuery,
head: `${github.context.repo.owner}:${versionBranch}`,
base: branch,
}); });
let changedPackages = await getChangedPackages(cwd, versionsByDirectory); let changedPackages = await getChangedPackages(cwd, versionsByDirectory);
let changedPackagesInfoPromises = Promise.all( let changedPackagesInfoPromises = Promise.all(
@@ -378,8 +374,8 @@ export async function runVersion({
await gitUtils.push(versionBranch, { force: true }); await gitUtils.push(versionBranch, { force: true });
let existingPullRequests = await existingPullRequestsPromise; let searchResult = await searchResultPromise;
core.info(JSON.stringify(existingPullRequests.data, null, 2)); core.info(JSON.stringify(searchResult.data, null, 2));
const changedPackagesInfo = (await changedPackagesInfoPromises) const changedPackagesInfo = (await changedPackagesInfoPromises)
.filter((x) => x) .filter((x) => x)
@@ -393,7 +389,7 @@ export async function runVersion({
prBodyMaxCharacters, prBodyMaxCharacters,
}); });
if (existingPullRequests.data.length === 0) { if (searchResult.data.items.length === 0) {
core.info("creating pull request"); core.info("creating pull request");
const { data: newPullRequest } = await octokit.rest.pulls.create({ const { data: newPullRequest } = await octokit.rest.pulls.create({
base: branch, base: branch,
@@ -407,7 +403,7 @@ export async function runVersion({
pullRequestNumber: newPullRequest.number, pullRequestNumber: newPullRequest.number,
}; };
} else { } else {
const [pullRequest] = existingPullRequests.data; const [pullRequest] = searchResult.data.items;
core.info(`updating found pull request #${pullRequest.number}`); core.info(`updating found pull request #${pullRequest.number}`);
await octokit.rest.pulls.update({ await octokit.rest.pulls.update({
@@ -415,7 +411,6 @@ export async function runVersion({
title: finalPrTitle, title: finalPrTitle,
body: prBody, body: prBody,
...github.context.repo, ...github.context.repo,
state: "open",
}); });
return { return {
+1 -25
View File
@@ -1733,13 +1733,6 @@
resolved "https://registry.yarnpkg.com/@types/node/-/node-12.20.55.tgz#c329cbd434c42164f846b909bd6f85b5537f6240" resolved "https://registry.yarnpkg.com/@types/node/-/node-12.20.55.tgz#c329cbd434c42164f846b909bd6f85b5537f6240"
integrity sha512-J8xLz7q2OFulZ2cyGTLE1TbbZcjpno7FaN6zdJNrgAdrJ+DZzh/uFR6YrTb4C+nXakvud8Q4+rbhoIWlYQbUFQ== integrity sha512-J8xLz7q2OFulZ2cyGTLE1TbbZcjpno7FaN6zdJNrgAdrJ+DZzh/uFR6YrTb4C+nXakvud8Q4+rbhoIWlYQbUFQ==
"@types/node@^20.11.17":
version "20.11.17"
resolved "https://registry.yarnpkg.com/@types/node/-/node-20.11.17.tgz#cdd642d0e62ef3a861f88ddbc2b61e32578a9292"
integrity sha512-QmgQZGWu1Yw9TDyAP9ZzpFJKynYNeOvwMJmaxABfieQoVoiVOS6MN1WSpqpRcbeA5+RW82kraAVxCCJg+780Qw==
dependencies:
undici-types "~5.26.4"
"@types/normalize-package-data@^2.4.0": "@types/normalize-package-data@^2.4.0":
version "2.4.1" version "2.4.1"
resolved "https://registry.yarnpkg.com/@types/normalize-package-data/-/normalize-package-data-2.4.1.tgz#d3357479a0fdfdd5907fe67e17e0a85c906e1301" resolved "https://registry.yarnpkg.com/@types/normalize-package-data/-/normalize-package-data-2.4.1.tgz#d3357479a0fdfdd5907fe67e17e0a85c906e1301"
@@ -1750,16 +1743,11 @@
resolved "https://registry.yarnpkg.com/@types/prettier/-/prettier-2.7.2.tgz#6c2324641cc4ba050a8c710b2b251b377581fbf0" resolved "https://registry.yarnpkg.com/@types/prettier/-/prettier-2.7.2.tgz#6c2324641cc4ba050a8c710b2b251b377581fbf0"
integrity sha512-KufADq8uQqo1pYKVIYzfKbJfBAc0sOeXqGbFaSpv8MRmC/zXgowNZmFcbngndGk922QDmOASEXUZCaY48gs4cg== integrity sha512-KufADq8uQqo1pYKVIYzfKbJfBAc0sOeXqGbFaSpv8MRmC/zXgowNZmFcbngndGk922QDmOASEXUZCaY48gs4cg==
"@types/semver@^6.0.0": "@types/semver@^6.0.0", "@types/semver@^6.0.2":
version "6.2.3" version "6.2.3"
resolved "https://registry.yarnpkg.com/@types/semver/-/semver-6.2.3.tgz#5798ecf1bec94eaa64db39ee52808ec0693315aa" resolved "https://registry.yarnpkg.com/@types/semver/-/semver-6.2.3.tgz#5798ecf1bec94eaa64db39ee52808ec0693315aa"
integrity sha512-KQf+QAMWKMrtBMsB8/24w53tEsxllMj6TuA80TT/5igJalLI/zm0L3oXRbIAl4Ohfc85gyHX/jhMwsVkmhLU4A== integrity sha512-KQf+QAMWKMrtBMsB8/24w53tEsxllMj6TuA80TT/5igJalLI/zm0L3oXRbIAl4Ohfc85gyHX/jhMwsVkmhLU4A==
"@types/semver@^7.5.0":
version "7.5.0"
resolved "https://registry.yarnpkg.com/@types/semver/-/semver-7.5.0.tgz#591c1ce3a702c45ee15f47a42ade72c2fd78978a"
integrity sha512-G8hZ6XJiHnuhQKR7ZmysCeJWE08o8T0AXtk5darsCaTVsYZhhgUrq53jizaR2FvsoeCwJhlmwTjkXBY5Pn/ZHw==
"@types/stack-utils@^2.0.0": "@types/stack-utils@^2.0.0":
version "2.0.1" version "2.0.1"
resolved "https://registry.yarnpkg.com/@types/stack-utils/-/stack-utils-2.0.1.tgz#20f18294f797f2209b5f65c8e3b5c8e8261d127c" resolved "https://registry.yarnpkg.com/@types/stack-utils/-/stack-utils-2.0.1.tgz#20f18294f797f2209b5f65c8e3b5c8e8261d127c"
@@ -4444,13 +4432,6 @@ semver@^7.3.5:
dependencies: dependencies:
lru-cache "^6.0.0" lru-cache "^6.0.0"
semver@^7.5.3:
version "7.5.3"
resolved "https://registry.yarnpkg.com/semver/-/semver-7.5.3.tgz#161ce8c2c6b4b3bdca6caadc9fa3317a4c4fe88e"
integrity sha512-QBlUtyVk/5EeHbi7X0fw6liDZc7BBmEaSYn01fMU1OUYbf6GPsbTtd8WmnqbI20SeycoHSeiybkE/q1Q+qlThQ==
dependencies:
lru-cache "^6.0.0"
set-blocking@^2.0.0: set-blocking@^2.0.0:
version "2.0.0" version "2.0.0"
resolved "https://registry.yarnpkg.com/set-blocking/-/set-blocking-2.0.0.tgz#045f9782d011ae9a6803ddd382b24392b3d890f7" resolved "https://registry.yarnpkg.com/set-blocking/-/set-blocking-2.0.0.tgz#045f9782d011ae9a6803ddd382b24392b3d890f7"
@@ -4855,11 +4836,6 @@ unbox-primitive@^1.0.2:
has-symbols "^1.0.3" has-symbols "^1.0.3"
which-boxed-primitive "^1.0.2" which-boxed-primitive "^1.0.2"
undici-types@~5.26.4:
version "5.26.5"
resolved "https://registry.yarnpkg.com/undici-types/-/undici-types-5.26.5.tgz#bcd539893d00b56e964fd2657a4866b221a65617"
integrity sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==
unherit@^1.0.4: unherit@^1.0.4:
version "1.1.3" version "1.1.3"
resolved "https://registry.yarnpkg.com/unherit/-/unherit-1.1.3.tgz#6c9b503f2b41b262330c80e91c8614abdaa69c22" resolved "https://registry.yarnpkg.com/unherit/-/unherit-1.1.3.tgz#6c9b503f2b41b262330c80e91c8614abdaa69c22"