Skip to content

Commit

Permalink
Add python-publish and python-app workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
oscgonfer committed Oct 5, 2023
1 parent 6b07192 commit 2b3de1e
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 25 deletions.
23 changes: 6 additions & 17 deletions .github/workflows/python-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 }}
54 changes: 54 additions & 0 deletions .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
@@ -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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ notebooks/*/
work
working_tasks
notebooks/working_*.ipynb
wip*.ipynb
Untitled*.ipynb
notebooks/00_done
wip*.py
notebooks/wip*.*
Expand Down
17 changes: 9 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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/*
release:
# Still testing
git push
git push --tags

0 comments on commit 2b3de1e

Please sign in to comment.