From 6625e55ae3437a1324ab7a88c3295404487931de Mon Sep 17 00:00:00 2001 From: Wilko Nienhaus Date: Sat, 20 Nov 2021 18:11:01 +0200 Subject: [PATCH 1/2] switch to using setuptools_scm to get version Disable appending local part to version because we're testing uploads to TestPyPI, and pypi does not support the local part in version numbers (see: https://github.com/pypa/setuptools_scm/#version-number-construction) --- setup.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) 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"], From aad344b6078db50cd9df74b97b08566bf84d730a Mon Sep 17 00:00:00 2001 From: Wilko Nienhaus Date: Sat, 20 Nov 2021 18:11:19 +0200 Subject: [PATCH 2/2] add workflow to publish to PyPI This workflow is triggered when publishing a new release using the GitHub Releases functionality. It can also be triggered manually for testing. The workflow will always publish to Test PyPI, but will only publish to the real PyPI, when releasing a new version using the GitHub Releases functionality. The version for the package is generated by setuptools_scm, based on the git tags/commits. For all non-tagged commits, a "dev version" is generated with the format "0.1.2-dev3", where 0.1.2 is the latest tag plus one more in the last part of the version number (i.e. given the last tag was 0.1.1, 0.1.2 will be used for the dev version) and the 3 in "-dev3" comes from the number of commits since the last tag. (This all is standard setuptools_scm behaviour.) --- .github/workflows/publish.yml | 42 +++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 .github/workflows/publish.yml 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 }}