Skip to content

Commit

Permalink
Add PyPi release action (#42)
Browse files Browse the repository at this point in the history
* add python 3.12

* update test versions

* add release connection and update instructions
  • Loading branch information
nllong authored Jun 12, 2024
1 parent 0abdb34 commit cc93e60
Show file tree
Hide file tree
Showing 7 changed files with 80 additions and 28 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest]
python-version: [3.9, 3.10.9]
python-version: [3.9, 3.10.9, 3.12]
test_env: [python, precommit, mypy]
runs-on: ubuntu-latest
steps:
Expand Down
55 changes: 55 additions & 0 deletions .github/workflows/pypi_release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: PyPIRelease
# https://packaging.python.org/en/latest/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/

on:
release:
types: [published]

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.12

- name: Install pypa/build
run: >-
python3 -m
pip install
build
--user
- name: Build a binary wheel and a source tarball
run: python3 -m build

- name: Store the distribution packages
uses: actions/upload-artifact@v4
with:
name: python-package-distributions
path: dist/

release:
name: >-
Publish Python 🐍 distribution 📦 to PyPI
needs:
- build
runs-on: ubuntu-latest
environment:
name: pypi_release
url: https://pypi.org/p/py-SEED
permissions:
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing

steps:
- name: Download all the dists
uses: actions/download-artifact@v4
with:
name: python-package-distributions
path: dist/
- name: Publish distribution 📦 to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
26 changes: 11 additions & 15 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
py-SEED
===========


.. image:: https://github.com/seed-platform/py-seed/actions/workflows/ci.yml/badge.svg?branch=develop
:target: https://github.com/seed-platform/py-seed/actions/workflows/ci.yml/badge.svg

Expand Down Expand Up @@ -74,6 +73,7 @@ Low-Level Documentation
-----------------------
This client has access to the lower level API client by accessing `seed_client_base.SEEDOAuthReadOnlyClient`, `seed_client_base.SEEDOAuthReadWriteClient`, `seed_client_base.SEEDReadOnlyClient`, and `seed_client_base.SEEDReadWriteClient`. This provides two user authentication based Python clients and two authentication methods, basic and `OAuth2 <https://github.com/GreenBuildingRegistry/jwt_oauth2>`_. More information on authentication can be seen in the following py-SEED classes:

.. code-block:: bash
SEEDOAuthReadOnlyClient
SEEDOAuthReadWriteClient
Expand Down Expand Up @@ -107,10 +107,10 @@ Tests can be run via the `pytest` command.

You will need to export environment variables for a test portfolio manager account to test integration. Environment variables should be named:

..code-block:: bash
.. code-block:: bash
SEED_PM_UN
SEED_PM_PW
SEED_PM_UN
SEED_PM_PW
SEED Platform
Expand All @@ -126,16 +126,12 @@ Full details in LICENSE file.
Releasing
---------

* Configure your PyPi with token access `https://pypi.org/manage/account/token/ <https://pypi.org/manage/account/token/>`_.
* Merge down to main
* Tag release on GitHub and add in the change log
* Release via command line
This project is configured with GitHub Actions to automatically release to PyPi when a new tag is created. To release a new version:

.. code-block:: bash
* Create a branch with the prepared release change log
* Merge branch to develop, and open PR to main
* Once deployed to main, create a new tag in GitHub against main and copy the change log notes into the tag description
* GitHub Actions will automatically prepare the release the new version to PyPi
* Go to GitHub actions to approve the release

rm -rf dist
python setup.py sdist
pip install twine
# make sure to check the dist package for errors in the RST files
twine check dist/*
twine upload --repository py-seed dist/*
The GitHub Action required updates to the GitHub repo to only release on tags (https://github.com/SEED-platform/py-seed/settings/environments) after approval and on PyPi to add an authorized publisher (https://pypi.org/manage/project/py-SEED/settings/publishing/).
4 changes: 2 additions & 2 deletions pyseed/seed_client_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,11 +242,11 @@ def _check_response(self, response, *args, **kwargs):
elif status_field == 'success':
# continue
error = False
elif 'success' in response.json().keys():
elif 'success' in response.json():
success_flag = response.json().get('success', None)
# For file uploads the response key is 'success'
error = not success_flag
elif 'progress_data' in response.json().keys():
elif 'progress_data' in response.json():
# this is a system matching response, which is okay. return the success flag of this
status_flag = response.json()['progress_data'].get('status', None)
error = status_flag not in ['not-started', 'success', 'parsing']
Expand Down
18 changes: 9 additions & 9 deletions requirements-test.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
-r requirements.txt
flake8==4.0.1
mock==4.0.3
flake8==7.0.0
mock==5.1.0
mypy==1.10.0
pre-commit==2.19.0
pytest==7.1.2
pytest-cov==3.0.0
pytest-order==1.0.1
pytest-xdist==2.5.0
testfixtures>=5.1.1
tox==3.25.0
pre-commit==3.7.1
pytest==8.2.2
pytest-cov==5.0.0
pytest-order==1.2.1
pytest-xdist==3.6.1
testfixtures>=8.3.0
tox==4.15.1
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
openpyxl==3.1.2
requests>=2.28.0
typing==3.6.1
typing==3.7.4.3
1 change: 1 addition & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ classifiers =
Programming Language :: Python :: 3.9
Programming Language :: Python :: 3.10
Programming Language :: Python :: 3.11
Programming Language :: Python :: 3.12

[options]
packages = find:
Expand Down

0 comments on commit cc93e60

Please sign in to comment.