# Release

DBaaS leverage jenkins to automate the release process. A release must be sourced from a tag with name pattern `release-v.*`, after a tag like that is pushed, the following steps will be taken:

1. The code is tested in jenkins
2. Docker images are built in jenkins if step 1 passed
3. Jenkins will require the approval from one of the SRE leaders to proceed to the deployment
4. With approval, jenkins deploys the images built in step 2 to the target environment

The SRE actions required in this process are listed below.

## Create the release branch

Login in [cicd.tidbcloud.com](http://cicd.tidbcloud.com), find the `staging` job, edit configuration, change the branch filter to the release branch `release-<date>`,
then create the release branch:

```
$ git checkout -b release-<date>
$ git push --set-upstream origin relesae-<date>
```

All changes to release branch will be automatically deployed to the staging env.

## Create a release tag

After DBaaS is fully tested in the staging env, bump the version of DBaaS, the version must be same as the git tag that is going to be created.

```
$ VERSION=release-v20200716
# with the target pulumi stack selected
$ pulumi config set image_tag ${VERSION}
$ git add .
$ git commit -m "Release ${VERSION}"
```

Get the PR reviewed and merged to the release branch. Then tag the commit.

```
$ git checkout <BUMP_COMMIT>
$ git tag ${VERSION}
$ git push origin ${VERSION}
```

## Check build status

Check [Jenkins Release Job](http://cicd.tidbcloud.com/job/release/view/tags/) to see if the test and build of your release are passed.

If the pre-release check is failed, you may fix it and re-apply a new tag. The release process would be paused before deploying to the 
production environment.

## Create a jira ticket

Create a jira ticket like [this](https://jira.tidbcloud.com/browse/CMP-25), ask approvals from the PM and one of the SRE leaders to deliver
the release candidate.

## Approve the release

With the jira ticket approved. Ask SRE leader to approve the release. The dialog should look like this:

![approve](../static/approve.png)

Then the pipeline would proceed and deploy DBaaS to production. Post release check should be done manually after the pipeline succeed.
