Skip to main content

GitHub Release storage adapter for Peagen

Project description

Swarmauri Logo

PyPI - Downloads Hits PyPI - Python Version PyPI - License PyPI - swarmauri_storage_github_release


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 a root_uri and returns fully-qualified URIs (e.g. ghrel://org/repo/tag/path) from upload calls.
  • Prefix-aware paths – supply an optional prefix to group related assets underneath a pseudo-directory on the release.
  • Bulk helpers – use upload_dir and download_dir to synchronise entire directories, or iter_prefix to discover stored assets.
  • Configuration friendlyGithubReleaseStorageAdapter.from_uri reads credentials from the GITHUB_TOKEN environment 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:

  • SecretStr support for securely passing tokens.
  • Automatic release creation when the v1.0.0 tag 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


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

If you're not sure about the file name format, learn more about wheel file names.

File details

Details for the file swarmauri_storage_github_release-0.3.0.dev25.tar.gz.

File metadata

  • Download URL: swarmauri_storage_github_release-0.3.0.dev25.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

Hashes for swarmauri_storage_github_release-0.3.0.dev25.tar.gz
Algorithm Hash digest
SHA256 8c0104c9ff0817251f2bfa3cc7389d7c90cb20692f8dcddea5ad8de6112323ab
MD5 6762c989724a3c8a910ddebb85294ce9
BLAKE2b-256 3528b989178ef10bd474c1d76e340c15d76791b9621d1bfeabc645f942f6e5c1

See more details on using hashes here.

File details

Details for the file swarmauri_storage_github_release-0.3.0.dev25-py3-none-any.whl.

File metadata

  • Download URL: swarmauri_storage_github_release-0.3.0.dev25-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

Hashes for swarmauri_storage_github_release-0.3.0.dev25-py3-none-any.whl
Algorithm Hash digest
SHA256 9cca4003897d6c540ab0ba211c6b701776f61b8f04f121309b533a9261b2d76c
MD5 0ae63e42dd2bb105a0486892df5e70dc
BLAKE2b-256 c6f6d892039b0ef4d0a69ac999076a869b5d0debcabcf807e7ee916baa0cf404

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page