mirror of
https://github.com/changesets/action
synced 2026-10-26 16:39:56 +08:00
Compare commits
14
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6da688107f | ||
|
|
615034bb14 | ||
|
|
8380fc6a4d | ||
|
|
e912ac334c | ||
|
|
f01916801c | ||
|
|
a4133a0d28 | ||
|
|
0138f456ec | ||
|
|
88338839e3 | ||
|
|
e08fde7435 | ||
|
|
371fd77b45 | ||
|
|
85efcafd80 | ||
|
|
5bb9d5ccac | ||
|
|
ca8589735a | ||
|
|
36f529f13a |
@@ -27,12 +27,12 @@ jobs:
|
||||
security-events: write # allow writing security events
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
|
||||
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
with:
|
||||
persist-credentials: false
|
||||
|
||||
- name: Run zizmor
|
||||
uses: zizmorcore/zizmor-action@3dc1ecc9bcb9e94e9b2c709687979e1298497054 # v0.6.2
|
||||
uses: zizmorcore/zizmor-action@cc914d7f3750a2d13d75c7f184a1060aa0e9d482 # v0.6.4
|
||||
with:
|
||||
persona: pedantic
|
||||
annotations: true
|
||||
|
||||
@@ -33,7 +33,7 @@ jobs:
|
||||
|
||||
- name: Select mode
|
||||
id: select-mode
|
||||
uses: ./select-mode
|
||||
uses: $/select-mode
|
||||
|
||||
version:
|
||||
name: Version
|
||||
@@ -62,7 +62,7 @@ jobs:
|
||||
|
||||
- name: Create or update release pull request
|
||||
id: changesets
|
||||
uses: ./version
|
||||
uses: $/version
|
||||
with:
|
||||
github-token: ${{ steps.bot-auth.outputs.token }}
|
||||
script: pnpm bump
|
||||
@@ -92,7 +92,7 @@ jobs:
|
||||
permission-contents: write # to bypass branch and tag protection rules (release.ts)
|
||||
|
||||
- name: Publish to marketplace
|
||||
uses: ./publish
|
||||
uses: $/publish
|
||||
with:
|
||||
github-token: ${{ steps.bot-auth.outputs.token }}
|
||||
script: pnpm release
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
v24.11.0
|
||||
24.22.1
|
||||
|
||||
@@ -1,5 +1,17 @@
|
||||
# @changesets/action
|
||||
|
||||
## 2.1.2
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- [#735](https://github.com/changesets/action/pull/735) [`8833883`](https://github.com/changesets/action/commit/88338839e35c3e0fa61f3c9c3f27e7572cd5f2cf) Thanks [@bluwy](https://github.com/bluwy)! - Handle error when pushing git tags with the git CLI
|
||||
|
||||
- [#724](https://github.com/changesets/action/pull/724) [`36f529f`](https://github.com/changesets/action/commit/36f529f13ab58bbcf6331035cb950385586e8a89) Thanks [@bluwy](https://github.com/bluwy)! - Improve log messages
|
||||
|
||||
- [#724](https://github.com/changesets/action/pull/724) [`36f529f`](https://github.com/changesets/action/commit/36f529f13ab58bbcf6331035cb950385586e8a89) Thanks [@bluwy](https://github.com/bluwy)! - Fix root action double error logs
|
||||
|
||||
- [#729](https://github.com/changesets/action/pull/729) [`ca85897`](https://github.com/changesets/action/commit/ca8589735af2ff6977a0f6474537d550040530d8) Thanks [@bluwy](https://github.com/bluwy)! - Always switch and reset branch when generating version commits, similar to if `push-with-git-cli` is enabled
|
||||
|
||||
## 2.1.1
|
||||
|
||||
### Patch Changes
|
||||
|
||||
+18
-18
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@changesets/action",
|
||||
"version": "2.1.1",
|
||||
"version": "2.1.2",
|
||||
"private": true,
|
||||
"license": "MIT",
|
||||
"type": "module",
|
||||
@@ -23,33 +23,33 @@
|
||||
"@actions/core": "^3.0.1",
|
||||
"@actions/exec": "^3.0.0",
|
||||
"@actions/github": "^9.1.1",
|
||||
"@changesets/get-release-plan": "^5.0.0",
|
||||
"@changesets/get-release-plan": "^5.0.2",
|
||||
"@changesets/ghcommit": "^3.0.0",
|
||||
"@changesets/git": "^4.0.0",
|
||||
"@changesets/git": "^4.0.1",
|
||||
"@changesets/pre": "^3.0.0",
|
||||
"@changesets/read": "^1.0.0",
|
||||
"@changesets/read": "^1.0.1",
|
||||
"@manypkg/get-packages": "^3.1.0",
|
||||
"@octokit/core": "^7.0.7",
|
||||
"@octokit/core": "^7.0.8",
|
||||
"@octokit/plugin-throttling": "^11.0.5",
|
||||
"human-id": "^4.2.0",
|
||||
"human-id": "^4.2.1",
|
||||
"markdown-table": "^3.0.4",
|
||||
"semver": "^7.8.5",
|
||||
"tinyexec": "^1.3.0"
|
||||
"tinyexec": "^1.3.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@changesets/changelog-github": "^1.0.0",
|
||||
"@changesets/cli": "^3.0.0",
|
||||
"@changesets/changelog-github": "^1.0.1",
|
||||
"@changesets/cli": "^3.0.3",
|
||||
"@changesets/types": "^7.0.0",
|
||||
"@changesets/write": "^1.0.0",
|
||||
"@tsconfig/node24": "^24.0.4",
|
||||
"@types/node": "^26.1.2",
|
||||
"@changesets/write": "^1.0.1",
|
||||
"@tsconfig/node24": "^24.0.5",
|
||||
"@types/node": "^26.6.2",
|
||||
"@types/semver": "^7.8.0",
|
||||
"fs-fixture": "^2.14.0",
|
||||
"oxfmt": "^0.61.0",
|
||||
"rolldown": "^1.2.2",
|
||||
"typescript": "^6.0.3",
|
||||
"vitest": "^4.1.10",
|
||||
"yaml": "^2.9.0"
|
||||
"fs-fixture": "^2.16.0",
|
||||
"oxfmt": "^0.70.0",
|
||||
"rolldown": "^1.2.10",
|
||||
"typescript": "^7.0.2",
|
||||
"vitest": "^5.0.1",
|
||||
"yaml": "^2.9.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=24"
|
||||
|
||||
Generated
+635
-422
File diff suppressed because it is too large
Load Diff
+17
-19
@@ -195,7 +195,7 @@ export class GitHub {
|
||||
if (authorIdentity.exitCode === 0 && committerIdentity.exitCode === 0) {
|
||||
return;
|
||||
}
|
||||
core.info("Setting Git user to github-actions[bot]");
|
||||
core.info("Setting git user to github-actions[bot]");
|
||||
await exec("git", ["config", "user.name", `"github-actions[bot]"`], {
|
||||
cwd: this.cwd,
|
||||
});
|
||||
@@ -213,32 +213,30 @@ export class GitHub {
|
||||
}
|
||||
|
||||
async pushTag(tag: string) {
|
||||
if (!this.pushWithGitCli) {
|
||||
return this.octokit.rest.git
|
||||
.createRef({
|
||||
try {
|
||||
if (!this.pushWithGitCli) {
|
||||
await this.octokit.rest.git.createRef({
|
||||
...context.repo,
|
||||
ref: `refs/tags/${tag}`,
|
||||
sha: context.sha,
|
||||
})
|
||||
.catch((err) => {
|
||||
// Assuming tag was manually pushed in custom publish script
|
||||
core.warning(`Failed to create tag ${tag}: ${err.message}`);
|
||||
});
|
||||
} else {
|
||||
await exec("git", ["push", "origin", tag], {
|
||||
cwd: this.cwd,
|
||||
env: {
|
||||
...process.env,
|
||||
...(await this.#getCliAuthEnv()),
|
||||
} as Record<string, string>,
|
||||
});
|
||||
}
|
||||
} catch (err) {
|
||||
core.warning(
|
||||
`Failed to create git tag "${tag}". Assuming it was manually pushed by the publish script: ${(err as Error).message}`,
|
||||
);
|
||||
}
|
||||
await exec("git", ["push", "origin", tag], {
|
||||
cwd: this.cwd,
|
||||
env: {
|
||||
...process.env,
|
||||
...(await this.#getCliAuthEnv()),
|
||||
} as Record<string, string>,
|
||||
});
|
||||
}
|
||||
|
||||
async prepareBranch(branch: string) {
|
||||
if (!this.pushWithGitCli) {
|
||||
// Preparing a new local branch is not necessary when using the API
|
||||
return;
|
||||
}
|
||||
await switchToMaybeExistingBranch(branch, { cwd: this.cwd });
|
||||
await reset(context.sha, { cwd: this.cwd });
|
||||
}
|
||||
|
||||
+11
-9
@@ -10,7 +10,13 @@ import {
|
||||
validateChangesetsCliVersion,
|
||||
} from "./utils.ts";
|
||||
|
||||
(async () => {
|
||||
try {
|
||||
await main();
|
||||
} catch (err) {
|
||||
core.setFailed((err as Error).message);
|
||||
}
|
||||
|
||||
async function main() {
|
||||
const cwd = getOptionalInput("cwd") || process.cwd();
|
||||
await validateChangesetsCliVersion(cwd);
|
||||
|
||||
@@ -62,7 +68,7 @@ import {
|
||||
switch (true) {
|
||||
case !hasChangesets && !hasPublishScript:
|
||||
core.info(
|
||||
"No changesets present or were removed by merging release PR. Not publishing because no publish script found.",
|
||||
"No changesets present or were removed by merging version PR. Not publishing because publish-script is not set.",
|
||||
);
|
||||
return;
|
||||
case !hasChangesets && hasPublishScript: {
|
||||
@@ -98,7 +104,7 @@ import {
|
||||
}
|
||||
|
||||
if (result.exitCode !== 0) {
|
||||
core.error(
|
||||
throw new Error(
|
||||
`Publish command exited with code ${result.exitCode}${
|
||||
result.published
|
||||
? `, but some packages were published: ${result.publishedPackages
|
||||
@@ -107,12 +113,11 @@ import {
|
||||
: ""
|
||||
}`,
|
||||
);
|
||||
process.exit(result.exitCode);
|
||||
}
|
||||
return;
|
||||
}
|
||||
case hasChangesets && !hasNonEmptyChangesets:
|
||||
core.info("All changesets are empty; not creating PR");
|
||||
core.info("All changesets are empty. Not creating PR");
|
||||
return;
|
||||
case hasChangesets: {
|
||||
const { pullRequestNumber } = await runVersion({
|
||||
@@ -131,7 +136,4 @@ import {
|
||||
return;
|
||||
}
|
||||
}
|
||||
})().catch((err) => {
|
||||
core.error(err);
|
||||
core.setFailed(err.message);
|
||||
});
|
||||
}
|
||||
|
||||
+23
-9
@@ -1,12 +1,13 @@
|
||||
import path from "node:path";
|
||||
import * as core from "@actions/core";
|
||||
import * as github from "@actions/github";
|
||||
import type { Changeset } from "@changesets/types";
|
||||
import { writeChangeset } from "@changesets/write";
|
||||
import { createFixture } from "fs-fixture";
|
||||
import { exec } from "tinyexec";
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import { GitHub } from "./github.ts";
|
||||
import { runPublish, runVersion } from "./run.ts";
|
||||
import { gitdir } from "./test-utils.ts";
|
||||
|
||||
vi.mock("@actions/github", () => ({
|
||||
context: {
|
||||
@@ -44,7 +45,7 @@ let mockedGraphql = vi.fn();
|
||||
const nodeModulesDir = path.join(import.meta.dirname, "..", "node_modules");
|
||||
|
||||
function createSimpleProjectFixture() {
|
||||
return createFixture({
|
||||
return gitdir({
|
||||
node_modules: (api) => api.symlink(nodeModulesDir),
|
||||
".changeset/config.json": JSON.stringify({}),
|
||||
"packages/pkg-a/package.json": JSON.stringify({
|
||||
@@ -69,7 +70,7 @@ function createSimpleProjectFixture() {
|
||||
}
|
||||
|
||||
function createIgnoredPackageFixture() {
|
||||
return createFixture({
|
||||
return gitdir({
|
||||
node_modules: (api) => api.symlink(nodeModulesDir),
|
||||
".changeset/config.json": JSON.stringify({
|
||||
ignore: ["changesets-dev-ignored-package-pkg-a"],
|
||||
@@ -106,15 +107,20 @@ const createGithub = (cwd: string) =>
|
||||
pushWithGitCli: false,
|
||||
});
|
||||
|
||||
async function initializeGitRepository(cwd: string) {
|
||||
await exec("git", ["init"], {
|
||||
async function updateGithubContext(cwd: string) {
|
||||
const head = await exec("git", ["rev-parse", "HEAD"], {
|
||||
nodeOptions: { cwd },
|
||||
throwOnError: true,
|
||||
});
|
||||
github.context.sha = head.stdout.trim();
|
||||
}
|
||||
|
||||
function resetGithubContext() {
|
||||
github.context.sha = "xeac7";
|
||||
}
|
||||
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks();
|
||||
resetGithubContext();
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
@@ -125,7 +131,7 @@ describe("publish", () => {
|
||||
it("warns when a custom publish script does not create the output file", async () => {
|
||||
await using fixture = await createSimpleProjectFixture();
|
||||
const cwd = fixture.path;
|
||||
await initializeGitRepository(cwd);
|
||||
await updateGithubContext(cwd);
|
||||
vi.stubEnv("RUNNER_TEMP", cwd);
|
||||
|
||||
const result = await runPublish({
|
||||
@@ -145,7 +151,7 @@ describe("publish", () => {
|
||||
});
|
||||
|
||||
it("throws when the built-in publish command does not create the output file", async () => {
|
||||
await using fixture = await createFixture({
|
||||
await using fixture = await gitdir({
|
||||
"node_modules/@changesets/cli/package.json": JSON.stringify({
|
||||
name: "@changesets/cli",
|
||||
type: "module",
|
||||
@@ -158,7 +164,7 @@ describe("publish", () => {
|
||||
"package-lock.json": "",
|
||||
});
|
||||
const cwd = fixture.path;
|
||||
await initializeGitRepository(cwd);
|
||||
await updateGithubContext(cwd);
|
||||
vi.stubEnv("RUNNER_TEMP", cwd);
|
||||
|
||||
await expect(
|
||||
@@ -176,6 +182,7 @@ describe("version", () => {
|
||||
it("creates simple PR", async () => {
|
||||
await using fixture = await createSimpleProjectFixture();
|
||||
const cwd = fixture.path;
|
||||
await updateGithubContext(cwd);
|
||||
|
||||
mockedGithubMethods.pulls.list.mockImplementationOnce(() => ({ data: [] }));
|
||||
|
||||
@@ -213,6 +220,7 @@ describe("version", () => {
|
||||
it('creates a draft PR when prDraft is "create"', async () => {
|
||||
await using fixture = await createSimpleProjectFixture();
|
||||
const cwd = fixture.path;
|
||||
await updateGithubContext(cwd);
|
||||
|
||||
mockedGithubMethods.pulls.list.mockImplementationOnce(() => ({ data: [] }));
|
||||
|
||||
@@ -247,6 +255,7 @@ describe("version", () => {
|
||||
it("only includes bumped packages in the PR body", async () => {
|
||||
await using fixture = await createSimpleProjectFixture();
|
||||
const cwd = fixture.path;
|
||||
await updateGithubContext(cwd);
|
||||
|
||||
mockedGithubMethods.pulls.list.mockImplementationOnce(() => ({ data: [] }));
|
||||
|
||||
@@ -280,6 +289,7 @@ describe("version", () => {
|
||||
it("doesn't include ignored package that got a dependency update in the PR body", async () => {
|
||||
await using fixture = await createIgnoredPackageFixture();
|
||||
const cwd = fixture.path;
|
||||
await updateGithubContext(cwd);
|
||||
|
||||
mockedGithubMethods.pulls.list.mockImplementationOnce(() => ({ data: [] }));
|
||||
|
||||
@@ -313,6 +323,7 @@ describe("version", () => {
|
||||
it("does not include changelog entries if full message exceeds size limit", async () => {
|
||||
await using fixture = await createSimpleProjectFixture();
|
||||
const cwd = fixture.path;
|
||||
await updateGithubContext(cwd);
|
||||
|
||||
mockedGithubMethods.pulls.list.mockImplementationOnce(() => ({ data: [] }));
|
||||
|
||||
@@ -370,6 +381,7 @@ fluminis divesque vulnere aquis parce lapsis rabie si visa fulmineis.
|
||||
it("does not include any release information if a message with simplified release info exceeds size limit", async () => {
|
||||
await using fixture = await createSimpleProjectFixture();
|
||||
const cwd = fixture.path;
|
||||
await updateGithubContext(cwd);
|
||||
|
||||
mockedGithubMethods.pulls.list.mockImplementationOnce(() => ({ data: [] }));
|
||||
|
||||
@@ -427,6 +439,7 @@ fluminis divesque vulnere aquis parce lapsis rabie si visa fulmineis.
|
||||
it('updates an existing PR via GraphQL without converting it to draft when prDraft is "create"', async () => {
|
||||
await using fixture = await createSimpleProjectFixture();
|
||||
const cwd = fixture.path;
|
||||
await updateGithubContext(cwd);
|
||||
|
||||
mockedGithubMethods.pulls.list.mockImplementationOnce(() => ({
|
||||
data: [{ number: 123, node_id: "PR_kwDOA" }],
|
||||
@@ -459,6 +472,7 @@ fluminis divesque vulnere aquis parce lapsis rabie si visa fulmineis.
|
||||
it('updates an existing PR via GraphQL and converts it to draft when prDraft is "always"', async () => {
|
||||
await using fixture = await createSimpleProjectFixture();
|
||||
const cwd = fixture.path;
|
||||
await updateGithubContext(cwd);
|
||||
|
||||
mockedGithubMethods.pulls.list.mockImplementationOnce(() => ({
|
||||
data: [{ number: 123, node_id: "PR_kwDOA" }],
|
||||
|
||||
+3
-3
@@ -401,7 +401,7 @@ export async function runVersion({
|
||||
head: `${context.repo.owner}:${versionBranch}`,
|
||||
base: branch,
|
||||
});
|
||||
core.info(
|
||||
core.debug(
|
||||
`Existing pull requests: ${JSON.stringify(
|
||||
existingPullRequests.data,
|
||||
null,
|
||||
@@ -427,7 +427,7 @@ export async function runVersion({
|
||||
});
|
||||
|
||||
if (existingPullRequests.data.length === 0) {
|
||||
core.info("creating pull request");
|
||||
core.info("Creating pull request");
|
||||
const { data: newPullRequest } = await octokit.rest.pulls.create({
|
||||
base: branch,
|
||||
head: versionBranch,
|
||||
@@ -443,7 +443,7 @@ export async function runVersion({
|
||||
} else {
|
||||
const [pullRequest] = existingPullRequests.data;
|
||||
|
||||
core.info(`updating found pull request #${pullRequest.number}`);
|
||||
core.info(`Updating found pull request #${pullRequest.number}`);
|
||||
const convertPullRequestToDraftMutation =
|
||||
prDraft === "always"
|
||||
? `
|
||||
|
||||
Reference in New Issue
Block a user