Skip to main content

GitHub Upload Release Asset

The GitHub Upload Release Asset recipe uploads a file as an asset to a GitHub release using the GitHub REST API — for example a build artifact at the end of a release pipeline.

Recipe IDjjideenschmiede/github-upload-release-asset
MarketplaceGitHub Upload Release Asset
Source codeGitHub

How It Works​

The recipe first checks that the given file exists. If no release ID is given, it determines the latest release of the repository. The file is then uploaded as an asset to the release. If one of the steps fails, the build step fails with the error message of the GitHub API.

Installation​

The recipe requires TeamCity 2025.03 or later. How to add it to a build configuration is described under Using a Recipe.

Inputs​

InputRequiredDefaultDescription
RepositoryYes–GitHub repository in owner/repo format, for example JetBrains/teamcity-recipes
Release IDNoLatest releaseID of the GitHub release to upload the asset to. If the field is left empty, the latest release of the repository is used.
GitHub Access TokenYes–Personal access token with repo permissions. Create tokens at github.com/settings/tokens.
Asset File PathYes–Path to the file to upload. Absolute and relative paths are accepted.
Asset NameNoFile nameName of the asset in the release. If the field is left empty, the file name is used.

Example​

InputValue
Repositoryexample/app
GitHub Access Token%github.token%
Asset File Pathdist/app-%build.number%.zip

Without a Release ID, the file is uploaded to the latest release and appears there under its file name.

Error Messages​

MessageCause
Asset file not foundNo file exists at the given path. Relative paths refer to the working directory of the build step.
Asset path is not a fileThe path points to a directory
Failed to fetch latest release (HTTP 404)The repository has no published release or the token has no access
Upload failed (HTTP 422)An asset with this name already exists in the release
Upload failed (HTTP 401) or (HTTP 403)The token is invalid or has no write access to the repository

Notes​

  • The release ID is the numeric ID from the GitHub API, not the tag name of the release.
  • The latest release is the one that GitHub marks as "latest". Drafts and pre-releases are not considered.
  • An asset with the same name must not exist in the release yet, otherwise GitHub rejects the upload.
  • The file is loaded completely into the memory of the agent before the upload. Keep this in mind for very large files.