diff --git a/.github/workflows/python-app.yml b/.github/workflows/python-app.yml index 92077799..d4a4670a 100644 --- a/.github/workflows/python-app.yml +++ b/.github/workflows/python-app.yml @@ -11,22 +11,17 @@ on: jobs: build: - runs-on: ubuntu-latest - # strategy: - # # You can use PyPy versions in python-version. - # # For example, pypy2.7 and pypy3.9 - # matrix: - # python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"] - + strategy: + matrix: + python-version: ["3.8", "3.9"] steps: - uses: actions/checkout@v2 - - name: Set up Python 3.8 + - name: Set up Python uses: actions/setup-python@v2 with: - python-version: 3.8 - # python-version: ${{ matrix.python-version }} - # cache: 'pip' + python-version: ${{ matrix.python-version }} + cache: 'pip' - name: Display Python version run: python -c "import sys; print(sys.version)" - name: Install dependencies @@ -51,9 +46,3 @@ jobs: with: name: scdata-pkg path: dist - - name: Publish package - if: github.repository == 'fablabbcn/smartcitizen-data' && github.event_name == 'push' && startsWith(github.ref, 'refs/tags') - uses: pypa/gh-action-pypi-publish@master - with: - user: oscgonfer - password: ${{ secrets.PYPI_API_TOKEN }} diff --git a/.github/workflows/python-publish.yml b/.github/workflows/python-publish.yml new file mode 100644 index 00000000..96992efd --- /dev/null +++ b/.github/workflows/python-publish.yml @@ -0,0 +1,54 @@ +# This workflow will install Python dependencies, run tests and lint with a single version of Python +# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions + +name: Python Publish + +on: + push: + branches: [ "master" ] + tags: + - '*' + +jobs: + pypi-publish: + name: Upload release to PyPI + runs-on: ubuntu-latest + environment: + name: pypi + url: https://pypi.org/p/scdata + permissions: + id-token: write + steps: + - uses: actions/checkout@v2 + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: 3.8 + cache: 'pip' + - name: Display Python version + run: python -c "import sys; print(sys.version)" + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install flake8 pytest + pip install . + - name: Lint with flake8 + run: | + # stop the build if there are Python syntax errors or undefined names + # flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics + # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide + flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics + - name: Test with pytest + run: | + pytest + - name: Build package + run: | + python setup.py sdist bdist_wheel + - name: Archive artifacts + uses: actions/upload-artifact@v1 + with: + name: scdata-pkg + path: dist + - name: Publish package distributions to PyPI + if: github.repository == 'fablabbcn/smartcitizen-data' && github.ref == 'refs/heads/master' && job.status == 'success' + uses: pypa/gh-action-pypi-publish@release/v1 \ No newline at end of file diff --git a/.gitignore b/.gitignore index 401ec3a9..bf5de1c5 100644 --- a/.gitignore +++ b/.gitignore @@ -11,6 +11,8 @@ notebooks/*/ work working_tasks notebooks/working_*.ipynb +wip*.ipynb +Untitled*.ipynb notebooks/00_done wip*.py notebooks/wip*.* diff --git a/Makefile b/Makefile index 274c07e2..1e95bb33 100644 --- a/Makefile +++ b/Makefile @@ -5,15 +5,16 @@ all: package test: pytest -package: +clean: rm -rf dist/* rm -rf build/* - python setup.py sdist bdist_wheel -release: package - git tag -a v$(python setup.py --version) - twine upload dist/* +package: clean + git add -p setup.py scdata/__init__.py + RELEASE=$(python setup.py --version) && git commit -m "Version $RELEASE" && git tag -a v$RELEASE -m "Version $RELEASE" + python setup.py sdist bdist_wheel -clean: - rm dist/* - rm -rf build/* \ No newline at end of file +release: + # Still testing + git push + git push --tags