diff --git a/.github/workflows/autorelease-excalidraw.yml b/.github/workflows/autorelease-excalidraw.yml
new file mode 100644
index 00000000..230ea630
--- /dev/null
+++ b/.github/workflows/autorelease-excalidraw.yml
@@ -0,0 +1,26 @@
+name: Auto release @excalidraw/excalidraw-next
+on:
+ push:
+ branches:
+ - master
+
+jobs:
+ Auto-release-excalidraw-next:
+ runs-on: ubuntu-latest
+
+ steps:
+ - uses: actions/checkout@v2
+ with:
+ fetch-depth: 2
+ - name: Setup Node.js 14.x
+ uses: actions/setup-node@v2
+ with:
+ node-version: 14.x
+ - name: Set up publish access
+ run: |
+ npm config set //registry.npmjs.org/:_authToken ${NPM_TOKEN}
+ env:
+ NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
+ - name: Auto release
+ run: |
+ yarn autorelease
diff --git a/package.json b/package.json
index be3a3992..9a3cd557 100644
--- a/package.json
+++ b/package.json
@@ -104,6 +104,7 @@
"test:other": "yarn prettier --list-different",
"test:typecheck": "tsc",
"test:update": "yarn test:app --updateSnapshot --watchAll=false",
- "test": "yarn test:app"
+ "test": "yarn test:app",
+ "autorelease": "node scripts/autorelease.js"
}
}
diff --git a/scripts/autorelease.js b/scripts/autorelease.js
new file mode 100644
index 00000000..45a0b1d4
--- /dev/null
+++ b/scripts/autorelease.js
@@ -0,0 +1,51 @@
+const fs = require("fs");
+const { exec, execSync } = require("child_process");
+
+const excalidrawDir = `${__dirname}/../src/packages/excalidraw`;
+const excalidrawPackage = `${excalidrawDir}/package.json`;
+const pkg = require(excalidrawPackage);
+
+const getShortCommitHash = () => {
+ return execSync("git rev-parse --short HEAD").toString().trim();
+};
+
+const publish = () => {
+ try {
+ execSync(`yarn --frozen-lockfile`);
+ execSync(`yarn --frozen-lockfile`, { cwd: excalidrawDir });
+ execSync(`yarn run build:umd`, { cwd: excalidrawDir });
+ execSync(`yarn --cwd ${excalidrawDir} publish`);
+ } catch (e) {
+ console.error(e);
+ }
+};
+
+// get files changed between prev and head commit
+exec(`git diff --name-only HEAD^ HEAD`, async (error, stdout, stderr) => {
+ if (error || stderr) {
+ console.error(error);
+ process.exit(1);
+ }
+
+ const changedFiles = stdout.trim().split("\n");
+ const filesToIgnoreRegex = /src\/excalidraw-app|packages\/utils/;
+
+ const excalidrawPackageFiles = changedFiles.filter((file) => {
+ return file.indexOf("src") >= 0 && !filesToIgnoreRegex.test(file);
+ });
+
+ if (!excalidrawPackageFiles.length) {
+ process.exit(0);
+ }
+
+ // update package.json
+ pkg.version = `${pkg.version}-${getShortCommitHash()}`;
+ pkg.name = "@excalidraw/excalidraw-next";
+ fs.writeFileSync(excalidrawPackage, JSON.stringify(pkg, null, 2), "utf8");
+
+ // update readme
+ const data = fs.readFileSync(`${excalidrawDir}/README_NEXT.md`, "utf8");
+ fs.writeFileSync(`${excalidrawDir}/README.md`, data, "utf8");
+
+ publish();
+});
diff --git a/src/packages/excalidraw/README.md b/src/packages/excalidraw/README.md
index f72d829f..d1f487d0 100644
--- a/src/packages/excalidraw/README.md
+++ b/src/packages/excalidraw/README.md
@@ -24,6 +24,10 @@ By default it will try to load the files from `https://unpkg.com/@excalidraw/exc
If you want to load assets from a different path you can set a variable `window.EXCALIDRAW_ASSET_PATH` depending on environment (for example if you have different URL's for dev and prod) to the url from where you want to load the assets.
+#### Note
+
+**If you don't want to wait for the next stable release and try out the unreleased changes you can use [@excalidraw/excalidraw-next](https://www.npmjs.com/package/@excalidraw/excalidraw-next).**
+
### Demo
[Try here](https://codesandbox.io/s/excalidraw-ehlz3).
diff --git a/src/packages/excalidraw/README_NEXT.md b/src/packages/excalidraw/README_NEXT.md
index f72d829f..697f1907 100644
--- a/src/packages/excalidraw/README_NEXT.md
+++ b/src/packages/excalidraw/README_NEXT.md
@@ -1,3 +1,13 @@
+
+
+## Note
+
+**This is an unstable release and not recommended for production. If you don't want to wait for the stable release and try out the unreleased changes you can use this.**
+
+For stable release please use [@excalidraw/excalidraw](https://www.npmjs.com/package/@excalidraw/excalidraw).
+
+
+
### Excalidraw
Excalidraw exported as a component to directly embed in your projects.
@@ -7,20 +17,20 @@ Excalidraw exported as a component to directly embed in your projects.
You can use npm
```
-npm install react react-dom @excalidraw/excalidraw
+npm install react react-dom @excalidraw/excalidraw-next
```
or via yarn
```
-yarn add react react-dom @excalidraw/excalidraw
+yarn add react react-dom @excalidraw/excalidraw-next
```
After installation you will see a folder `excalidraw-assets` and `excalidraw-assets-dev` in `dist` directory which contains the assets needed for this app in prod and dev mode respectively.
Move the folder `excalidraw-assets` and `excalidraw-assets-dev` to the path where your assets are served.
-By default it will try to load the files from `https://unpkg.com/@excalidraw/excalidraw/{currentVersion}/dist/`
+By default it will try to load the files from `https://unpkg.com/@excalidraw/excalidraw-next/dist/`
If you want to load assets from a different path you can set a variable `window.EXCALIDRAW_ASSET_PATH` depending on environment (for example if you have different URL's for dev and prod) to the url from where you want to load the assets.
@@ -38,7 +48,7 @@ If you are using a Web bundler (for instance, Webpack), you can import it as an
```js
import React, { useEffect, useState, useRef } from "react";
-import Excalidraw from "@excalidraw/excalidraw";
+import Excalidraw from "@excalidraw/excalidraw-next";
import InitialData from "./initialData";
import "./styles.scss";
@@ -156,13 +166,13 @@ import { useState, useEffect } from "react";
export default function IndexPage() {
const [Comp, setComp] = useState(null);
useEffect(() => {
- import("@excalidraw/excalidraw").then((comp) => setComp(comp.default));
+ import("@excalidraw/excalidraw-next").then((comp) => setComp(comp.default));
});
return <>{Comp &&
-import { getSceneVersion } from "@excalidraw/excalidraw"; +import { getSceneVersion } from "@excalidraw/excalidraw-next"; getSceneVersion(elements: ExcalidrawElement[])@@ -653,7 +663,7 @@ isInvisiblySmallElement(element: