-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🔨🔧 add invoke tasks to tox CI/CD setup for self-hosted publishing.
Signed-off-by: rjdbcm <[email protected]>
- Loading branch information
Showing
3 changed files
with
65 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
from __future__ import annotations | ||
|
||
import sys | ||
from pathlib import Path | ||
|
||
from invoke.context import Context | ||
from invoke.tasks import call | ||
from invoke.tasks import task | ||
|
||
|
||
@task | ||
def sign_log(c: Context, suite: str | None = None) -> None: | ||
banned = './' | ||
if not suite: | ||
return print('No suite target provided', file=sys.stderr) | ||
if any(i in suite for i in banned): | ||
return print(f'Invalid sign target suite: {suite}', file=sys.stderr) | ||
log = Path(f'.tox/{suite}/tmp/meson-logs/testlog-{suite}.txt') # noqa: S108 | ||
if log.exists(): | ||
c.run(f'sigstore sign --output-dir=sig {log}') | ||
else: | ||
print(f'Log not found for {suite}.', file=sys.stderr) | ||
|
||
|
||
@task(pre=[call(sign_log, suite='dist'), call(sign_log, suite='test'), call(sign_log, suite='lint')]) # pyright: ignore | ||
def release(c: Context, sdist: bool = False) -> None: | ||
"""Create release wheels for the current interpreter. | ||
:param c: invoke context | ||
:type c: Context | ||
:param sdist: create source distribution tarball, defaults to False | ||
:type sdist: bool, optional | ||
""" | ||
draft = c.run('psr --noop version') | ||
if draft and draft.exited != 0: | ||
return print('No release drafted.', file=sys.stderr) | ||
if sdist: | ||
c.run('python -m build --sdist') | ||
c.run('sigstore sign dist/*.tar.gz') | ||
ext_wheel = c.run('cibuildwheel --output-dir dist .') | ||
if ext_wheel and ext_wheel.exited != 0: | ||
c.run('python -m build --wheel') | ||
c.run('sigstore sign --output-dir=sig dist/*.whl') | ||
|
||
|
||
@task(release) | ||
def provenance(c: Context) -> None: | ||
print('SLSA provenance currently unavailable in OZI self-hosted CI/CD', file=sys.stderr) | ||
|
||
@task(provenance) | ||
def publish(c: Context) -> None: | ||
"""Publishes a release tag""" | ||
c.run('psr publish') | ||
c.run('twine upload dist/*') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters