mirror of
https://github.com/changesets/action
synced 2026-10-26 16:39:56 +08:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f13b1baaa6 |
@@ -10,12 +10,12 @@ jobs:
|
||||
|
||||
steps:
|
||||
- name: Checkout Repo
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Use Node.js 20
|
||||
uses: actions/setup-node@v4
|
||||
- name: Use Node.js 16
|
||||
uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: 20.x
|
||||
node-version: 16.x
|
||||
|
||||
- name: Install Dependencies
|
||||
run: yarn --frozen-lockfile
|
||||
|
||||
@@ -12,12 +12,12 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout Repo
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Use Node.js 20
|
||||
uses: actions/setup-node@v4
|
||||
- name: Use Node.js 16
|
||||
uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: 20.x
|
||||
node-version: 16.x
|
||||
|
||||
- name: Install Dependencies
|
||||
run: yarn --frozen-lockfile
|
||||
|
||||
@@ -1,25 +1,5 @@
|
||||
# @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
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -16,7 +16,7 @@ This action for [Changesets](https://github.com/atlassian/changesets) creates a
|
||||
|
||||
### 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"}]`
|
||||
|
||||
### Example workflow:
|
||||
@@ -43,10 +43,10 @@ jobs:
|
||||
- name: Checkout Repo
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Setup Node.js 20
|
||||
- name: Setup Node.js 16
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: 20
|
||||
node-version: 16
|
||||
|
||||
- name: Install Dependencies
|
||||
run: yarn
|
||||
@@ -79,10 +79,10 @@ jobs:
|
||||
- name: Checkout Repo
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Setup Node.js 20.x
|
||||
- name: Setup Node.js 16.x
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: 20.x
|
||||
node-version: 16.x
|
||||
|
||||
- name: Install Dependencies
|
||||
run: yarn
|
||||
@@ -124,7 +124,7 @@ For example, you can add a step before running the Changesets GitHub Action:
|
||||
|
||||
#### 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.
|
||||
|
||||
@@ -144,10 +144,10 @@ jobs:
|
||||
- name: Checkout Repo
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Setup Node.js 20.x
|
||||
- name: Setup Node.js 16.x
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: 20.x
|
||||
node-version: 16.x
|
||||
|
||||
- name: Install Dependencies
|
||||
run: yarn
|
||||
@@ -188,10 +188,10 @@ jobs:
|
||||
- name: Checkout Repo
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Setup Node.js 20.x
|
||||
- name: Setup Node.js 16.x
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: 20.x
|
||||
node-version: 16.x
|
||||
|
||||
- name: Install Dependencies
|
||||
run: yarn
|
||||
|
||||
+1
-4
@@ -1,7 +1,7 @@
|
||||
name: Changesets
|
||||
description: A GitHub action to automate releases with Changesets
|
||||
runs:
|
||||
using: "node20"
|
||||
using: "node16"
|
||||
main: "dist/index.js"
|
||||
inputs:
|
||||
publish:
|
||||
@@ -28,9 +28,6 @@ inputs:
|
||||
description: "A boolean value to indicate whether to create Github releases after `publish` or not"
|
||||
required: false
|
||||
default: true
|
||||
branch:
|
||||
description: Sets the branch in which the action will run. Default to `github.ref_name` if not provided
|
||||
required: false
|
||||
outputs:
|
||||
published:
|
||||
description: A boolean value to indicate whether a publishing is happened or not
|
||||
|
||||
Vendored
+5
-5
File diff suppressed because one or more lines are too long
+5
-5
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@changesets/action",
|
||||
"version": "1.4.8",
|
||||
"version": "1.4.5",
|
||||
"main": "dist/index.js",
|
||||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
@@ -16,8 +16,8 @@
|
||||
"@babel/preset-typescript": "^7.13.0",
|
||||
"@types/fs-extra": "^8.0.0",
|
||||
"@types/jest": "^29.5.1",
|
||||
"@types/node": "^20.11.17",
|
||||
"@types/semver": "^7.5.0",
|
||||
"@types/node": "^12.7.1",
|
||||
"@types/semver": "^6.0.2",
|
||||
"babel-jest": "^29.5.0",
|
||||
"husky": "^3.0.3",
|
||||
"jest": "^29.5.0"
|
||||
@@ -31,7 +31,7 @@
|
||||
"release": "node ./scripts/release.js"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 20"
|
||||
"node": ">= 16"
|
||||
},
|
||||
"dependencies": {
|
||||
"@actions/core": "^1.10.0",
|
||||
@@ -46,7 +46,7 @@
|
||||
"remark-parse": "^7.0.1",
|
||||
"remark-stringify": "^7.0.3",
|
||||
"resolve-from": "^5.0.0",
|
||||
"semver": "^7.5.3",
|
||||
"semver": "^6.3.0",
|
||||
"unified": "^8.3.2"
|
||||
},
|
||||
"husky": {
|
||||
|
||||
@@ -109,7 +109,6 @@ const getOptionalInput = (name: string) => core.getInput(name) || undefined;
|
||||
prTitle: getOptionalInput("title"),
|
||||
commitMessage: getOptionalInput("commit"),
|
||||
hasPublishScript,
|
||||
branch: getOptionalInput("branch"),
|
||||
});
|
||||
|
||||
core.setOutput("pullRequestNumber", String(pullRequestNumber));
|
||||
|
||||
+18
-6
@@ -33,9 +33,11 @@ jest.mock("@actions/github/lib/utils", () => ({
|
||||
jest.mock("./gitUtils");
|
||||
|
||||
let mockedGithubMethods = {
|
||||
search: {
|
||||
issuesAndPullRequests: jest.fn(),
|
||||
},
|
||||
pulls: {
|
||||
create: jest.fn(),
|
||||
list: jest.fn(),
|
||||
},
|
||||
repos: {
|
||||
createRelease: jest.fn(),
|
||||
@@ -63,7 +65,9 @@ describe("version", () => {
|
||||
let cwd = f.copy("simple-project");
|
||||
linkNodeModules(cwd);
|
||||
|
||||
mockedGithubMethods.pulls.list.mockImplementationOnce(() => ({ data: [] }));
|
||||
mockedGithubMethods.search.issuesAndPullRequests.mockImplementationOnce(
|
||||
() => ({ data: { items: [] } })
|
||||
);
|
||||
|
||||
mockedGithubMethods.pulls.create.mockImplementationOnce(() => ({
|
||||
data: { number: 123 },
|
||||
@@ -100,7 +104,9 @@ describe("version", () => {
|
||||
let cwd = f.copy("simple-project");
|
||||
linkNodeModules(cwd);
|
||||
|
||||
mockedGithubMethods.pulls.list.mockImplementationOnce(() => ({ data: [] }));
|
||||
mockedGithubMethods.search.issuesAndPullRequests.mockImplementationOnce(
|
||||
() => ({ data: { items: [] } })
|
||||
);
|
||||
|
||||
mockedGithubMethods.pulls.create.mockImplementationOnce(() => ({
|
||||
data: { number: 123 },
|
||||
@@ -133,7 +139,9 @@ describe("version", () => {
|
||||
let cwd = f.copy("ignored-package");
|
||||
linkNodeModules(cwd);
|
||||
|
||||
mockedGithubMethods.pulls.list.mockImplementationOnce(() => ({ data: [] }));
|
||||
mockedGithubMethods.search.issuesAndPullRequests.mockImplementationOnce(
|
||||
() => ({ data: { items: [] } })
|
||||
);
|
||||
|
||||
mockedGithubMethods.pulls.create.mockImplementationOnce(() => ({
|
||||
data: { number: 123 },
|
||||
@@ -166,7 +174,9 @@ describe("version", () => {
|
||||
let cwd = f.copy("simple-project");
|
||||
linkNodeModules(cwd);
|
||||
|
||||
mockedGithubMethods.pulls.list.mockImplementationOnce(() => ({ data: [] }));
|
||||
mockedGithubMethods.search.issuesAndPullRequests.mockImplementationOnce(
|
||||
() => ({ data: { items: [] } })
|
||||
);
|
||||
|
||||
mockedGithubMethods.pulls.create.mockImplementationOnce(() => ({
|
||||
data: { number: 123 },
|
||||
@@ -223,7 +233,9 @@ fluminis divesque vulnere aquis parce lapsis rabie si visa fulmineis.
|
||||
let cwd = f.copy("simple-project");
|
||||
linkNodeModules(cwd);
|
||||
|
||||
mockedGithubMethods.pulls.list.mockImplementationOnce(() => ({ data: [] }));
|
||||
mockedGithubMethods.search.issuesAndPullRequests.mockImplementationOnce(
|
||||
() => ({ data: { items: [] } })
|
||||
);
|
||||
|
||||
mockedGithubMethods.pulls.create.mockImplementationOnce(() => ({
|
||||
data: { number: 123 },
|
||||
|
||||
+8
-13
@@ -299,7 +299,6 @@ type VersionOptions = {
|
||||
commitMessage?: string;
|
||||
hasPublishScript?: boolean;
|
||||
prBodyMaxCharacters?: number;
|
||||
branch?: string;
|
||||
};
|
||||
|
||||
type RunVersionResult = {
|
||||
@@ -314,12 +313,11 @@ export async function runVersion({
|
||||
commitMessage = "Version Packages",
|
||||
hasPublishScript = false,
|
||||
prBodyMaxCharacters = MAX_CHARACTERS_PER_MESSAGE,
|
||||
branch,
|
||||
}: VersionOptions): Promise<RunVersionResult> {
|
||||
const octokit = setupOctokit(githubToken);
|
||||
|
||||
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 { preState } = await readChangesetState(cwd);
|
||||
@@ -342,11 +340,9 @@ export async function runVersion({
|
||||
});
|
||||
}
|
||||
|
||||
const existingPullRequestsPromise = octokit.rest.pulls.list({
|
||||
...github.context.repo,
|
||||
state: "open",
|
||||
head: `${github.context.repo.owner}:${versionBranch}`,
|
||||
base: branch,
|
||||
let searchQuery = `repo:${repo}+state:open+head:${versionBranch}+base:${branch}+is:pull-request`;
|
||||
let searchResultPromise = octokit.rest.search.issuesAndPullRequests({
|
||||
q: searchQuery,
|
||||
});
|
||||
let changedPackages = await getChangedPackages(cwd, versionsByDirectory);
|
||||
let changedPackagesInfoPromises = Promise.all(
|
||||
@@ -378,8 +374,8 @@ export async function runVersion({
|
||||
|
||||
await gitUtils.push(versionBranch, { force: true });
|
||||
|
||||
let existingPullRequests = await existingPullRequestsPromise;
|
||||
core.info(JSON.stringify(existingPullRequests.data, null, 2));
|
||||
let searchResult = await searchResultPromise;
|
||||
core.info(JSON.stringify(searchResult.data, null, 2));
|
||||
|
||||
const changedPackagesInfo = (await changedPackagesInfoPromises)
|
||||
.filter((x) => x)
|
||||
@@ -393,7 +389,7 @@ export async function runVersion({
|
||||
prBodyMaxCharacters,
|
||||
});
|
||||
|
||||
if (existingPullRequests.data.length === 0) {
|
||||
if (searchResult.data.items.length === 0) {
|
||||
core.info("creating pull request");
|
||||
const { data: newPullRequest } = await octokit.rest.pulls.create({
|
||||
base: branch,
|
||||
@@ -407,7 +403,7 @@ export async function runVersion({
|
||||
pullRequestNumber: newPullRequest.number,
|
||||
};
|
||||
} else {
|
||||
const [pullRequest] = existingPullRequests.data;
|
||||
const [pullRequest] = searchResult.data.items;
|
||||
|
||||
core.info(`updating found pull request #${pullRequest.number}`);
|
||||
await octokit.rest.pulls.update({
|
||||
@@ -415,7 +411,6 @@ export async function runVersion({
|
||||
title: finalPrTitle,
|
||||
body: prBody,
|
||||
...github.context.repo,
|
||||
state: "open",
|
||||
});
|
||||
|
||||
return {
|
||||
|
||||
@@ -1733,13 +1733,6 @@
|
||||
resolved "https://registry.yarnpkg.com/@types/node/-/node-12.20.55.tgz#c329cbd434c42164f846b909bd6f85b5537f6240"
|
||||
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":
|
||||
version "2.4.1"
|
||||
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"
|
||||
integrity sha512-KufADq8uQqo1pYKVIYzfKbJfBAc0sOeXqGbFaSpv8MRmC/zXgowNZmFcbngndGk922QDmOASEXUZCaY48gs4cg==
|
||||
|
||||
"@types/semver@^6.0.0":
|
||||
"@types/semver@^6.0.0", "@types/semver@^6.0.2":
|
||||
version "6.2.3"
|
||||
resolved "https://registry.yarnpkg.com/@types/semver/-/semver-6.2.3.tgz#5798ecf1bec94eaa64db39ee52808ec0693315aa"
|
||||
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":
|
||||
version "2.0.1"
|
||||
resolved "https://registry.yarnpkg.com/@types/stack-utils/-/stack-utils-2.0.1.tgz#20f18294f797f2209b5f65c8e3b5c8e8261d127c"
|
||||
@@ -4444,13 +4432,6 @@ semver@^7.3.5:
|
||||
dependencies:
|
||||
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:
|
||||
version "2.0.0"
|
||||
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"
|
||||
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:
|
||||
version "1.1.3"
|
||||
resolved "https://registry.yarnpkg.com/unherit/-/unherit-1.1.3.tgz#6c9b503f2b41b262330c80e91c8614abdaa69c22"
|
||||
|
||||
Reference in New Issue
Block a user