Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix publish #1064

Merged
merged 2 commits into from
Jul 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ dependencies = [
"flake8",
"flake8-pyproject",
"reactpy-flake8 >=0.7",
# types
"mypy",
"types-toml",
# publish
"semver >=2, <3",
"twine",
Expand All @@ -42,7 +45,15 @@ test-docs = "invoke test-docs"
target-version = ["py39"]
line-length = 88

# --- Flake8 ----------------------------------------------------------------------------
# --- MyPy -----------------------------------------------------------------------------

[tool.mypy]
ignore_missing_imports = true
warn_unused_configs = true
warn_redundant_casts = true
warn_unused_ignores = true

# --- Flake8 ---------------------------------------------------------------------------

[tool.flake8]
select = ["RPY"] # only need to check with reactpy-flake8
Expand Down
18 changes: 15 additions & 3 deletions tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from invoke import task
from invoke.context import Context
from invoke.exceptions import Exit
from invoke.runners import Result

# --- Typing Preamble ------------------------------------------------------------------

Expand Down Expand Up @@ -286,7 +287,9 @@ def get_packages(context: Context) -> dict[str, PackageInfo]:

def make_py_pkg_info(context: Context, pkg_dir: Path) -> PackageInfo:
with context.cd(pkg_dir):
proj_metadata = json.loads(context.run("hatch project metadata").stdout)
proj_metadata = json.loads(
ensure_result(context, "hatch project metadata").stdout
)
return PackageInfo(
name=proj_metadata["name"],
path=pkg_dir,
Expand Down Expand Up @@ -329,7 +332,9 @@ def get_current_tags(context: Context) -> set[str]:
line
for line in map(
str.strip,
context.run("git tag --points-at HEAD", hide=True).stdout.splitlines(),
ensure_result(
context, "git tag --points-at HEAD", hide=True
).stdout.splitlines(),
)
if line
}
Expand Down Expand Up @@ -418,7 +423,7 @@ def publish(dry_run: bool):

context.run(
"twine upload dist/*",
env_dict={
env={
"TWINE_USERNAME": twine_username,
"TWINE_PASSWORD": twine_password,
},
Expand All @@ -444,3 +449,10 @@ def install_poetry_project(context: Context, path: Path) -> None:
]
context.run("pip install -e .")
context.run(f"pip install {' '.join(packages_to_install)}")


def ensure_result(context: Context, *args: Any, **kwargs: Any) -> Result:
result = context.run(*args, **kwargs)
if result is None:
raise Exit("Command failed")
return result