Skip to content
Merged
13 changes: 7 additions & 6 deletions .changeset/config.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
{
"$schema": "https://unpkg.com/@changesets/config@1.6.2/schema.json",
"changelog": [
"@changesets/changelog-github",
{ "repo": "changesets/action" }
],
"$schema": "https://unpkg.com/@changesets/config@4.0.0-next.6/schema.json",
"changelog": "@changesets/changelog-github",
"commit": false,
"linked": [],
"access": "restricted",
"baseBranch": "main",
"updateInternalDependencies": "patch",
"ignore": []
"ignore": [],
"privatePackages": {
"version": true,
"tag": true
}
}
3 changes: 0 additions & 3 deletions .changeset/pre.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
{
"mode": "pre",
"tag": "next",
"initialVersions": {
"@changesets/action": "1.9.0"
},
"changesets": [
"all-cars-grin",
"eight-clocks-pull",
Expand Down
41 changes: 33 additions & 8 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,38 @@ concurrency:
permissions: {} # each job should define its own permission explicitly

jobs:
select-mode:
name: Select mode
runs-on: ubuntu-latest
timeout-minutes: 20
outputs:
mode: ${{ steps.select-mode.outputs.mode }}
permissions:
contents: read # to check out repo (actions/checkout)
steps:
- name: Check out repo
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
with:
persist-credentials: false

- uses: ./.github/actions/ci-setup
with:
skip-cache: true # avoid cache poisoning attacks

- name: Build
run: pnpm build

- name: Select mode
id: select-mode
uses: ./select-mode

version:
name: Version
if: needs.select-mode.outputs.mode == 'version'
needs: select-mode
runs-on: ubuntu-latest
environment: version
timeout-minutes: 20
outputs:
hasChangesets: ${{ steps.changesets.outputs.hasChangesets }}
permissions:
contents: read # to check out repo (actions/checkout)
steps:
Expand All @@ -47,15 +72,15 @@ jobs:

- name: Create or update release pull request
id: changesets
uses: ./
uses: ./version
with:
github-token: ${{ steps.app-token.outputs.token }}
version: pnpm bump
script: pnpm bump

publish:
name: Publish
if: needs.version.outputs.hasChangesets == 'false'
needs: version
if: needs.select-mode.outputs.mode == 'publish'
needs: select-mode
runs-on: ubuntu-latest
environment: marketplace
timeout-minutes: 20
Expand All @@ -82,7 +107,7 @@ jobs:
run: pnpm build

- name: Publish to marketplace
uses: ./
uses: ./publish
with:
github-token: ${{ steps.app-token.outputs.token }}
publish: pnpm release
script: pnpm release
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"name": "@changesets/action",
"version": "2.0.0-next.2",
"private": true,
"license": "MIT",
"type": "module",
"main": "dist/index.js",
Expand Down Expand Up @@ -36,7 +37,7 @@
},
"devDependencies": {
"@changesets/changelog-github": "^1.0.0-next.6",
"@changesets/cli": "^3.0.0-next.7",
"@changesets/cli": "^3.0.0-next.8",
"@changesets/types": "^7.0.0-next.6",
"@changesets/write": "^1.0.0-next.6",
"@tsconfig/node24": "^24.0.4",
Expand Down
10 changes: 5 additions & 5 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pnpm-workspace.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ minimumReleaseAgeExclude:
- "@changesets/assemble-release-plan@7.0.0-next.7"
- "@changesets/changelog-git@1.0.0-next.6"
- "@changesets/changelog-github@1.0.0-next.6"
- "@changesets/cli@3.0.0-next.7"
- "@changesets/cli@3.0.0-next.8"
- "@changesets/config@4.0.0-next.6"
- "@changesets/get-dependents-graph@3.0.0-next.6"
- "@changesets/get-github-info@1.0.0-next.3"
Expand Down
4 changes: 3 additions & 1 deletion scripts/bump.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import fs from "node:fs";
import path from "node:path";
import { exec } from "@actions/exec";
import pkgJson from "../package.json" with { type: "json" };

process.chdir(path.join(import.meta.dirname, ".."));

await exec("changeset", ["version"]);

// read after versioning to get the new version
const pkgJson = (await import("../package.json", { with: { type: "json" } }))
.default;
const releaseLine = `v${pkgJson.version.split(".")[0]}`;

const readmePath = path.join(import.meta.dirname, "..", "README.md");
Expand Down
42 changes: 11 additions & 31 deletions scripts/release.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Buffer } from "node:buffer";
import path from "node:path";
import { exec, getExecOutput } from "@actions/exec";
import { exec } from "@actions/exec";
import pkgJson from "../package.json" with { type: "json" };

const tag = `v${pkgJson.version}`;
Expand All @@ -20,37 +20,17 @@ const gitEnv = {

process.chdir(path.join(import.meta.dirname, ".."));

(async () => {
const { exitCode, stderr } = await getExecOutput(
`git`,
["ls-remote", "--exit-code", "origin", "--tags", `refs/tags/${tag}`],
{
ignoreReturnCode: true,
},
);
if (exitCode === 0) {
console.log(
`Action is not being published because version ${tag} is already published`,
);
return;
}
if (exitCode !== 2) {
throw new Error(`git ls-remote exited with ${exitCode}:\n${stderr}`);
}

await exec("git", ["checkout", "--detach"]);
await exec("git", ["add", "--force", "dist"]);
await exec("git", ["commit", "-m", tag]);
await exec("git", ["checkout", "--detach"]);
await exec("git", ["add", "--force", "dist"]);
await exec("git", ["commit", "-m", tag]);

await exec("changeset", ["git-tag"]);

if (isPrerelease) {
await exec("git", ["push", "origin", `refs/tags/${tag}`], {
env: gitEnv,
});
return;
}
await exec("changeset", ["git-tag"]);

if (isPrerelease) {
await exec("git", ["push", "origin", `refs/tags/${tag}`], {
env: gitEnv,
});
} else {
await exec(
"git",
[
Expand All @@ -64,4 +44,4 @@ process.chdir(path.join(import.meta.dirname, ".."));
env: gitEnv,
},
);
})();
}