From efcb11c29b7289beb3a856c07e3e935f81af02ec Mon Sep 17 00:00:00 2001 From: Ghislain Vieilledent Date: Tue, 19 Dec 2023 10:56:55 +1100 Subject: [PATCH] Use one action for PyPI and TestPyPI --- .github/workflows/{lint.yaml => lint.yml} | 0 .github/workflows/wheel-pypi.yml | 37 +++++++--- .github/workflows/wheel-testpypi.yml | 86 ----------------------- setup.py | 2 +- 4 files changed, 29 insertions(+), 96 deletions(-) rename .github/workflows/{lint.yaml => lint.yml} (100%) delete mode 100644 .github/workflows/wheel-testpypi.yml diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yml similarity index 100% rename from .github/workflows/lint.yaml rename to .github/workflows/lint.yml diff --git a/.github/workflows/wheel-pypi.yml b/.github/workflows/wheel-pypi.yml index e14871e..dc7f3e9 100644 --- a/.github/workflows/wheel-pypi.yml +++ b/.github/workflows/wheel-pypi.yml @@ -1,17 +1,19 @@ -## Build wheel and upload to PyPI +## Build wheel and upload to TestPyPI (!! not PyPI !!) ## https://github.com/joerick/cibuildwheel/blob/master/examples/github-deploy.yml ## https://scikit-hep.org/developer/gha_wheels -name: Build wheel and upload to PyPI - -# When new version on master branch +name: Build wheel and upload to PyPI or TestPyPI + +# When push on branch dev on: push: - branches: - - master tags: - "v*" +env: + CONFIGURATIONS_FOLDER: .github/label-configuration-files + CONFIGURATIONS_ARTIFACT: label-configuration-files + jobs: build_wheels: name: Build wheels on ${{ matrix.os }} @@ -48,7 +50,7 @@ jobs: - uses: actions/setup-python@v5 name: Install Python with: - python-version: '3.11' + python-version: "3.11" - name: Install Python dependencies run: | python3 -m pip install --upgrade pip setuptools wheel @@ -60,8 +62,8 @@ jobs: path: dist/*.tar.gz upload_pypi: - # upload to PyPI on every tag starting with 'v' - # if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/v') + # Upload to PyPI for master branch + if: github.ref == "refs/heads/master" name: Upload to PyPI needs: [build_wheels, build_sdist] runs-on: ubuntu-latest @@ -75,4 +77,21 @@ jobs: user: __token__ password: ${{ secrets.pypi_password }} + upload_testpypi: + # Upload to TestPyPI for dev branch + if: github.ref == "refs/heads/dev" + name: Upload to TestPyPI + needs: [build_wheels, build_sdist] + runs-on: ubuntu-latest + steps: + - uses: actions/download-artifact@v3 + with: + name: artifact + path: dist + - uses: pypa/gh-action-pypi-publish@release/v1 + with: + user: __token__ + password: ${{ secrets.testpypi_password }} + repository_url: https://test.pypi.org/legacy/ + # End diff --git a/.github/workflows/wheel-testpypi.yml b/.github/workflows/wheel-testpypi.yml deleted file mode 100644 index 0d7d1ff..0000000 --- a/.github/workflows/wheel-testpypi.yml +++ /dev/null @@ -1,86 +0,0 @@ -## Build wheel and upload to TestPyPI (!! not PyPI !!) -## https://github.com/joerick/cibuildwheel/blob/master/examples/github-deploy.yml -## https://scikit-hep.org/developer/gha_wheels - -name: Build wheel and upload to TestPyPI - -# When push on branch dev -on: - push: - branches: - - dev - tags: - - "v*" - -env: - CONFIGURATIONS_FOLDER: .github/label-configuration-files - CONFIGURATIONS_ARTIFACT: label-configuration-files - -jobs: - build_wheels: - name: Build wheels on ${{ matrix.os }} - runs-on: ${{ matrix.os }} - strategy: - matrix: - os: [ubuntu-latest, windows-latest, macos-latest] - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-python@v5 - name: Install Python - with: - python-version: '3.11' - - name: Install NumPy and cibuildwheel - run: | - python3 -m pip install --upgrade pip - python3 -m pip install cibuildwheel==2.16.2 - - name: Build wheels - run: | - python3 -m cibuildwheel --output-dir wheelhouse - env: - CIBW_BUILD: cp311-* - CIBW_SKIP: pp* - CIBW_BEFORE_BUILD: pip install numpy - - uses: actions/upload-artifact@v3 - with: - path: ./wheelhouse/*.whl - - build_sdist: - name: Build source distribution - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-python@v5 - name: Install Python - with: - python-version: '3.11' - - name: Install Python dependencies - run: | - python3 -m pip install --upgrade pip setuptools wheel - python3 -m pip install numpy - - name: Build sdist - run: python setup.py sdist - - uses: actions/upload-artifact@v3 - with: - path: dist/*.tar.gz - - upload_pypi: - # if: startsWith(github.event.ref, 'refs/tags/v') - # upload to PyPI on every tag starting with 'v' - # if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/v') - # alternatively, to publish when a GitHub Release is created, use the following rule: - # if: github.event_name == 'release' && github.event.action == 'published' - name: Upload to PyPI - needs: [build_wheels, build_sdist] - runs-on: ubuntu-latest - steps: - - uses: actions/download-artifact@v3 - with: - name: artifact - path: dist - - uses: pypa/gh-action-pypi-publish@release/v1 - with: - user: __token__ - password: ${{ secrets.testpypi_password }} - repository_url: https://test.pypi.org/legacy/ - -# End diff --git a/setup.py b/setup.py index c55f378..27a92f1 100644 --- a/setup.py +++ b/setup.py @@ -58,7 +58,7 @@ def find_version(): long_description_content_type="text/x-rst", classifiers=[ "Development Status :: 4 - Beta", - "License :: OSI Approved :: GNU General Public License v3", + "License :: OSI Approved :: GNU General Public License v3 (GPLv3)", "Programming Language :: Python :: 2", "Programming Language :: Python :: 3", "Operating System :: OS Independent",