Skip to content

Commit

Permalink
Merge pull request #255 from a2i2/feature/release-ci
Browse files Browse the repository at this point in the history
FEATURE: Automate release of surround from Codefresh
  • Loading branch information
ucokzeko authored Dec 7, 2020
2 parents 24a8f9a + 365d755 commit 6cb4d08
Showing 1 changed file with 61 additions and 29 deletions.
90 changes: 61 additions & 29 deletions codefresh.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ steps:
stage: "clone"

test:
stage: "test"
type: parallel
steps:
test_lib:
Expand All @@ -41,7 +42,6 @@ steps:
- pip install pylint==2.4.3
- pylint setup.py
- find surround/ -iname "*.py" | xargs pylint
stage: "test"

test_cli:
title: "Test Surround CLI"
Expand All @@ -66,31 +66,63 @@ steps:
- cd ..
- find examples/ -iname "*.py" | xargs pylint
- ls examples/ | xargs -n 1 -I '{}' python3 examples/'{}'/main.py
stage: "test"

# TODO: Release on VERSION change
# release:
# title: "Release to Pypi"
# type: "freestyle" # Run any command
# image: "python:3.6.10" # The image in which command will be executed
# working_directory: "${{clone}}" # Running command where code cloned
# commands:
# # Install required packages
# - python3 -m pip install --user --upgrade setuptools wheel twine

# # Setup Pypi config
# - echo "[pypi]" > ~/.pypirc
# - echo "repository=https://upload.pypi.org/legacy/" >> ~/.pypirc
# - echo "username=${{PYPI_USERNAME}}" >> ~/.pypirc
# - echo "password=${{PYPI_PASSWORD}}" >> ~/.pypirc

# # Build package
# - VERSION_TAG=$(git tag -l --points-at HEAD) python3 setup.py sdist bdist_wheel

# # Upload package for distribution
# - python3 -m twine upload --repository pypi dist/*
# when:
# branch:
# only:
# - /([0-9]+)\.([0-9]+)\.([0-9]+)?$/
# stage: "release"

release:
stage: "release"
type: parallel
steps:
release_lib:
title: "Release surround lib to PYPI"
type: "freestyle"
image: "python:3.6.10" # The image in which command will be executed
working_directory: "${{clone}}" # Running command where code cloned
commands:
- cd surround

# Install required packages
- python3 -m pip install --user --upgrade setuptools wheel twine

# Setup Pypi config
- echo "[pypi]" > ~/.pypirc
- echo "repository=https://upload.pypi.org/legacy/" >> ~/.pypirc
- echo "username=${{PYPI_USERNAME}}" >> ~/.pypirc
- echo "password=${{PYPI_PASSWORD}}" >> ~/.pypirc

# Build package
- python3 setup.py sdist bdist_wheel

# Upload package for distribution
- python3 -m twine upload --repository pypi dist/*
when:
condition:
all:
isMainRepo: '"${{CF_REPO_OWNER}}" == "a2i2"'
isReleaseBranch: 'match("${{CF_BRANCH}}", "/surround-v([0-9]+)\.([0-9]+)\.([0-9]+)?$", false) == true'

release_cli:
title: "Release surround cli to PYPI"
type: "freestyle"
image: "python:3.6.10" # The image in which command will be executed
working_directory: "${{clone}}" # Running command where code cloned
commands:
- cd surround_cli

# Install required packages
- python3 -m pip install --user --upgrade setuptools wheel twine

# Setup Pypi config
- echo "[pypi]" > ~/.pypirc
- echo "repository=https://upload.pypi.org/legacy/" >> ~/.pypirc
- echo "username=${{PYPI_USERNAME}}" >> ~/.pypirc
- echo "password=${{PYPI_PASSWORD}}" >> ~/.pypirc

# Build package
- python3 setup.py sdist bdist_wheel

# Upload package for distribution
- python3 -m twine upload --repository pypi dist/*
when:
condition:
all:
isMainRepo: '"${{CF_REPO_OWNER}}" == "a2i2"'
isReleaseBranch: 'match("${{CF_BRANCH}}", "/surround-cli-v([0-9]+)\.([0-9]+)\.([0-9]+)?$", false) == true'

0 comments on commit 6cb4d08

Please sign in to comment.