Skip to content

Commit

Permalink
feat: automatic release system for js
Browse files Browse the repository at this point in the history
  • Loading branch information
asdofindia committed Oct 23, 2023
1 parent d5edec5 commit b8f6910
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 0 deletions.
23 changes: 23 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Release everything!
on:
push:
branches:
- main
# paths:
# - maps
jobs:
releaser:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
- name: Build
run: |
node scripts/build.js
- uses: ncipollo/release-action@v1
with:
artifacts: "build/*"
tag: v1.0.${{ github.run_id }}

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
build
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,17 @@ You can contribute the map to the community by either editing an existing map or

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.

### Using map library

You can find and download library artifacts in [releases](https://github.com/libindic/unicode-conversion-maps/releases)

For javascript, you can do

```javascript
import maps from './unicode-conversion-maps.mjs'
console.log(maps["revathi"]["A"]) // prints അ
```

## History

* [Payyans](https://github.com/libindic/payyans) is the origin of a lot of map files.
Expand Down
24 changes: 24 additions & 0 deletions scripts/build.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
const fs = require('fs');
const path = require('path');

const scriptDir = __dirname;
const mapsFolder = path.join(scriptDir, '..', "maps");
const buildFolder = path.join(scriptDir, '..', "build");
const atlas = {}
const files = fs.readdirSync(mapsFolder)
files.forEach((file) => {
const filePath = path.join(mapsFolder, file);

const data = fs.readFileSync(filePath, 'utf8')
const fontName = path.parse(file).name;
const fontMap = {};
data.split('\n').forEach(l => {
if (l.startsWith('#')) return;
const [lhs, rhs] = l.split('=').map(w => w.trim());
if (lhs) fontMap[lhs] = rhs;
})
atlas[fontName] = fontMap;
});
const jsBuildPath = path.join(buildFolder, 'unicode-conversion-maps.mjs');
fs.mkdirSync(buildFolder, { recursive: true })
fs.writeFileSync(jsBuildPath, `export default ${JSON.stringify(atlas, null, 0)};`)

0 comments on commit b8f6910

Please sign in to comment.