GitHub Release storage adapter for Peagen
Project description
Swarmauri GitHub Release Storage Adapter
Stores and retrieves artifacts as assets on a GitHub release. The adapter is designed to plug directly into the Swarmauri/Peagen storage interfaces while still being usable as a standalone utility.
Features
- Automatic release management – a release is created on-demand when the requested tag does not already exist.
ghrel://addressing – the adapter exposes aroot_uriand returns fully-qualified URIs (e.g.ghrel://org/repo/tag/path) fromuploadcalls.- Prefix-aware paths – supply an optional
prefixto group related assets underneath a pseudo-directory on the release. - Bulk helpers – use
upload_diranddownload_dirto synchronise entire directories, oriter_prefixto discover stored assets. - Configuration friendly –
GithubReleaseStorageAdapter.from_urireads credentials from theGITHUB_TOKENenvironment variable for simple environment-driven configuration in workflows.
Requirements
- A GitHub personal access token (PAT) or GitHub App token with sufficient permissions to view, create and manage releases on the target repository.
- Network access to the GitHub REST API (provided by
PyGithub). - Python 3.10 through 3.12.
Installation
Install uv (optional)
curl -LsSf https://astral.sh/uv/install.sh | sh
Add the package with uv
uv add swarmauri_storage_github_release
Add with Poetry
poetry add swarmauri_storage_github_release
Install with pip
pip install swarmauri_storage_github_release
Usage
from io import BytesIO
from pydantic import SecretStr
from swarmauri_storage_github_release import GithubReleaseStorageAdapter
adapter = GithubReleaseStorageAdapter(
token=SecretStr("ghp_example-token"),
org="example-org",
repo="example-repo",
tag="v1.0.0",
prefix="artifacts",
release_name="Example release",
message="Artifacts published by our workflow.",
)
print(adapter.root_uri)
uri = adapter.upload("artifact.txt", BytesIO(b"important payload"))
downloaded_payload = adapter.download("artifact.txt").read()
assets = list(adapter.iter_prefix(""))
print(uri)
print(downloaded_payload)
print(assets)
The code above demonstrates:
SecretStrsupport for securely passing tokens.- Automatic release creation when the
v1.0.0tag does not exist. - Prefix-aware uploads that produce the URI
ghrel://example-org/example-repo/v1.0.0/artifacts/artifacts/artifact.txt(the asset key itself contains the prefix, so it appears in the base URI and the returned asset key). - Round-tripping an asset and enumerating stored keys via
iter_prefix.
Working with directories
Use the bulk helper methods to synchronise entire directory trees:
adapter.upload_dir("dist", prefix="binaries")
adapter.download_dir("binaries", "./downloads")
Both helpers respect the adapter-level prefix and will mirror nested folders.
Using ghrel:// URIs and configuration
The from_uri class method creates adapters from an address such as:
adapter = GithubReleaseStorageAdapter.from_uri(
"ghrel://example-org/example-repo/v1.0.0/artifacts",
)
When invoked this way the adapter builds an unauthenticated client
(token="").
Any prefix encoded in the URI is respected, and the resulting instance exposes the same API shown above. For private repositories or higher rate limits, instantiate the adapter directly and provide a token.
Controlling release metadata
The constructor accepts additional keyword arguments to fine tune release
creation, including release_name, message, draft, and prerelease. These
parameters map directly to GitHub's release settings, allowing you to reuse the
adapter for production, staging, or nightly build workflows.
Want to help?
If you want to contribute to swarmauri-sdk, read up on our guidelines for contributing that will help you get started.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file swarmauri_storage_github_release-0.3.0.dev24.tar.gz.
File metadata
- Download URL: swarmauri_storage_github_release-0.3.0.dev24.tar.gz
- Upload date:
- Size: 9.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.10.3 {"installer":{"name":"uv","version":"0.10.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
db6952e3b546859247e148c7ff34ad4d94a6c1848e1c8146087f60d86f80bef0
|
|
| MD5 |
7edf4c8de5b93e3012d679961911e109
|
|
| BLAKE2b-256 |
8a79baf786a234051c4e9abd5de281c93312c1cbdfdcf68a382d530e11e00758
|
File details
Details for the file swarmauri_storage_github_release-0.3.0.dev24-py3-none-any.whl.
File metadata
- Download URL: swarmauri_storage_github_release-0.3.0.dev24-py3-none-any.whl
- Upload date:
- Size: 10.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.10.3 {"installer":{"name":"uv","version":"0.10.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dfce4c32949ea06bc9709dcce76d6ac724403d4866378cdc909c1cb3bbe8187c
|
|
| MD5 |
956ff69644694fadcd2fc94d6fdf4c9d
|
|
| BLAKE2b-256 |
36afe5fc548e256e740b0837d247971dd0cff44ecb0a6ea5a3192e5e9146cf80
|