Skip to content

Commit

Permalink
Check python package when we don't publish it
Browse files Browse the repository at this point in the history
  • Loading branch information
sbrunner committed Dec 6, 2020
1 parent 8bb22f7 commit 298a9ff
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 6 deletions.
13 changes: 9 additions & 4 deletions c2cciutils/publish.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@
import sys


def pip(config, version, version_type):
def pip(config, version, version_type, publish):
"""
Publish to pypi
version_type: Describe the kind of release we do: rebuild (specified using --type), version_tag,
version_branch, feature_branch, feature_tag (for pull request)
publish: If False only check the package
config is like:
packages:
- path: . # the root foder of the package
Expand Down Expand Up @@ -45,9 +46,13 @@ def pip(config, version, version_type):
subprocess.check_call(
["python3", "./setup.py", "egg_info", "--no-date", "bdist_wheel"], cwd=cwd, env=env
)
subprocess.check_call(
["twine", "upload", "--verbose", "--disable-progress-bar"] + glob.glob("dist/*.whl"), cwd=cwd
)
pkg_publish = publish
if "versions" in pkg:
pkg_publish &= version_type in pkg["versions"]
cmd = ["twine"]
cmd += ["upload", "--verbose", "--disable-progress-bar"] if pkg_publish else ["check"]
cmd += glob.glob(os.path.join(cwd, "dist/*.whl"))
subprocess.check_call(cmd)
print("::endgroup::")
except subprocess.CalledProcessError as exception:
print("Error: {}".format(exception))
Expand Down
5 changes: 3 additions & 2 deletions c2cciutils/scripts/publish.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,9 @@ def main() -> None:

success = True
pypi_config = config.get("publish", {}).get("pypi", {})
if version_type in pypi_config.get("versions", []):
success &= c2cciutils.publish.pip(pypi_config, version, version_type)
success &= c2cciutils.publish.pip(
pypi_config, version, version_type, version_type in pypi_config.get("versions", [])
)

docker_config = config.get("publish", {}).get("docker", {})

Expand Down
4 changes: 4 additions & 0 deletions ci/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ audit:

publish:
pypi:
packages:
- path: .
- path: test/pkg
versions: []
versions:
- version_tag
- version_branch
6 changes: 6 additions & 0 deletions test/pkg/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from setuptools import setup

setup(
name="test",
version="1.0.0",
)

0 comments on commit 298a9ff

Please sign in to comment.