Skip to content

Commit 6f67a12

Browse files
authored
React 19 release runners (#28)
* deps: update to react 19 * package: move react and grapes to peers + add clean script * refactor: move example app to 19 * feat: add react app 18 example * further changes to support react 18 + 19 * refactor: use create root for react 19 demo * package: updates * * yarn lock * * ci: init * ci: add core build * ci: * * ci: * * ci: * * ci: * * feat: add docker files * * * docker * * apply react codemod * * * ci: * * * * * * fix build errors? * fix errors 2? * fix 3 * * * * * * * * * feat: add two simple examples in 18 & 19 * fix: use import type newline vs same * fix: build cjs main * fix: cjs and exclude react jsx runtime from build * refactor: remove simple example * pkg fix * ci * * ci: add release runners (#25) * ci: add runners * ci: fix* * ci: * * refactor: ORG_NPM_TOKEN * Revert "ci: add release runners (#25)" (#26) This reverts commit 4c17982. * React 19 release (#27) * ci: add runners * ci: fix* * ci: * * refactor: ORG_NPM_TOKEN
1 parent 9bd4b73 commit 6f67a12

File tree

6 files changed

+89
-10
lines changed

6 files changed

+89
-10
lines changed

.github/actions/setup-project/action.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,12 @@ runs:
1818
- name: Install dependencies
1919
run: yarn
2020
shell: bash
21+
22+
- name: Install React Dependencies in Root
23+
shell: bash
24+
run: |
25+
cd ./packages/grapesjs-react && yarn add \
26+
react@^19.0.0 \
27+
react-dom@^19.0.0 \
28+
@types/react@^19.0.0 \
29+
@types/react-dom@^19.0.0

.github/workflows/pr.yml

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,6 @@ jobs:
3030
- name: Setup Project Base
3131
uses: ./.github/actions/setup-project
3232

33-
## We specify the version of react and react-dom we want to run vite build with
34-
- name: Install React Dependencies in Root
35-
run: |
36-
cd ./packages/grapesjs-react && yarn add \
37-
react@^19.0.0 \
38-
react-dom@^19.0.0 \
39-
@types/react@^19.0.0 \
40-
@types/react-dom@^19.0.0
41-
4233
- name: Build Core
4334
run: yarn workspace @grapesjs/react run build
4435

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: Publish GrapesJS React latest
2+
on:
3+
push:
4+
branches: [main]
5+
6+
jobs:
7+
publish:
8+
if: "contains(github.event.head_commit.message, 'Release GrapesJS React latest:')"
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Checkout
12+
uses: actions/checkout@v4
13+
- name: Setup project
14+
uses: ./.github/actions/setup-project
15+
- name: Build
16+
run: yarn build:core
17+
- name: Publish to npm
18+
env:
19+
NODE_AUTH_TOKEN: ${{ secrets.ORG_NPM_TOKEN }}
20+
run: |
21+
echo "//registry.npmjs.org/:_authToken=${NODE_AUTH_TOKEN}" >> ./packages/grapesjs-react/.npmrc
22+
yarn publish:core:latest

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@
88
"clean": "find . -type d \\( -name \"node_modules\" -o -name \"build\" -o -name \"dist\" \\) -exec rm -rf {} + && rm ./yarn.lock",
99
"build:core": "yarn workspace @grapesjs/react run build",
1010
"build:app-18": "yarn workspace @grapesjs/react-app-18 run build",
11-
"build:app-19": "yarn workspace @grapesjs/react-app-19 run build"
11+
"build:app-19": "yarn workspace @grapesjs/react-app-19 run build",
12+
"release:core:latest": "ts-node scripts/releaseCore latest",
13+
"publish:core:latest": "cd packages/grapesjs-react && npm publish --access public"
1214
},
1315
"workspaces": {
1416
"packages": [

scripts/common.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { execSync } from "child_process";
2+
3+
export function runCommand(command: string, error?: string) {
4+
try {
5+
return (execSync(command, { stdio: "inherit" }) || "").toString().trim();
6+
} catch (err) {
7+
console.error(error || `Error while running command: ${command}`);
8+
throw err;
9+
}
10+
}

scripts/releaseCore.ts

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import fs from "fs";
2+
import { resolve } from "path";
3+
import { runCommand } from "./common";
4+
5+
const grapesJSReactPath = resolve(__dirname, "../packages/grapesjs-react");
6+
7+
async function prepareReleaseGrapesJSReact() {
8+
try {
9+
const releaseTag = process.argv[2] || "rc";
10+
console.log("Prepare release GrapesJS tag:", releaseTag);
11+
12+
runCommand(
13+
"git diff-index --quiet HEAD --",
14+
"You have uncommitted changes. Please commit or stash them before running the release script."
15+
);
16+
17+
const versionCmd =
18+
releaseTag === "latest"
19+
? "--patch"
20+
: `--prerelease --preid ${releaseTag}`;
21+
runCommand(
22+
`yarn workspace @grapesjs/react version ${versionCmd} --no-git-tag-version --no-commit-hooks`
23+
);
24+
25+
// Create a new release branch
26+
const newVersion = JSON.parse(
27+
fs.readFileSync(`${grapesJSReactPath}/package.json`, "utf8")
28+
).version;
29+
const newBranch = `release-v${newVersion}`;
30+
runCommand(`git checkout -b ${newBranch}`);
31+
runCommand("git add .");
32+
runCommand(
33+
`git commit -m "Release GrapesJS React ${releaseTag}: v${newVersion}"`
34+
);
35+
36+
console.log(
37+
`Release prepared! Push the current "${newBranch}" branch and open a new PR targeting 'main'`
38+
);
39+
} catch (error) {
40+
console.error(error);
41+
process.exit(1);
42+
}
43+
}
44+
45+
prepareReleaseGrapesJSReact();

0 commit comments

Comments
 (0)