diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..b8dc74d --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,42 @@ +name: Publish Python Package + +on: + # trigger when publishing a release + release: + types: [published] + + # also allow triggering this workflow manually for testing + workflow_dispatch: + +jobs: + publish: + + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + # just fetching 1 commit is not enough for setuptools-scm, so we fetch all + fetch-depth: 0 + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: '3.x' + - name: Install dependencies + run: | + pip install setuptools setuptools_scm + - name: Build package + run: | + python setup.py sdist + rm dist/*.orig # clean sdist_upip noise + - name: Publish to Test PyPI + uses: pypa/gh-action-pypi-publish@release/v1 + with: + password: ${{ secrets.TEST_PYPI_API_TOKEN }} + repository_url: https://test.pypi.org/legacy/ + - name: Publish to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 + if: github.event.release.tag_name # only when releasing a new version + with: + password: ${{ secrets.PYPI_API_TOKEN }} diff --git a/setup.py b/setup.py index e16ceda..946cc0d 100644 --- a/setup.py +++ b/setup.py @@ -2,8 +2,6 @@ import sdist_upip from setuptools import setup -VERSION = "1.0.0" - def long_desc_from_readme(): with open('README.rst', 'r') as fd: @@ -20,7 +18,9 @@ def long_desc_from_readme(): setup( name="micropython-py-esp32-ulp", - version=VERSION, + use_scm_version={ + 'local_scheme': 'no-local-version', + }, description="Assembler toolchain for the ESP32 ULP co-processor, written in MicroPython", long_description=long_desc_from_readme(), long_description_content_type='text/x-rst', @@ -34,6 +34,7 @@ def long_desc_from_readme(): 'License :: OSI Approved :: MIT License', 'Programming Language :: Python :: Implementation :: MicroPython', ], + setup_requires=['setuptools_scm'], platforms=["esp32", "linux", "darwin"], cmdclass={"sdist": sdist_upip.sdist}, packages=["esp32_ulp"],