stouputils.continuous_delivery.github module#
This module contains utilities for continuous delivery on GitHub.
upload_to_github: Upload the project to GitHub using the credentials and the configuration (make a release and upload the assets, handle existing tag, generate changelog, etc.)
- validate_github_credentials(
- credentials: dict[str, dict[str, str]],
Get and validate GitHub credentials.
- Parameters:
credentials – Credentials dictionary with ‘github’ key containing ‘api_key’ and ‘username’
- Returns:
(owner username, headers dict)
- Return type:
tuple
- Raises:
ValueError – If required keys are missing
- validate_github_config(
- github_config: dict[str, Any],
Validate GitHub configuration.
- Parameters:
github_config – Configuration dictionary
- Returns:
(project_name, version, build_folder, endswith list)
- Return type:
tuple
- Raises:
ValueError – If required keys are missing
- build_github_config(
- owner: str,
- headers: dict[str, str],
- project_name: str,
- version: str,
- build_folder: str,
- endswith: list[str],
- api_url: str,
Build a PlatformConfig for GitHub.
- Parameters:
owner – GitHub username
headers – HTTP headers with authorization
project_name – Name of the repository
version – Version to release
build_folder – Path to build assets
endswith – File suffixes to upload
api_url – GitHub API URL
- Returns:
Configuration for GitHub release
- Return type:
- delete_github_release(
- config: PlatformConfig,
Delete existing GitHub release for the configured version.
- delete_github_tag(
- config: PlatformConfig,
Delete existing GitHub tag for the configured version.
- get_github_commit_date(
- commit: dict[str, Any],
Extract date from a GitHub commit response.
- extract_github_commit_data(
- commits: list[dict[str, Any]],
Extract (sha, message) tuples from GitHub commits.
- create_github_tag(
- config: PlatformConfig,
Create a new tag on GitHub.
- create_github_release(
- config: PlatformConfig,
- changelog: str,
Create a new GitHub release and return its ID.
- Parameters:
config – Platform configuration
changelog – Changelog text for the release body
- Returns:
Release ID for asset uploads
- Return type:
int
- upload_github_assets(
- config: PlatformConfig,
- release_id: int,
Upload release assets to GitHub.
- Parameters:
config – Platform configuration
release_id – ID of the release to upload assets to
- upload_to_github(
- credentials: dict[str, Any],
- github_config: dict[str, Any],
- api_url: str = 'https://api.github.com',
Upload the project to GitHub using the credentials and the configuration.
- Parameters:
credentials – Credentials for the GitHub API
github_config – Configuration for the GitHub project
api_url – GitHub API URL (default: https://api.github.com)
- Returns:
Generated changelog text
- Return type:
str
Examples:
> upload_to_github( credentials={ "github": { "api_key": "ghp_...", "username": "Stoupy" } }, github_config={ "project_name": "stouputils", "version": "1.0.0", "build_folder": "build", "endswith": [".zip"] } )