Skip to content

Commit

Permalink
1.10.1 - Refactor GitHub release task
Browse files Browse the repository at this point in the history
Also fixes a bug with python-build-once.
  • Loading branch information
vkottler committed Jul 13, 2023
1 parent 90824ca commit 42d53b4
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 22 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ jobs:
- run: |
mk python-release owner=vkottler \
repo=vmklib version=1.10.0
repo=vmklib version=1.10.1
if: |
matrix.python-version == '3.11'
&& matrix.system == 'ubuntu-latest'
Expand Down
3 changes: 3 additions & 0 deletions .pylintrc
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
[DESIGN]
max-args=6

[MESSAGES CONTROL]
disable=duplicate-code
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
=====================================
generator=datazen
version=3.1.2
hash=0bae505c06b01979c4276b236a95630b
hash=0c42310385e6f37f284556e25b419929
=====================================
-->

# vmklib ([1.10.0](https://pypi.org/project/vmklib/))
# vmklib ([1.10.1](https://pypi.org/project/vmklib/))

[![python](https://img.shields.io/pypi/pyversions/vmklib.svg)](https://pypi.org/project/vmklib/)
![Build Status](https://github.com/vkottler/vmklib/workflows/Python%20Package/badge.svg)
Expand Down
2 changes: 1 addition & 1 deletion local/variables/package.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
major: 1
minor: 10
patch: 0
patch: 1
entry: mk
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta:__legacy__"

[project]
name = "vmklib"
version = "1.10.0"
version = "1.10.1"
description = "Simplify project workflows by standardizing use of GNU Make."
readme = "README.md"
requires-python = ">=3.8"
Expand Down
4 changes: 2 additions & 2 deletions vmklib/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# =====================================
# generator=datazen
# version=3.1.2
# hash=0e50415f07e485c70acde31abb963f05
# hash=089d813c9238c490a893adefbd7ad945
# =====================================

"""
Expand All @@ -10,4 +10,4 @@

DESCRIPTION = "Simplify project workflows by standardizing use of GNU Make."
PKG_NAME = "vmklib"
VERSION = "1.10.0"
VERSION = "1.10.1"
4 changes: 2 additions & 2 deletions vmklib/tasks/python/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@

# internal
from vmklib.tasks.args import environ_fallback_split
from vmklib.tasks.mixins.concrete import ConcreteBuilderMixin
from vmklib.tasks.mixins.concrete import ConcreteOnceMixin
from vmklib.tasks.python import PREFIX


class PythonBuild(ConcreteBuilderMixin, SubprocessLogMixin):
class PythonBuild(ConcreteOnceMixin, SubprocessLogMixin):
"""Build a Python package."""

async def run(
Expand Down
39 changes: 26 additions & 13 deletions vmklib/tasks/release.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,15 @@ async def upload_release_asset(
)
return loads(result.stdout) # type: ignore

async def run(
async def release(
self,
inbox: Inbox,
outbox: Outbox,
*args,
**kwargs,
) -> bool: # pragma: nocover
"""Generate ninja configuration files."""
cwd: Path,
owner: str,
repo: str,
version: str,
dist: str = "dist",
) -> bool:
"""Create a release."""

# Check for API key in environment.
if "GITHUB_API_TOKEN" not in os.environ:
Expand All @@ -68,12 +69,7 @@ async def run(
# Set token header.
ensure_api_token(os.environ["GITHUB_API_TOKEN"])

cwd: Path = args[0]

# Ensure GitHub parameters are set.
owner = kwargs["owner"]
repo = kwargs["repo"]
version = kwargs["version"]
if not owner or not repo or not version:
return False

Expand All @@ -94,10 +90,27 @@ async def run(

# Use 'Upload a release asset' API to upload all files in the 'dist'
# directory to the new release.
for item in cwd.joinpath(kwargs.get("dist", "dist")).iterdir():
for item in cwd.joinpath(dist).iterdir():
result = await self.upload_release_asset(
owner, repo, release_id, item
)
self.log.info("Uploaded '%s'.", result["browser_download_url"])

return True

async def run(
self,
inbox: Inbox,
outbox: Outbox,
*args,
**kwargs,
) -> bool: # pragma: nocover
"""Generate ninja configuration files."""

return await self.release(
args[0],
kwargs["owner"],
kwargs["repo"],
kwargs["version"],
dist=kwargs.get("dist", "dist"),
)

0 comments on commit 42d53b4

Please sign in to comment.