diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index c64efe7..e482d44 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -20,8 +20,9 @@ jobs: with: node-version: '16.x' - run: yarn install - - run: yarn build - - run: yarn pack:icons + - run: yarn run build + - run: yarn run release + - run: yarn run pack:icons - uses: actions/upload-artifact@v3 with: name: packages diff --git a/package.json b/package.json index 4b1d4a7..6e0e37b 100644 --- a/package.json +++ b/package.json @@ -30,7 +30,8 @@ "test": "jest packages", "test:react": "jest packages/react", "test:svg": "jest packages/svg", - "pack:icons": "zip -r icons.zip ./icons" + "pack:icons": "zip -r icons.zip ./icons", + "release": "node ./scripts/release.js" }, "devDependencies": { "@babel/core": "^7.21.4", diff --git a/packages/react/package.json b/packages/react/package.json index f1fd5a6..6c359b0 100644 --- a/packages/react/package.json +++ b/packages/react/package.json @@ -1,6 +1,6 @@ { "name": "@josemi-icons/react", - "version": "0.1.0", + "version": "0.0.0", "description": "An open source and hand-crafted SVG icons library", "author": { "name": "Josemi Juanes", diff --git a/packages/svg/package.json b/packages/svg/package.json index 536fcd4..acc0f3f 100644 --- a/packages/svg/package.json +++ b/packages/svg/package.json @@ -1,6 +1,6 @@ { "name": "@josemi-icons/svg", - "version": "0.1.0", + "version": "0.0.0", "description": "An open source and hand-crafted SVG icons library", "author": { "name": "Josemi Juanes", diff --git a/scripts/release.js b/scripts/release.js new file mode 100644 index 0000000..84c7a84 --- /dev/null +++ b/scripts/release.js @@ -0,0 +1,34 @@ +const fs = require("node:fs/promises"); +const path = require("path"); + +const {version} = require("../package.json"); + +const readJson = file => { + return fs.readFile(file, "utf8") + .then(data => JSON.parse(data)); +}; + +const writeJson = (file, content) => { + return fs.writeFile(file, JSON.stringify(content, null, " "), "utf8"); +}; + +// Prepare next release +const main = async () => { + console.log("[release] Prepare release for packages in './packages' folder"); + const packagesFolder = path.join(process.cwd(), "packages"); + const packagesList = await fs.readdir(packagesFolder); + console.log(`[release] Found ${packagesList.length} packages to prepare`); + // Prepare each package in ./packages folder + for (let i = 0; i < packagesList.length; i++) { + const name = packagesList[i]; + console.log(`[release] Preparing package '${name}'...`); + const packagePath = path.join(packagesFolder, name, "package.json"); + const currentPkg = await readJson(packagePath); + currentPkg.version = version; + await writeJson(packagePath, currentPkg); + } + // Finish release prepare script + console.log("[release] Release ready"); +}; + +main();