mirror of
				https://github.com/excalidraw/excalidraw.git
				synced 2025-10-31 10:54:33 +01:00 
			
		
		
		
	 5662c5141d
			
		
	
	5662c5141d
	
	
	
		
			
			* feat: Auto release @excalidraw/excalidraw-next on every change * fix * fix name * fix * add logs * use commithash * yarn installå * fix * catch * log * fix * uncomment * remove console * add logs * list files changed between prev and current commit * fetch last two commits * remove logs * fix * update readme_next * update readme before release * temp commit to trigger release * update package name to excalidraw-next * bold * remove temp branch * add note about next * fix * fix * fix
		
			
				
	
	
		
			52 lines
		
	
	
		
			1.5 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			52 lines
		
	
	
		
			1.5 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
| 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();
 | |
| });
 |