Skip to content

Commit

Permalink
Add GitHub Actions workflow for automated PyPI deployment (#42)
Browse files Browse the repository at this point in the history
* Add missing dependency for Python 3.6
* Factor out package version to separate file
* Add workflow for publishing to PyPI on new release
  • Loading branch information
aksestok authored Sep 13, 2021
1 parent aeb66f4 commit 3ccc7e4
Show file tree
Hide file tree
Showing 4 changed files with 110 additions and 2 deletions.
86 changes: 86 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
name: Build, test and publish Python Package

on:
release:
types: [published]

env:
runner-os: ubuntu-latest

jobs:
build-package:
runs-on: ${{ env.runner-os }}

steps:
- uses: actions/checkout@v2

- name: Check git tag against package version and get python version
run: |
./check_package_version.sh
echo "::set-output name=VERSION::$(<.python-version)"
id: python-version

- uses: actions/setup-python@v2
with:
python-version: ${{ steps.python-version.outputs.VERSION }}

- name: Install dependencies and build package
run: |
pip install pipenv wheel
pipenv sync --system
./build.sh
- name: Cache build
uses: actions/cache@v2
with:
path: ./dist
key: build-cache

test-package:
needs: build-package
runs-on: ${{ env.runner-os }}
strategy:
matrix:
python-version: ["3.6", "3.7", "3.8", "3.9"]
fail-fast: true

steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}

- name: Recover cache
uses: actions/cache@v2
with:
path: ./dist
key: build-cache

- name: Install SDK from cache
run: |
PACKAGE=$(ls ./dist/ | grep -P .+\.whl$)
pip install ./dist/$PACKAGE
- name: Run unit tests
run: |
mkdir -p tests/exabel_data_sdk
cp -r ./exabel_data_sdk/tests ./tests/exabel_data_sdk/
cd ./tests/
python -m unittest discover -s ./exabel_data_sdk/tests
publish-package-to-pypi:
needs: test-package
runs-on: ${{ env.runner-os }}

steps:
- name: Recover cache
uses: actions/cache@v2
with:
path: ./dist
key: build-cache

- name: Publish package to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
1 change: 1 addition & 0 deletions VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.0.23
12 changes: 12 additions & 0 deletions check_package_version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/env bash

VERSION="v$(<VERSION)"
GIT_TAG=$(git describe --tags)

echo "Verifying current git tag is the same as version set in VERSION"
if [ $VERSION != $GIT_TAG ]; then
echo "Current git tag does not match version set in VERSION. Aborting build ..."
echo "GIT_TAG: $GIT_TAG"
echo "VERSION: $VERSION"
exit 1;
fi
13 changes: 11 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@
with open("README.md", "r", encoding="utf-8") as fh:
long_description = fh.read()

with open("VERSION", "r", encoding="utf-8") as fh:
version = fh.read()

setuptools.setup(
name="exabel-data-sdk",
version="0.0.22",
version=version,
author="Exabel",
author_email="[email protected]",
description="Python SDK for the Exabel Data API",
Expand All @@ -14,7 +17,13 @@
long_description_content_type="text/markdown",
url="https://github.com/Exabel/python-sdk",
packages=setuptools.find_packages(),
install_requires=["grpcio", "pandas", "protobuf", "requests"],
install_requires=[
'dataclasses == 0.8; python_version <= "3.6"',
"grpcio",
"pandas",
"protobuf",
"requests",
],
python_requires=">=3.6",
classifiers=[
"Development Status :: 4 - Beta",
Expand Down

0 comments on commit 3ccc7e4

Please sign in to comment.