Skip to content

Commit 9718f5b

Browse files
committed
feat: python build and pypi publishing
1 parent 1dd5269 commit 9718f5b

2 files changed

Lines changed: 26 additions & 2 deletions

File tree

.github/workflows/release.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,21 @@ on:
88
jobs:
99
releaser:
1010
runs-on: ubuntu-latest
11+
environment: release
1112
permissions:
1213
contents: write
14+
id-token: write
1315
steps:
1416
- uses: actions/checkout@v4
1517
- uses: actions/setup-node@v3
1618
with:
1719
registry-url: 'https://registry.npmjs.org'
20+
- uses: actions/setup-python@v4
1821
- name: Build
1922
run: |
2023
node scripts/build.js ${{ github.run_id }}
24+
cd build/pypi
25+
python -m build
2126
- uses: ncipollo/release-action@v1
2227
with:
2328
artifacts: "build/raw/*"
@@ -27,4 +32,7 @@ jobs:
2732
run: npm publish --access public
2833
env:
2934
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
30-
35+
- name: Publish package to PyPI
36+
uses: pypa/gh-action-pypi-publish@release/v1
37+
with:
38+
packages-dir: build/pypi/dist

scripts/build.js

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,4 +53,20 @@ fs.writeFileSync(npmPackageJson, `{
5353
}
5454
`)
5555

56-
fs.copyFileSync(jsBuildPath, path.join(npmFolder, "unicode-conversion-maps.mjs"))
56+
fs.copyFileSync(jsBuildPath, path.join(npmFolder, "unicode-conversion-maps.mjs"))
57+
58+
const pythonFolder = path.join(buildFolder, "pypi");
59+
const pythonFilePath = path.join(pythonFolder, "libindic", "unicode_conversion_maps", "__init__.py")
60+
mkdir(path.dirname(pythonFilePath));
61+
62+
fs.writeFileSync(pythonFilePath, `# This Python file uses the following encoding: utf-8
63+
maps = ${JSON.stringify(atlas, null, 0)}`);
64+
65+
fs.writeFileSync(path.join(pythonFolder, 'pyproject.toml'), `[build-system]
66+
requires = ["setuptools"]
67+
build-backend = "setuptools.build_meta"
68+
69+
[project]
70+
name = "libindic-unicode-conversion-maps"
71+
version = "1.0.${version}"
72+
`)

0 commit comments

Comments
 (0)