mirror of
https://github.com/changesets/action
synced 2026-10-26 16:39:56 +08:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
06245a4e0a | ||
|
|
ff7179cf12 | ||
|
|
8b16070fe3 | ||
|
|
07dc948a9f | ||
|
|
31ff97e8ac | ||
|
|
57ab80c611 | ||
|
|
50750fa876 | ||
|
|
48ab0d2f2e | ||
|
|
89b41e6c69 | ||
|
|
c62ef9792f |
@@ -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,10 +10,10 @@ jobs:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout Repo
|
- name: Checkout Repo
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Use Node.js 20
|
- name: Use Node.js 20
|
||||||
uses: actions/setup-node@v1
|
uses: actions/setup-node@v4
|
||||||
with:
|
with:
|
||||||
node-version: 20.x
|
node-version: 20.x
|
||||||
|
|
||||||
|
|||||||
@@ -12,10 +12,10 @@ 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 20
|
- name: Use Node.js 20
|
||||||
uses: actions/setup-node@v1
|
uses: actions/setup-node@v4
|
||||||
with:
|
with:
|
||||||
node-version: 20.x
|
node-version: 20.x
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,25 @@
|
|||||||
# @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
|
## 1.4.7
|
||||||
|
|
||||||
### 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:
|
||||||
@@ -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.
|
||||||
|
|
||||||
|
|||||||
Vendored
+1
-1
File diff suppressed because one or more lines are too long
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@changesets/action",
|
"name": "@changesets/action",
|
||||||
"version": "1.4.7",
|
"version": "1.4.10",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
|||||||
+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"`,
|
||||||
]);
|
]);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
+2
-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`;
|
||||||
|
|||||||
+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 },
|
||||||
|
|||||||
+10
-7
@@ -342,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(
|
||||||
@@ -376,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)
|
||||||
@@ -391,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,
|
||||||
@@ -405,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({
|
||||||
@@ -413,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 {
|
||||||
|
|||||||
Reference in New Issue
Block a user