55 inputs :
66 version :
77 description : ' Release version'
8- required : true
8+ required : false
99
1010jobs :
1111 build :
@@ -15,15 +15,17 @@ jobs:
1515 python-version : [3.9]
1616 steps :
1717 - uses : actions/checkout@v3
18+ with :
19+ fetch-depth : 0
1820 - name : Set up Python ${{ matrix.python-version }}
1921 uses : actions/setup-python@v4
2022 with :
2123 python-version : ${{ matrix.python-version }}
2224 - name : Install dependencies
2325 run : |
2426 python -m pip install --upgrade pip
25- pip install -r requirements.txt
26- pip install wheel
27+ pip install .[test]
28+ pip install build twine
2729
2830 - name : Build Graph
2931 run : |
@@ -37,17 +39,32 @@ jobs:
3739 cp tn/*.fst graph
3840 cp itn/*.fst graph
3941
42+ - name : Get version from setuptools_scm
43+ id : scm_version
44+ run : |
45+ # Check if version is provided as input
46+ if [ -n "${{ github.event.inputs.version }}" ]; then
47+ echo "VERSION=${{ github.event.inputs.version }}" >> $GITHUB_OUTPUT
48+ else
49+ # Get version from setuptools_scm
50+ pip install setuptools_scm
51+ VERSION=$(python -m setuptools_scm | tail -1)
52+ echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
53+ fi
54+
4055 - name : Upload Graph
4156 uses : actions/upload-artifact@v3
4257 with :
43- name : release-graph-v${{ github.event.inputs.version }}
58+ name : release-graph-v${{ steps.scm_version.outputs.VERSION }}
4459 path : graph
4560
61+ - name : Build package
62+ run : |
63+ python -m build
64+
4665 - name : Publish on pypi.org
4766 env :
4867 TWINE_USERNAME : __token__
4968 TWINE_PASSWORD : ${{ secrets.PYPI_API_TOKEN }}
5069 run : |
51- python setup.py sdist bdist_wheel --version=${{ github.event.inputs.version}}
52- python -m pip install -U twine
53- python -m twine upload --repository-url https://upload.pypi.org/legacy/ dist/*
70+ python -m twine upload dist/*
0 commit comments