mirror of
https://github.com/changesets/action
synced 2026-10-26 16:39:56 +08:00
Compare commits
@@ -0,0 +1,11 @@
|
|||||||
|
# To get started with Dependabot version updates, you'll need to specify which
|
||||||
|
# package ecosystems to update and where the package manifests are located.
|
||||||
|
# Please see the documentation for all configuration options:
|
||||||
|
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
|
||||||
|
|
||||||
|
version: 2
|
||||||
|
updates:
|
||||||
|
- package-ecosystem: "npm" # See documentation for possible values
|
||||||
|
directory: "/" # Location of package manifests
|
||||||
|
schedule:
|
||||||
|
interval: "weekly"
|
||||||
@@ -10,12 +10,12 @@ jobs:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout Repo
|
- name: Checkout Repo
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Use Node.js 16
|
- name: Use Node.js 20
|
||||||
uses: actions/setup-node@v1
|
uses: actions/setup-node@v4
|
||||||
with:
|
with:
|
||||||
node-version: 16.x
|
node-version: 20.x
|
||||||
|
|
||||||
- name: Install Dependencies
|
- name: Install Dependencies
|
||||||
run: yarn --frozen-lockfile
|
run: yarn --frozen-lockfile
|
||||||
|
|||||||
@@ -12,12 +12,12 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout Repo
|
- name: Checkout Repo
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Use Node.js 16
|
- name: Use Node.js 20
|
||||||
uses: actions/setup-node@v1
|
uses: actions/setup-node@v4
|
||||||
with:
|
with:
|
||||||
node-version: 16.x
|
node-version: 20.x
|
||||||
|
|
||||||
- name: Install Dependencies
|
- name: Install Dependencies
|
||||||
run: yarn --frozen-lockfile
|
run: yarn --frozen-lockfile
|
||||||
|
|||||||
@@ -1,5 +1,43 @@
|
|||||||
# @changesets/action
|
# @changesets/action
|
||||||
|
|
||||||
|
## 1.4.10
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- [#448](https://github.com/changesets/action/pull/448) [`8b16070`](https://github.com/changesets/action/commit/8b16070fe386eed3456c83eeed9460160432cf26) Thanks [@bluwy](https://github.com/bluwy)! - Use full git email (`41898282+github-actions[bot]@users.noreply.github.com`) for github-actions bot when making commits
|
||||||
|
|
||||||
|
## 1.4.9
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- [#415](https://github.com/changesets/action/pull/415) [`57ab80c`](https://github.com/changesets/action/commit/57ab80c61104c270bebc125910ae32da3a5aca46) Thanks [@benmccann](https://github.com/benmccann)! - Improve error message when attempting to publish without publish script defined
|
||||||
|
|
||||||
|
## 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
|
||||||
|
|
||||||
|
- [#282](https://github.com/changesets/action/pull/282) [`eb19e25`](https://github.com/changesets/action/commit/eb19e25e7797cf33dc2de4caa071e85a8057a0f0) Thanks [@mark-omarov](https://github.com/mark-omarov)! - Updated a few dependencies to patch the security vulnerabilities that were reported for their older versions.
|
||||||
|
|
||||||
## 1.4.4
|
## 1.4.4
|
||||||
|
|
||||||
### Patch Changes
|
### Patch Changes
|
||||||
|
|||||||
@@ -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 is happened or not
|
- published - A boolean value to indicate whether a publishing has 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 16
|
- name: Setup Node.js 20
|
||||||
uses: actions/setup-node@v3
|
uses: actions/setup-node@v3
|
||||||
with:
|
with:
|
||||||
node-version: 16
|
node-version: 20
|
||||||
|
|
||||||
- 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 16.x
|
- name: Setup Node.js 20.x
|
||||||
uses: actions/setup-node@v3
|
uses: actions/setup-node@v3
|
||||||
with:
|
with:
|
||||||
node-version: 16.x
|
node-version: 20.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 16.x
|
- name: Setup Node.js 20.x
|
||||||
uses: actions/setup-node@v3
|
uses: actions/setup-node@v3
|
||||||
with:
|
with:
|
||||||
node-version: 16.x
|
node-version: 20.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 16.x
|
- name: Setup Node.js 20.x
|
||||||
uses: actions/setup-node@v3
|
uses: actions/setup-node@v3
|
||||||
with:
|
with:
|
||||||
node-version: 16.x
|
node-version: 20.x
|
||||||
|
|
||||||
- name: Install Dependencies
|
- name: Install Dependencies
|
||||||
run: yarn
|
run: yarn
|
||||||
|
|||||||
+4
-1
@@ -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: "node16"
|
using: "node20"
|
||||||
main: "dist/index.js"
|
main: "dist/index.js"
|
||||||
inputs:
|
inputs:
|
||||||
publish:
|
publish:
|
||||||
@@ -28,6 +28,9 @@ 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
|
||||||
|
|||||||
Vendored
+63
File diff suppressed because one or more lines are too long
+18
-16
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@changesets/action",
|
"name": "@changesets/action",
|
||||||
"version": "1.4.4",
|
"version": "1.4.10",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
@@ -10,7 +10,17 @@
|
|||||||
"@vercel/ncc": "^0.36.1",
|
"@vercel/ncc": "^0.36.1",
|
||||||
"fixturez": "^1.1.0",
|
"fixturez": "^1.1.0",
|
||||||
"prettier": "^2.0.5",
|
"prettier": "^2.0.5",
|
||||||
"typescript": "^5.0.4"
|
"typescript": "^5.0.4",
|
||||||
|
"@babel/core": "^7.13.10",
|
||||||
|
"@babel/preset-env": "^7.13.10",
|
||||||
|
"@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",
|
||||||
|
"babel-jest": "^29.5.0",
|
||||||
|
"husky": "^3.0.3",
|
||||||
|
"jest": "^29.5.0"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "ncc build src/index.ts -o dist --transpile-only --minify",
|
"build": "ncc build src/index.ts -o dist --transpile-only --minify",
|
||||||
@@ -21,32 +31,22 @@
|
|||||||
"release": "node ./scripts/release.js"
|
"release": "node ./scripts/release.js"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">= 16"
|
"node": ">= 20"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/core": "^1.10.0",
|
"@actions/core": "^1.10.0",
|
||||||
"@actions/exec": "^1.1.1",
|
"@actions/exec": "^1.1.1",
|
||||||
"@actions/github": "^5.1.1",
|
"@actions/github": "^5.1.1",
|
||||||
"@babel/core": "^7.13.10",
|
|
||||||
"@babel/preset-env": "^7.13.10",
|
|
||||||
"@babel/preset-typescript": "^7.13.0",
|
|
||||||
"@changesets/pre": "^1.0.9",
|
"@changesets/pre": "^1.0.9",
|
||||||
"@changesets/read": "^0.5.3",
|
"@changesets/read": "^0.5.3",
|
||||||
"@manypkg/get-packages": "^1.1.3",
|
"@manypkg/get-packages": "^1.1.3",
|
||||||
"@octokit/plugin-throttling": "5.1.1",
|
"@octokit/plugin-throttling": "^5.2.1",
|
||||||
"@types/fs-extra": "^8.0.0",
|
|
||||||
"@types/jest": "^29.5.1",
|
|
||||||
"@types/node": "^12.7.1",
|
|
||||||
"@types/semver": "^6.0.2",
|
|
||||||
"babel-jest": "^29.5.0",
|
|
||||||
"fs-extra": "^8.1.0",
|
"fs-extra": "^8.1.0",
|
||||||
"husky": "^3.0.3",
|
|
||||||
"jest": "^29.5.0",
|
|
||||||
"mdast-util-to-string": "^1.0.6",
|
"mdast-util-to-string": "^1.0.6",
|
||||||
"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": "^6.3.0",
|
"semver": "^7.5.3",
|
||||||
"unified": "^8.3.2"
|
"unified": "^8.3.2"
|
||||||
},
|
},
|
||||||
"husky": {
|
"husky": {
|
||||||
@@ -54,6 +54,8 @@
|
|||||||
},
|
},
|
||||||
"prettier": {},
|
"prettier": {},
|
||||||
"resolutions": {
|
"resolutions": {
|
||||||
"**/@octokit/core": "4.2.0"
|
"**/@octokit/core": "4.2.0",
|
||||||
|
"trim": "^0.0.3",
|
||||||
|
"y18n": "^4.0.1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -9,7 +9,7 @@ export const setupUser = async () => {
|
|||||||
await exec("git", [
|
await exec("git", [
|
||||||
"config",
|
"config",
|
||||||
"user.email",
|
"user.email",
|
||||||
`"github-actions[bot]@users.noreply.github.com"`,
|
`"41898282+github-actions[bot]@users.noreply.github.com"`,
|
||||||
]);
|
]);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
+3
-2
@@ -48,11 +48,11 @@ const getOptionalInput = (name: string) => core.getInput(name) || undefined;
|
|||||||
|
|
||||||
switch (true) {
|
switch (true) {
|
||||||
case !hasChangesets && !hasPublishScript:
|
case !hasChangesets && !hasPublishScript:
|
||||||
core.info("No changesets found");
|
core.info("No changesets present or were removed by merging release PR. Not publishing because no publish script found.");
|
||||||
return;
|
return;
|
||||||
case !hasChangesets && hasPublishScript: {
|
case !hasChangesets && hasPublishScript: {
|
||||||
core.info(
|
core.info(
|
||||||
"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`;
|
||||||
@@ -109,6 +109,7 @@ 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));
|
||||||
|
|||||||
@@ -11,17 +11,19 @@ export default async function readChangesetState(
|
|||||||
cwd: string = process.cwd()
|
cwd: string = process.cwd()
|
||||||
): Promise<ChangesetState> {
|
): Promise<ChangesetState> {
|
||||||
let preState = await readPreState(cwd);
|
let preState = await readPreState(cwd);
|
||||||
let isInPreMode = preState !== undefined && preState.mode === "pre";
|
|
||||||
|
|
||||||
let changesets = await readChangesets(cwd);
|
let changesets = await readChangesets(cwd);
|
||||||
|
|
||||||
if (isInPreMode) {
|
if (preState !== undefined && preState.mode === "pre") {
|
||||||
let changesetsToFilter = new Set(preState.changesets);
|
let changesetsToFilter = new Set(preState.changesets);
|
||||||
changesets = changesets.filter((x) => !changesetsToFilter.has(x.id));
|
|
||||||
|
return {
|
||||||
|
preState,
|
||||||
|
changesets: changesets.filter((x) => !changesetsToFilter.has(x.id)),
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
preState: isInPreMode ? preState : undefined,
|
preState: undefined,
|
||||||
changesets,
|
changesets,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
+6
-18
@@ -33,11 +33,9 @@ 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(),
|
||||||
@@ -65,9 +63,7 @@ describe("version", () => {
|
|||||||
let cwd = f.copy("simple-project");
|
let cwd = f.copy("simple-project");
|
||||||
linkNodeModules(cwd);
|
linkNodeModules(cwd);
|
||||||
|
|
||||||
mockedGithubMethods.search.issuesAndPullRequests.mockImplementationOnce(
|
mockedGithubMethods.pulls.list.mockImplementationOnce(() => ({ data: [] }));
|
||||||
() => ({ data: { items: [] } })
|
|
||||||
);
|
|
||||||
|
|
||||||
mockedGithubMethods.pulls.create.mockImplementationOnce(() => ({
|
mockedGithubMethods.pulls.create.mockImplementationOnce(() => ({
|
||||||
data: { number: 123 },
|
data: { number: 123 },
|
||||||
@@ -104,9 +100,7 @@ describe("version", () => {
|
|||||||
let cwd = f.copy("simple-project");
|
let cwd = f.copy("simple-project");
|
||||||
linkNodeModules(cwd);
|
linkNodeModules(cwd);
|
||||||
|
|
||||||
mockedGithubMethods.search.issuesAndPullRequests.mockImplementationOnce(
|
mockedGithubMethods.pulls.list.mockImplementationOnce(() => ({ data: [] }));
|
||||||
() => ({ data: { items: [] } })
|
|
||||||
);
|
|
||||||
|
|
||||||
mockedGithubMethods.pulls.create.mockImplementationOnce(() => ({
|
mockedGithubMethods.pulls.create.mockImplementationOnce(() => ({
|
||||||
data: { number: 123 },
|
data: { number: 123 },
|
||||||
@@ -139,9 +133,7 @@ describe("version", () => {
|
|||||||
let cwd = f.copy("ignored-package");
|
let cwd = f.copy("ignored-package");
|
||||||
linkNodeModules(cwd);
|
linkNodeModules(cwd);
|
||||||
|
|
||||||
mockedGithubMethods.search.issuesAndPullRequests.mockImplementationOnce(
|
mockedGithubMethods.pulls.list.mockImplementationOnce(() => ({ data: [] }));
|
||||||
() => ({ data: { items: [] } })
|
|
||||||
);
|
|
||||||
|
|
||||||
mockedGithubMethods.pulls.create.mockImplementationOnce(() => ({
|
mockedGithubMethods.pulls.create.mockImplementationOnce(() => ({
|
||||||
data: { number: 123 },
|
data: { number: 123 },
|
||||||
@@ -174,9 +166,7 @@ describe("version", () => {
|
|||||||
let cwd = f.copy("simple-project");
|
let cwd = f.copy("simple-project");
|
||||||
linkNodeModules(cwd);
|
linkNodeModules(cwd);
|
||||||
|
|
||||||
mockedGithubMethods.search.issuesAndPullRequests.mockImplementationOnce(
|
mockedGithubMethods.pulls.list.mockImplementationOnce(() => ({ data: [] }));
|
||||||
() => ({ data: { items: [] } })
|
|
||||||
);
|
|
||||||
|
|
||||||
mockedGithubMethods.pulls.create.mockImplementationOnce(() => ({
|
mockedGithubMethods.pulls.create.mockImplementationOnce(() => ({
|
||||||
data: { number: 123 },
|
data: { number: 123 },
|
||||||
@@ -233,9 +223,7 @@ 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.search.issuesAndPullRequests.mockImplementationOnce(
|
mockedGithubMethods.pulls.list.mockImplementationOnce(() => ({ data: [] }));
|
||||||
() => ({ data: { items: [] } })
|
|
||||||
);
|
|
||||||
|
|
||||||
mockedGithubMethods.pulls.create.mockImplementationOnce(() => ({
|
mockedGithubMethods.pulls.create.mockImplementationOnce(() => ({
|
||||||
data: { number: 123 },
|
data: { number: 123 },
|
||||||
|
|||||||
+27
-14
@@ -17,8 +17,6 @@ import * as gitUtils from "./gitUtils";
|
|||||||
import readChangesetState from "./readChangesetState";
|
import readChangesetState from "./readChangesetState";
|
||||||
import resolveFrom from "resolve-from";
|
import resolveFrom from "resolve-from";
|
||||||
import { throttling } from "@octokit/plugin-throttling";
|
import { throttling } from "@octokit/plugin-throttling";
|
||||||
// temporary workaround for https://github.com/octokit/plugin-throttling.js/pull/590
|
|
||||||
import type {} from "@octokit/plugin-throttling/dist-types/types.d";
|
|
||||||
|
|
||||||
// GitHub Issues/PRs messages have a max size limit on the
|
// GitHub Issues/PRs messages have a max size limit on the
|
||||||
// message body payload.
|
// message body payload.
|
||||||
@@ -26,7 +24,7 @@ import type {} from "@octokit/plugin-throttling/dist-types/types.d";
|
|||||||
// To avoid that, we ensure to cap the message to 60k chars.
|
// To avoid that, we ensure to cap the message to 60k chars.
|
||||||
const MAX_CHARACTERS_PER_MESSAGE = 60000;
|
const MAX_CHARACTERS_PER_MESSAGE = 60000;
|
||||||
|
|
||||||
const setupOctokit = (githubToken) => {
|
const setupOctokit = (githubToken: string) => {
|
||||||
return new (GitHub.plugin(throttling))(
|
return new (GitHub.plugin(throttling))(
|
||||||
getOctokitOptions(githubToken, {
|
getOctokitOptions(githubToken, {
|
||||||
throttle: {
|
throttle: {
|
||||||
@@ -61,7 +59,7 @@ const setupOctokit = (githubToken) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const createRelease = async (
|
const createRelease = async (
|
||||||
octokit: ReturnType<typeof GitHub>,
|
octokit: ReturnType<typeof setupOctokit>,
|
||||||
{ pkg, tagName }: { pkg: Package; tagName: string }
|
{ pkg, tagName }: { pkg: Package; tagName: string }
|
||||||
) => {
|
) => {
|
||||||
try {
|
try {
|
||||||
@@ -87,7 +85,12 @@ const createRelease = async (
|
|||||||
});
|
});
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
// if we can't find a changelog, the user has probably disabled changelogs
|
// if we can't find a changelog, the user has probably disabled changelogs
|
||||||
if (err.code !== "ENOENT") {
|
if (
|
||||||
|
err &&
|
||||||
|
typeof err === "object" &&
|
||||||
|
"code" in err &&
|
||||||
|
err.code !== "ENOENT"
|
||||||
|
) {
|
||||||
throw err;
|
throw err;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -205,7 +208,12 @@ const requireChangesetsCliPkgJson = (cwd: string) => {
|
|||||||
try {
|
try {
|
||||||
return require(resolveFrom(cwd, "@changesets/cli/package.json"));
|
return require(resolveFrom(cwd, "@changesets/cli/package.json"));
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
if (err && err.code === "MODULE_NOT_FOUND") {
|
if (
|
||||||
|
err &&
|
||||||
|
typeof err === "object" &&
|
||||||
|
"code" in err &&
|
||||||
|
err.code === "MODULE_NOT_FOUND"
|
||||||
|
) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`Have you forgotten to install \`@changesets/cli\` in "${cwd}"?`
|
`Have you forgotten to install \`@changesets/cli\` in "${cwd}"?`
|
||||||
);
|
);
|
||||||
@@ -291,6 +299,7 @@ type VersionOptions = {
|
|||||||
commitMessage?: string;
|
commitMessage?: string;
|
||||||
hasPublishScript?: boolean;
|
hasPublishScript?: boolean;
|
||||||
prBodyMaxCharacters?: number;
|
prBodyMaxCharacters?: number;
|
||||||
|
branch?: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
type RunVersionResult = {
|
type RunVersionResult = {
|
||||||
@@ -305,11 +314,12 @@ 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}`;
|
||||||
let branch = github.context.ref.replace("refs/heads/", "");
|
branch = 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);
|
||||||
@@ -332,9 +342,11 @@ export async function runVersion({
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
let searchQuery = `repo:${repo}+state:open+head:${versionBranch}+base:${branch}+is:pull-request`;
|
const existingPullRequestsPromise = octokit.rest.pulls.list({
|
||||||
let searchResultPromise = octokit.rest.search.issuesAndPullRequests({
|
...github.context.repo,
|
||||||
q: searchQuery,
|
state: "open",
|
||||||
|
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(
|
||||||
@@ -366,8 +378,8 @@ export async function runVersion({
|
|||||||
|
|
||||||
await gitUtils.push(versionBranch, { force: true });
|
await gitUtils.push(versionBranch, { force: true });
|
||||||
|
|
||||||
let searchResult = await searchResultPromise;
|
let existingPullRequests = await existingPullRequestsPromise;
|
||||||
core.info(JSON.stringify(searchResult.data, null, 2));
|
core.info(JSON.stringify(existingPullRequests.data, null, 2));
|
||||||
|
|
||||||
const changedPackagesInfo = (await changedPackagesInfoPromises)
|
const changedPackagesInfo = (await changedPackagesInfoPromises)
|
||||||
.filter((x) => x)
|
.filter((x) => x)
|
||||||
@@ -381,7 +393,7 @@ export async function runVersion({
|
|||||||
prBodyMaxCharacters,
|
prBodyMaxCharacters,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (searchResult.data.items.length === 0) {
|
if (existingPullRequests.data.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,
|
||||||
@@ -395,7 +407,7 @@ export async function runVersion({
|
|||||||
pullRequestNumber: newPullRequest.number,
|
pullRequestNumber: newPullRequest.number,
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
const [pullRequest] = searchResult.data.items;
|
const [pullRequest] = existingPullRequests.data;
|
||||||
|
|
||||||
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({
|
||||||
@@ -403,6 +415,7 @@ export async function runVersion({
|
|||||||
title: finalPrTitle,
|
title: finalPrTitle,
|
||||||
body: prBody,
|
body: prBody,
|
||||||
...github.context.repo,
|
...github.context.repo,
|
||||||
|
state: "open",
|
||||||
});
|
});
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ import remarkParse from "remark-parse";
|
|||||||
import remarkStringify from "remark-stringify";
|
import remarkStringify from "remark-stringify";
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
import mdastToString from "mdast-util-to-string";
|
import mdastToString from "mdast-util-to-string";
|
||||||
import { exec } from "@actions/exec";
|
|
||||||
import { getPackages, Package } from "@manypkg/get-packages";
|
import { getPackages, Package } from "@manypkg/get-packages";
|
||||||
|
|
||||||
export const BumpLevels = {
|
export const BumpLevels = {
|
||||||
|
|||||||
Reference in New Issue
Block a user