Skip to content

Commit 676b88a

Browse files
committed
chore: release to npm
1 parent 7a049e1 commit 676b88a

2 files changed

Lines changed: 40 additions & 3 deletions

File tree

.github/workflows/release.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,18 @@ jobs:
1313
steps:
1414
- uses: actions/checkout@v4
1515
- uses: actions/setup-node@v3
16+
with:
17+
registry-url: 'https://registry.npmjs.org'
1618
- name: Build
1719
run: |
18-
node scripts/build.js
20+
node scripts/build.js ${{ github.run_id }}
1921
- uses: ncipollo/release-action@v1
2022
with:
2123
artifacts: "build/raw/*"
2224
tag: v1.0.${{ github.run_id }}
25+
- name: npm publish
26+
working-directory: build/npm
27+
run: npm publish --access public
28+
env:
29+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
2330

scripts/build.js

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
const fs = require('fs');
22
const path = require('path');
33

4+
const version = process.argv[2];
5+
6+
const mkdir = (f) => fs.mkdirSync(f, { recursive: true })
7+
48
const scriptDir = __dirname;
59
const mapsFolder = path.join(scriptDir, '..', "maps");
610
const buildFolder = path.join(scriptDir, '..', "build");
@@ -21,5 +25,31 @@ files.forEach((file) => {
2125
atlas[fontName] = fontMap;
2226
});
2327
const jsBuildPath = path.join(buildRawFolder, 'unicode-conversion-maps.mjs');
24-
fs.mkdirSync(buildRawFolder, { recursive: true })
25-
fs.writeFileSync(jsBuildPath, `export default ${JSON.stringify(atlas, null, 0)};`)
28+
mkdir(buildRawFolder);
29+
fs.writeFileSync(jsBuildPath, `export default ${JSON.stringify(atlas, null, 0)};`)
30+
31+
const npmFolder = path.join(buildFolder, "npm");
32+
mkdir(npmFolder);
33+
34+
const npmReadme = path.join(npmFolder, 'README.md')
35+
fs.writeFileSync(npmReadme, `# Unicode Conversion Maps
36+
37+
Install with \`npm install @indicjs/unicode-conversion-maps\`
38+
39+
Then use it like this:
40+
\`\`\`javascript
41+
import maps from '@indicjs/unicode-conversion-maps'
42+
console.log(maps["revathi"]["A"]) // prints അ
43+
\`\`\`
44+
`)
45+
46+
const npmPackageJson = path.join(npmFolder, 'package.json');
47+
fs.writeFileSync(npmPackageJson, `{
48+
"name": "@indicjs/unicode-conversion-maps",
49+
"version": "1.0.${version}",
50+
"homepage": "https://github.com/libindic/unicode-conversion-maps",
51+
"main": "unicode-conversion-maps.mjs",
52+
"type": "module"
53+
}`)
54+
55+
fs.copyFileSync(jsBuildPath, path.join(npmFolder, "unicode-conversion-maps.mjs"))

0 commit comments

Comments
 (0)