Skip to content

Commit

Permalink
ci: fixed release scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
jmjuanes committed Jul 25, 2023
1 parent a7714d3 commit 48ce6c8
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 5 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion packages/react/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
2 changes: 1 addition & 1 deletion packages/svg/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
34 changes: 34 additions & 0 deletions scripts/release.js
Original file line number Diff line number Diff line change
@@ -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();

0 comments on commit 48ce6c8

Please sign in to comment.