Skip to content

Commit

Permalink
CI: Add release job (#25)
Browse files Browse the repository at this point in the history
  • Loading branch information
liranbg authored Feb 11, 2021
1 parent f13cfad commit 5aa07bf
Show file tree
Hide file tree
Showing 7 changed files with 128 additions and 18 deletions.
69 changes: 69 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: Release

on:
push:
tags:
- "v[0-9]+.[0-9]+.[0-9]+"
- "v[0-9]+.[0-9]+.[0-9]+-rc[0-9]+"

env:
PIPENV_PYTHON_VERSION: 3.7

jobs:
build-and-release:
name: Release
runs-on: ubuntu-latest
steps:
- name: Dump github context
run: echo "$GITHUB_CONTEXT"
env:
GITHUB_CONTEXT: ${{ toJson(github) }}

- name: Dump runner context
run: echo "$RUNNER_CONTEXT"
env:
RUNNER_CONTEXT: ${{ toJson(runner) }}

- uses: actions/checkout@v2

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: ${{ env.PIPENV_PYTHON_VERSION }}

- name: Set envs
run: |
VERSION_TAG=${GITHUB_REF#refs/tags/}
RC_RELEASE=false
if echo $VERSION_TAG | grep -qE ".*-rc[0-9]+"; then\
RC_RELEASE=true;\
fi
echo "NUCLIO_SDK_PY_VERSION=$VERSION_TAG" >> $GITHUB_ENV
echo "RC_RELEASE=$RC_RELEASE" >> $GITHUB_ENV
- name: Install dependencies
run: |
python -m pip install --upgrade pip
make install_pipenv
- name: Build
run: |
make build
- name: Release Test-PyPI
uses: pypa/[email protected]
if: env.RC_RELEASE == 'true'
with:
user: __token__
skip_existing: true
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
repository_url: https://test.pypi.org/legacy/
verbose: true

- name: Release PyPI
uses: pypa/[email protected]
if: env.RC_RELEASE == 'false'
with:
user: __token__
password: ${{ secrets.DUMMY_TOKEN }}
verbose: true
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ nuclio_sdk.egg-info/
*.pyc
.idea
.github/act
VERSION
16 changes: 10 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
PIPENV_PYTHON_VERSION ?= 3.7

PIPENV_PYTHON_VERSION ?= 3.7
NUCLIO_SDK_PY_VERSION ?= $(shell git describe --tags --abbrev=0)

.PHONY: all
all:
$(error please pick a target)

.PHONY: upload
upload: clean build lint test
upload: ensure-version clean build lint test
python -m pipenv run upload

.PHONY: build
build:
build: ensure-version
python -m pipenv run build

.PHONY: clean
clean:
@rm -rf dist build nuclio_sdk.egg-info
@rm -rf VERSION dist build nuclio_sdk.egg-info

.PHONY: clean_pyc
clean_pyc:
Expand All @@ -39,7 +39,11 @@ test:
python -m pipenv run test

.PHONY: install_pipenv
install_pipenv:
install_pipenv: ensure-version
python -m pip install --user pipenv
python -m pipenv --python ${PIPENV_PYTHON_VERSION}
python -m pipenv install --dev

.PHONY: ensure-version
ensure-version:
@echo $(NUCLIO_SDK_PY_VERSION) | tee VERSION
6 changes: 4 additions & 2 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,14 @@ flake8 = "*"
twine = "*"
bleach = "==3.3.0"
black = "==20.8b1"
importlib_metadata = "*"
importlib_metadata = "<3"
build = ">0.2"

[scripts]
fmt = "black ."
build = "python setup.py sdist bdist_wheel"
build = "python -m build --sdist --wheel --outdir dist/"
test = "python -m unittest discover -s nuclio_sdk/test -p 'test_*.py' -v"
upload = "twine upload dist/*"
upload-test = "twine upload --repository testpypi dist/*"
lint = "black --check --diff ."
flake8 = "flake8 nuclio_sdk"
32 changes: 23 additions & 9 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# please keep this to a minimum - defaults are good
[tool.black]
exclude = '''
/(
\.git
| \.venv
| \venv
| \.run
| \.github
)/
'''
11 changes: 10 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,17 @@ def parse_deps():
deps.append("{}{}".format(dep, version))


def get_version():
with open("VERSION", "r") as f:
version = f.read().strip()
if version.startswith("v"):
version = version[1:]
return version


setup(
name="nuclio_sdk",
version="0.3.0",
version=get_version(),
description="Client for the Nuclio serverless platform",
long_description=open("README.md").read(),
long_description_content_type="text/markdown",
Expand All @@ -50,6 +58,7 @@ def parse_deps():
url="https://github.com/nuclio/nuclio-sdk-py",
packages=["nuclio_sdk", "nuclio_sdk.test"],
# install_requires=parse_deps(),
python_requires=">=3",
classifiers=[
"Development Status :: 4 - Beta",
"Intended Audience :: Developers",
Expand Down

0 comments on commit 5aa07bf

Please sign in to comment.