# GitHub Release

> For AI agents: the complete documentation index is at https://buddy.works/llms.txt

Connect a GitHub repository to a Buddy artifact. Each new release becomes a read-only version with its assets and can trigger a deploy pipeline.

A GitHub Release artifact creates versions from releases in a connected GitHub repository. The version name is the release tag, and the version contains the files attached to the release. A pipeline can download such a version, test it and deploy it.

## Artifact versions and synchronization

Each version corresponds to one release, for example `v1.1.0`. The source code archives that GitHub generates automatically are not in the version.

Sync works one way, from GitHub to Buddy. Versions are read-only in Buddy: adding a version or a file fails with `Artifact version is read only`. To create a GitHub release from a Buddy pipeline, use the [GitHub Release](https://buddy.works/docs/yaml/yaml-actions/git-hub-release.md) action.

A version has a URL like a version of a [Bucket](https://buddy.works/docs/artifacts/bucket.md) artifact. Dots in the version name are replaced with hyphens in the URL:

```
https://v1-1-0-my-app-releases-my-workspace.bucket-2.registry.sh
```

![GitHub Release artifact versions with pre-releases](https://buddy.works/docs/artifacts/github-release-versions.png)

## Artifact creation

The artifact requires a [GitHub integration](https://buddy.works/docs/integrations/github.md) with access to the repository. In **Artifacts**, click **New artifact**, select **GitHub Release** and set:

- **Scope** - Workspace or Project, described in [Scopes](https://buddy.works/docs/artifacts/scopes.md),
- **Integration**, **Organization** and **Repository** - the GitHub integration and the repository the releases come from,
- **Include draft releases** - enables synchronization of draft releases. Draft release versions do not trigger pipeline execution until the corresponding release is published on GitHub
- **Include pre-releases** - whether versions are also created from pre-releases.

After you create the artifact, you set retention rules for versions matching a pattern, for example `v*-rc.*`, in the **Settings** tab, in the **Retention artifact version pattern** field.

![GitHub Release artifact settings](https://buddy.works/docs/artifacts/github-release-settings.png)

Buddy does not import releases created before the repository was connected, so connecting it does not start any pipelines.

## Release-based pipeline triggers

A new version can start a pipeline with the [On artifact event](https://buddy.works/docs/pipelines/introduction/triggering-pipelines/on-artifact-event.md) trigger and the version creation event. In YAML:

```yaml
events:
- type: CREATE_ARTIFACT_VERSION
  artifacts:
  - identifier: my-app-releases
    scope: WORKSPACE
```

A run started by a new version has three variables that describe the release:

| Variable | Value |
| :--- | :--- |
| `BUDDY_RUN_ARTIFACT_VERSION` | Release tag, e.g. `v1.1.0-rc.2` |
| `BUDDY_RUN_ARTIFACT_VERSION_DRAFT` | `false` in automatically triggered runs. `true` only in runs started manually with a draft release version |
| `BUDDY_RUN_ARTIFACT_VERSION_PRERELEASE` | `true` for a GitHub pre-release, `false` for a stable release |

The value of `BUDDY_RUN_ARTIFACT_VERSION_PRERELEASE` comes from the pre-release flag on GitHub, not from the tag name. A `v2.0.0-rc.1` release published without this flag reaches the pipeline as stable.

The **Download Artifact Version** action downloads the version that started the run:

```yaml
- action: Download release
  type: DOWNLOAD_ARTIFACT_VERSION
  artifact: my-app-releases
  version: $BUDDY_RUN_ARTIFACT_VERSION
  destination_path: release/$BUDDY_RUN_ARTIFACT_VERSION
  overwrite: true
```

The pipeline filesystem persists between runs, so a separate directory for each version keeps the files of different releases apart. The other variables and action conditions are described in [Run a pipeline with an artifact version](https://buddy.works/docs/artifacts/run-with-version.md).

## Conditional execution based on release type

The `BUDDY_RUN_ARTIFACT_VERSION_PRERELEASE` variable can be used in trigger conditions to control action execution based on the release type. The following condition restricts action execution to pre-releases:

```yaml
trigger_conditions:
- trigger_condition: VAR_IS
  trigger_variable_key: BUDDY_RUN_ARTIFACT_VERSION_PRERELEASE
  trigger_variable_value: "true"
```

Set `trigger_variable_value` to `"false"` to restrict action execution to stable releases. Actions whose trigger conditions are not met are marked as **Skipped** in the run. For an example of a release-based deployment workflow, see [GitHub Release artifacts in Buddy](https://buddy.works/blog/github-release-artifacts).

## Pipeline permissions

Downloading artifact versions requires the pipeline to have at least the **Read-only** permission level for the artifact. Pipeline permissions are configured on the artifact's Permissions tab. See [Permissions and access](https://buddy.works/docs/artifacts/permissions-and-access.md).

See also:

- [Run a pipeline with an artifact version](https://buddy.works/docs/artifacts/run-with-version.md) - `BUDDY_RUN_ARTIFACT_*` variables and triggers on artifact events
- [Artifacts in pipelines](https://buddy.works/docs/artifacts/pipelines.md) - the Download Artifact Version action and its fields
- [Cleanup and retention](https://buddy.works/docs/artifacts/cleanup-and-retention.md) - deleting old versions, for example `-rc` candidates
- [GitHub integration](https://buddy.works/docs/integrations/github.md) - connecting a workspace to GitHub


---
Original source: https://buddy.works/docs/artifacts/github-release