Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions .github/scripts/release.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { execFileSync } from "node:child_process";

const mode = process.argv[2];

const run = (args) => execFileSync("pnpm", args, { stdio: "inherit" });

// changesets/action runs `git checkout changeset-release/main` + `git reset
// --hard` immediately before this, which can leave the deps state out of
// sync with pnpm-workspace.yaml. The next gated pnpm call
// (verifyDepsBeforeRun: error) would then abort the release. `pnpm install`
// is not gated, so reconcile here, after the action's git work and before
// any `pnpm changeset` call. Do not hoist this into an earlier workflow
// step: the action's git reset runs after workflow steps and undoes it.
// Must be --no-frozen-lockfile, not --prefer-frozen-lockfile: prefer-frozen
// can take the lockfile fast path and skip rewriting the stale deps-state
// hash, which is the exact condition that trips the gate.
run(["install", "--no-frozen-lockfile"]);

if (mode === "version") {
run(["changeset", "version"]);
run(["install", "--no-frozen-lockfile"]);
} else if (mode === "publish") {
run(["changeset", "publish"]);
} else {
throw new Error(
`Unknown release mode: ${JSON.stringify(mode)} (expected "version" or "publish")`,
);
}
6 changes: 3 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,16 +71,16 @@ jobs:
id: changesets
uses: changesets/action@63a615b9cd06ba9a3e6d13796c7fbcb080a60a0b # v1.8.0
with:
version: pnpm run changeset:version
publish: pnpm changeset publish
version: node .github/scripts/release.mjs version
publish: node .github/scripts/release.mjs publish
commit: "ci: release"
title: "ci: release"
env:
GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}

- name: Publish (manual)
if: ${{ inputs.publish-only }}
run: pnpm changeset publish
run: node .github/scripts/release.mjs publish

sync-templates:
name: Sync Templates
Expand Down
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@
"screenshots": "node scripts/screenshot-all-templates.mjs",
"query-counts": "node scripts/query-counts.mjs",
"locale:extract": "pnpm --filter @emdash-cms/admin locale:extract",
"locale:compile": "pnpm --filter @emdash-cms/admin locale:compile",
"changeset:version": "pnpm changeset version && pnpm install --no-frozen-lockfile"
"locale:compile": "pnpm --filter @emdash-cms/admin locale:compile"
},
"keywords": [],
"author": "Matt Kane",
Expand Down
Loading