Skip to content

Commit

Permalink
Dynamically update lib version and publish all plugins (flyteorg#364)
Browse files Browse the repository at this point in the history
Automatically publishes to pypi when a release is created. Removes the need to update any versions embedded in the files (init and setup.py) for the core library as well as plugins.
  • Loading branch information
EngHabu authored Feb 5, 2021
1 parent 1e9276a commit dea197e
Show file tree
Hide file tree
Showing 12 changed files with 88 additions and 27 deletions.
55 changes: 38 additions & 17 deletions .github/workflows/pythonpublish.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Upload Python Package
name: Publish Python Package

on:
release:
Expand All @@ -8,19 +8,40 @@ jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v1
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine
- name: Build and publish
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
python setup.py sdist bdist_wheel
twine upload dist/*
- uses: actions/checkout@v2
with:
fetch-depth: "0"
- name: Set up Python
uses: actions/setup-python@v1
with:
python-version: "3.x"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine
- name: Autobump version
run: |
# from refs/tags/v1.2.3 get 1.2.3
VERSION=$(echo $GITHUB_REF | sed 's#.*/v##')
VERSION=$VERSION make update_version
shell: bash
- name: Build and publish
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
python setup.py sdist bdist_wheel
twine upload dist/*
- name: Autobump plugin version
run: |
# from refs/tags/v1.2.3 get 1.2.3
VERSION=$(echo $GITHUB_REF | sed 's#.*/v##')
VERSION=$VERSION make -C plugins update_all_versions
shell: bash
- name: Build all Plugins and publish
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
make -C plugins build_all_plugins
make -C plugins publish_all_plugins
12 changes: 12 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,15 @@ requirements: requirements.txt dev-requirements.txt requirements-spark3.txt ## C
coverage:
coverage run -m pytest tests/flytekit/unit/core flytekit/types plugins/tests
coverage report -m --include="flytekit/core/*,flytekit/types/*,plugins/*"

PLACEHOLDER := "__version__\ =\ \"develop\""

.PHONY: update_version
update_version:
# ensure the placeholder is there. If grep doesn't find the placeholder
# it exits with exit code 1 and github actions aborts the build.
grep "$(PLACEHOLDER)" "flytekit/__init__.py"
sed -i "s/$(PLACEHOLDER)/__version__ = \"${VERSION}\"/g" "flytekit/__init__.py"

grep "$(PLACEHOLDER)" "setup.py"
sed -i "s/$(PLACEHOLDER)/__version__ = \"${VERSION}\"/g" "setup.py"
2 changes: 1 addition & 1 deletion flytekit/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from flytekit.core.workflow import WorkflowFailurePolicy, reference_workflow, workflow
from flytekit.loggers import logger

__version__ = "0.16.0b6"
__version__ = "develop"


def current_context() -> ExecutionParameters:
Expand Down
15 changes: 14 additions & 1 deletion plugins/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,18 @@ install-all-dev:

.PHONY: build_all_plugins
build_all_plugins:
run_all_plugins.sh python setup.py sdist bdist_wheel
./run_all_plugins.sh python setup.py sdist bdist_wheel

.PHONY: publish_all_plugins
publish_all_plugins:
twine upload */dist/*

PLACEHOLDER := "__version__\ =\ \"develop\""
VERSION_FILE := "setup.py"

.PHONY: update_all_versions
update_all_versions:
# ensure the placeholder is there. If grep doesn't find the placeholder
# it exits with exit code 1 and github actions aborts the build.
./run_all_plugins.sh grep "$(PLACEHOLDER)" "$(VERSION_FILE)"
./run_all_plugins.sh sed -i "s/$(PLACEHOLDER)/__version__ = \"${VERSION}\"/g" $(VERSION_FILE)
4 changes: 3 additions & 1 deletion plugins/awssagemaker/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@

plugin_requires = ["flytekit>=0.16.0b0,<1.0.0", "sagemaker-training>=3.6.2,<4.0.0"]

__version__ = "develop"

# TODO: move sagemaker install script here.
setup(
name=microlib_name,
version="0.1.1",
version=__version__,
author="flyteorg",
author_email="[email protected]",
description="AWS Plugins for flytekit",
Expand Down
4 changes: 3 additions & 1 deletion plugins/hive/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@

plugin_requires = ["flytekit>=0.16.0b0,<1.0.0"]

__version__ = "develop"

setup(
name=microlib_name,
version="0.1.1",
version=__version__,
author="flyteorg",
author_email="[email protected]",
description="This package holds Hive plugins for flytekit",
Expand Down
4 changes: 3 additions & 1 deletion plugins/kfpytorch/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@

plugin_requires = ["flytekit>=0.16.0b0,<1.0.0"]

__version__ = "develop"

setup(
name=microlib_name,
version="0.1.1",
version=__version__,
author="flyteorg",
author_email="[email protected]",
description="K8s based Pytorch plugin for Flytekit",
Expand Down
4 changes: 3 additions & 1 deletion plugins/kftensorflow/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@
# TODO: Requirements are missing, add them back in later.
plugin_requires = ["flytekit>=0.16.0b0,<1.0.0"]

__version__ = "develop"

setup(
name=microlib_name,
version="0.1.1",
version=__version__,
author="flyteorg",
author_email="[email protected]",
description="K8s based Tensorflow plugin for flytekit",
Expand Down
4 changes: 3 additions & 1 deletion plugins/papermill/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@

plugin_requires = ["flytekit>=0.16.0b0,<1.0.0", "papermill>=1.2.0", "nbconvert>=6.0.7", "ipykernel>=5.0.0"]

__version__ = "develop"

setup(
name=microlib_name,
version="0.1.1",
version=__version__,
author="flyteorg",
author_email="[email protected]",
description="This is the flytekit papermill plugin",
Expand Down
4 changes: 3 additions & 1 deletion plugins/pod/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@

plugin_requires = ["flytekit>=0.16.0b0,<1.0.0", "k8s-proto>=0.0.3,<1.0.0"]

__version__ = "develop"

setup(
name=microlib_name,
version="0.1.1",
version=__version__,
author="flyteorg",
author_email="[email protected]",
description="Flytekit plugin to support K8s Pod tasks",
Expand Down
4 changes: 3 additions & 1 deletion plugins/spark/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@

plugin_requires = ["flytekit>=0.16.0b0,<1.0.0", "pyspark>=3.0.0"]

__version__ = "develop"

setup(
name=microlib_name,
version="0.1.1",
version=__version__,
author="flyteorg",
author_email="[email protected]",
description="Spark 3 plugin for flytekit",
Expand Down
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,11 @@
"all": spark3 + all_but_spark,
}

__version__ = "develop"

setup(
name="flytekit",
version="0.16.0b6",
version=__version__,
maintainer="Flyte Org",
maintainer_email="[email protected]",
packages=find_packages(exclude=["tests*"]),
Expand Down

0 comments on commit dea197e

Please sign in to comment.