Skip to content

Commit c674e86

Browse files
authored
Merge pull request #20 from thunlp/dev
Add workflow to publish to PyPI
2 parents c20e88c + 8aec54f commit c674e86

File tree

4 files changed

+53
-1
lines changed

4 files changed

+53
-1
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: "Publish to PyPI"
2+
on:
3+
release:
4+
types:
5+
- published
6+
jobs:
7+
build-n-publish:
8+
name: Build and publish
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v2
12+
- uses: actions/setup-python@v2
13+
with:
14+
python-version: '3.7'
15+
architecture: 'x64'
16+
- name: Run build script
17+
run: |
18+
echo "VERSION = \"${GITHUB_REF##refs/tags/v}\"" > OpenHowNet/version.py
19+
pip install twine --user
20+
pip install wheel
21+
python setup.py sdist bdist_wheel
22+
- name: Publish a Python distribution to PyPI
23+
uses: pypa/gh-action-pypi-publish@release/v1
24+
with:
25+
user: __token__
26+
password: ${{ secrets.PYPI_API_TOKEN }}

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,4 @@ __pycache__
99
*.egg-info
1010
.DS_Store
1111
/OpenHowNet/HowNet_dict_complete
12-
/*.py
1312
/*.sh

OpenHowNet/version.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
VERSION = "test"

setup.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import setuptools
2+
3+
VERSION = "test"
4+
with open("OpenHowNet/version.py", "r") as fver:
5+
VERSION = fver.read().replace("VERSION", "").replace("=", "").replace("\"", "").strip()
6+
7+
with open("README.md", "r", encoding="utf-8") as fh:
8+
long_description = '<h1 align="center">OpenHowNet</h1>\n'+fh.read().split('### [中文版本](README_ZH.md)\n\n')[1]
9+
10+
setuptools.setup(
11+
name="OpenHowNet",
12+
version=VERSION,
13+
author="THUNLP",
14+
author_email="thunlp@gmail.com",
15+
description="OpenHowNet",
16+
long_description=long_description,
17+
long_description_content_type="text/markdown",
18+
url="https://github.com/thunlp/OpenHowNet",
19+
packages=setuptools.find_packages(),
20+
classifiers=[
21+
"Programming Language :: Python :: 3",
22+
"License :: OSI Approved :: MIT License",
23+
"Operating System :: OS Independent",
24+
],
25+
python_requires=">=3.6"
26+
)

0 commit comments

Comments
 (0)