> ## Documentation Index
> Fetch the complete documentation index at: https://docs.directgvr.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Create environments and promote releases

> Use promote.py to assign releases to environments such as QA and production, and move them up your pipeline.

Environments are the stages of your deployment pipeline, such as development, QA, beta, staging and production. You deploy a release, test it in an early environment, then promote it to later ones as it passes testing. This page uses the [promote.py](https://docs.directgvr.com/release-automation/deployment-scripts.md#promote-py) script.

## How environments work

When you assign a release to an environment, `promote.py` writes a key/value pair to that repository's alias file in this format:

```text theme={null}
repositoryname.environmentname: releaseId
```

The repository name and environment name are separated by a period. For example:

```json theme={null}
{
  "gameclient.qa": "327944e2a760bfe93f3839d4f0445f33cfa6f022"
}
```

Each repository has its own alias file, for example:

* `https://cdn.example.com/game/launcher/alias.json`
* `https://cdn.example.com/game/gameclient/alias.json`
* `https://cdn.example.com/game/maps/alias.json`

Once you've assigned releases to each environment, the repository's alias file lists one entry per environment:

```json theme={null}
{
  "gameclient.qa": "3ac5607fb72faae9af1ecf89b5f53b0b02508052",
  "gameclient.beta": "2cc958d0b81ca3b946ea50572f883e34d52d51f2",
  "gameclient.production": "979bee50d9d12794f3da28e9c739cb485d59b60b"
}
```

The launcher reads these alias files to decide whether it needs to update.

Because every environment points into the same repository, you can deploy all releases to the same CDN. A release promoted from internal QA to external QA to production is downloaded by production players from exactly the same files and location your QA team tested. You can also deploy to an internal server first and copy releases to your CDN later, but you don't have to.

## Assign a release to an environment

Run `promote.py` with the repository, the release and the environment:

```bash theme={null}
promote.py --repository=gameclient --version=0.0.5 --environment=qa --sync_directory=<your-sync-directory>/
promote.py --repository=gameclient --version=0.0.4 --environment=beta --sync_directory=<your-sync-directory>/
promote.py --repository=launcher --version=1.0.18 --environment=qa --sync_directory=<your-sync-directory>/
```

A release can be in more than one environment. These examples choose the release by `--version`; `promote.py` also accepts `--release_id`, `--description`, `--latest` and `--source_environment`.

## How the launcher picks an environment

The launcher's workflow names the repositories and the environment it syncs. See [Configure the launcher to download your repositories](https://docs.directgvr.com/launcher-design/download-repositories.md). A QA launcher has `"environment": "qa"` in its macros:

```json theme={null}
"loadMacros": {
  "type": "macro",
  "keyValuePairs": {
    "repositoryGame": "gameclient",
    "repositoryGameTitle": "Llama Game Client",
    "repositoryLauncher": "launcher",
    "repositoryLauncherTitle": "Llama Game Launcher",
    "repositoryMaps": "maps",
    "repositoryMapsTitle": "Llama Game Maps",
    "environment": "qa",
    "base_url": "https://cdn.example.com/game/",
    "installDirectory": "{moduleDirectory}Download{pathSlash}",
    "executableName-win": "clientData/llama_game.exe",
    "repositoryAliasUrl": "{base_url}{repository}/alias.json",
    "repositoryCatalogUrl": "{base_url}{repository}/catalog/",
    "selfUpdateDirectory": "{moduleDirectory}"
  }
},
```

A production launcher is the same except for `"environment": "production"`.

If a player has access to more than one environment, you can change the environment at runtime. See [Switch environments with command-line arguments](https://docs.directgvr.com/launcher-design/switch-environments.md).

## Promote between environments

When releases in one environment pass testing, promote them with `--source_environment`. For example, to move the beta releases to production:

```bash theme={null}
promote.py --repository=launcher --source_environment=beta --environment=production --sync_directory=<your-sync-directory>/
promote.py --repository=gameclient --source_environment=beta --environment=production --sync_directory=<your-sync-directory>/
promote.py --repository=languages --source_environment=beta --environment=production --sync_directory=<your-sync-directory>/
```

Players in the production environment then sync to the new required releases. Promote between any other environments the same way.

## Related

* [Deploy a release](https://docs.directgvr.com/release-automation/deploy-a-release.md)
* [Alias, repository, environment and history files](https://docs.directgvr.com/release-automation/metadata-files.md)
* [Deployment scripts](https://docs.directgvr.com/release-automation/deployment-scripts.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.