Skip to content

Commit b8f6910

Browse files
committed
feat: automatic release system for js
1 parent d5edec5 commit b8f6910

4 files changed

Lines changed: 59 additions & 0 deletions

File tree

.github/workflows/release.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: Release everything!
2+
on:
3+
push:
4+
branches:
5+
- main
6+
# paths:
7+
# - maps
8+
jobs:
9+
releaser:
10+
runs-on: ubuntu-latest
11+
permissions:
12+
contents: write
13+
steps:
14+
- uses: actions/checkout@v4
15+
- uses: actions/setup-node@v3
16+
- name: Build
17+
run: |
18+
node scripts/build.js
19+
- uses: ncipollo/release-action@v1
20+
with:
21+
artifacts: "build/*"
22+
tag: v1.0.${{ github.run_id }}
23+

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
build

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,17 @@ You can contribute the map to the community by either editing an existing map or
3838

3939
If you want to directly use these maps, you can paste them in [chekkans-web](http://asdofindia.github.io/chekkans-web/) at the bottom and use it directly.
4040

41+
### Using map library
42+
43+
You can find and download library artifacts in [releases](https://github.com/libindic/unicode-conversion-maps/releases)
44+
45+
For javascript, you can do
46+
47+
```javascript
48+
import maps from './unicode-conversion-maps.mjs'
49+
console.log(maps["revathi"]["A"]) // prints അ
50+
```
51+
4152
## History
4253

4354
* [Payyans](https://github.com/libindic/payyans) is the origin of a lot of map files.

scripts/build.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
const fs = require('fs');
2+
const path = require('path');
3+
4+
const scriptDir = __dirname;
5+
const mapsFolder = path.join(scriptDir, '..', "maps");
6+
const buildFolder = path.join(scriptDir, '..', "build");
7+
const atlas = {}
8+
const files = fs.readdirSync(mapsFolder)
9+
files.forEach((file) => {
10+
const filePath = path.join(mapsFolder, file);
11+
12+
const data = fs.readFileSync(filePath, 'utf8')
13+
const fontName = path.parse(file).name;
14+
const fontMap = {};
15+
data.split('\n').forEach(l => {
16+
if (l.startsWith('#')) return;
17+
const [lhs, rhs] = l.split('=').map(w => w.trim());
18+
if (lhs) fontMap[lhs] = rhs;
19+
})
20+
atlas[fontName] = fontMap;
21+
});
22+
const jsBuildPath = path.join(buildFolder, 'unicode-conversion-maps.mjs');
23+
fs.mkdirSync(buildFolder, { recursive: true })
24+
fs.writeFileSync(jsBuildPath, `export default ${JSON.stringify(atlas, null, 0)};`)

0 commit comments

Comments
 (0)