semantic_release.hvcs module¶
HVCS
- class semantic_release.hvcs.Base[source]¶
Bases:
object
- class semantic_release.hvcs.Gitea[source]¶
Bases:
Base
Gitea helper class
- DEFAULT_API_PATH = '/api/v1'¶
- DEFAULT_DOMAIN = 'gitea.com'¶
- static auth() Optional[TokenAuth] [source]¶
Gitea token property
- Returns:
The Gitea token environment variable (GITEA_TOKEN) value
- static check_build_status(owner: str, repo: str, ref: str) bool [source]¶
Check build status
https://gitea.com/api/swagger#/repository/repoCreateStatus
- Parameters:
owner – The owner namespace of the repository
repo – The repository name
ref – The sha1 hash of the commit ref
- Returns:
Was the build status success?
- classmethod create_release(owner: str, repo: str, tag: str, changelog: str) bool [source]¶
Create a new release
https://gitea.com/api/swagger#/repository/repoCreateRelease
- Parameters:
owner – The owner namespace of the repository
repo – The repository name
tag – Tag to create release for
changelog – The release notes for this version
- Returns:
Whether the request succeeded
- classmethod edit_release(owner: str, repo: str, id: int, changelog: str) bool [source]¶
Edit a release with updated change notes
https://gitea.com/api/swagger#/repository/repoEditRelease
- Parameters:
owner – The owner namespace of the repository
repo – The repository name
id – ID of release to update
changelog – The release notes for this version
- Returns:
Whether the request succeeded
- classmethod get_release(owner: str, repo: str, tag: str) Optional[int] [source]¶
Get a release by its tag name
https://gitea.com/api/swagger#/repository/repoGetReleaseByTag
- Parameters:
owner – The owner namespace of the repository
repo – The repository name
tag – Tag to get release for
- Returns:
ID of found release
- classmethod post_release_changelog(owner: str, repo: str, version: str, changelog: str) bool [source]¶
Post release changelog
- Parameters:
owner – The owner namespace of the repository
repo – The repository name
version – The version number
changelog – The release notes for this version
- Returns:
The status of the request
- static token() Optional[str] [source]¶
Gitea token property
- Returns:
The Gitea token environment variable (GITEA_TOKEN) value
- classmethod upload_asset(owner: str, repo: str, release_id: int, file: str, label: str = None) bool [source]¶
Upload an asset to an existing release
https://gitea.com/api/swagger#/repository/repoCreateReleaseAttachment
- Parameters:
owner – The owner namespace of the repository
repo – The repository name
release_id – ID of the release to upload to
file – Path of the file to upload
label – Custom label for this file
- Returns:
The status of the request
- classmethod upload_dists(owner: str, repo: str, version: str, path: str) bool [source]¶
Upload distributions to a release
- Parameters:
owner – The owner namespace of the repository
repo – The repository name
version – Version to upload for
path – Path to the dist directory
- Returns:
The status of the request
- class semantic_release.hvcs.Github[source]¶
Bases:
Base
Github helper class
- DEFAULT_DOMAIN = 'github.com'¶
- static auth() Optional[TokenAuth] [source]¶
Github token property
- Returns:
The Github token environment variable (GH_TOKEN) value
- static check_build_status(owner: str, repo: str, ref: str) bool [source]¶
Check build status
https://docs.github.com/rest/reference/repos#get-the-combined-status-for-a-specific-reference
- Parameters:
owner – The owner namespace of the repository
repo – The repository name
ref – The sha1 hash of the commit ref
- Returns:
Was the build status success?
- classmethod create_release(owner: str, repo: str, tag: str, changelog: str) bool [source]¶
Create a new release
https://docs.github.com/rest/reference/repos#create-a-release
- Parameters:
owner – The owner namespace of the repository
repo – The repository name
tag – Tag to create release for
changelog – The release notes for this version
- Returns:
Whether the request succeeded
- classmethod edit_release(owner: str, repo: str, id: int, changelog: str) bool [source]¶
Edit a release with updated change notes
https://docs.github.com/rest/reference/repos#update-a-release
- Parameters:
owner – The owner namespace of the repository
repo – The repository name
id – ID of release to update
changelog – The release notes for this version
- Returns:
Whether the request succeeded
- classmethod get_asset_upload_url(owner: str, repo: str, release_id: str) Optional[str] [source]¶
Get the correct upload url for a release
https://docs.github.com/en/enterprise-server@3.5/rest/releases/releases#get-a-release
- Parameters:
owner – The owner namespace of the repository
repo – The repository name
release_id – ID of the release to upload to
- Returns:
URL found to upload for a release
- classmethod get_release(owner: str, repo: str, tag: str) Optional[int] [source]¶
Get a release by its tag name
https://docs.github.com/rest/reference/repos#get-a-release-by-tag-name
- Parameters:
owner – The owner namespace of the repository
repo – The repository name
tag – Tag to get release for
- Returns:
ID of found release
- classmethod post_release_changelog(owner: str, repo: str, version: str, changelog: str) bool [source]¶
Post release changelog
- Parameters:
owner – The owner namespace of the repository
repo – The repository name
version – The version number
changelog – The release notes for this version
- Returns:
The status of the request
- static token() Optional[str] [source]¶
Github token property
- Returns:
The Github token environment variable (GH_TOKEN) value
- classmethod upload_asset(owner: str, repo: str, release_id: int, file: str, label: str = None) bool [source]¶
Upload an asset to an existing release
https://docs.github.com/rest/reference/repos#upload-a-release-asset
- Parameters:
owner – The owner namespace of the repository
repo – The repository name
release_id – ID of the release to upload to
file – Path of the file to upload
label – Custom label for this file
- Returns:
The status of the request
- classmethod upload_dists(owner: str, repo: str, version: str, path: str) bool [source]¶
Upload distributions to a release
- Parameters:
owner – The owner namespace of the repository
repo – The repository name
version – Version to upload for
path – Path to the dist directory
- Returns:
The status of the request
- class semantic_release.hvcs.Gitlab[source]¶
Bases:
Base
Gitlab helper class
- static check_build_status(owner: str, repo: str, ref: str) bool [source]¶
Check last build status
- Parameters:
owner – The owner namespace of the repository. It includes all groups and subgroups.
repo – The repository name
ref – The sha1 hash of the commit ref
- Returns:
the status of the pipeline (False if a job failed)
- classmethod post_release_changelog(owner: str, repo: str, version: str, changelog: str) bool [source]¶
Post release changelog
- Parameters:
owner – The owner namespace of the repository
repo – The repository name
version – The version number
changelog – The release notes for this version
- Returns:
The status of the request
- class semantic_release.hvcs.TokenAuth(token)[source]¶
Bases:
AuthBase
requests Authentication for token based authorization
- semantic_release.hvcs.check_build_status(owner: str, repository: str, ref: str) bool [source]¶
Checks the build status of a commit on the api from your hosted version control provider.
- Parameters:
owner – The owner of the repository
repository – The repository name
ref – Commit or branch reference
- Returns:
A boolean with the build status
- semantic_release.hvcs.check_token() bool [source]¶
Checks whether there exists a token or not.
- Returns:
A boolean telling if there is a token.
- semantic_release.hvcs.get_domain() Optional[str] [source]¶
Returns the domain for the current VCS
- Returns:
The domain in string form
- semantic_release.hvcs.get_hvcs() Base [source]¶
Get HVCS helper class
- Raises:
ImproperConfigurationError – if the hvcs option provided is not valid
- semantic_release.hvcs.get_token() Optional[str] [source]¶
Returns the token for the current VCS
- Returns:
The token in string form
- semantic_release.hvcs.post_changelog(owner: str, repository: str, version: str, changelog: str) bool [source]¶
Posts the changelog to the current hvcs release API
- Parameters:
owner – The owner of the repository
repository – The repository name
version – A string with the new version
changelog – A string with the changelog in correct format
- Returns:
a tuple with success status and payload from hvcs
- semantic_release.hvcs.upload_to_release(owner: str, repository: str, version: str, path: str) bool [source]¶
Upload distributions to the current hvcs release API
- Parameters:
owner – The owner of the repository
repository – The repository name
version – A string with the version to upload for
path – Path to dist directory
- Returns:
Status of the request