Automating Your Releases

Marc Campbell
 | 
Aug 18, 2017


Developers and teams are happiest when they release higher quality updates more often. And most importantly, so are your customers. Great tooling plays an important part in helping everyone reach this happy place.

cli for replicated release

We are excited to announce the release of the Replicated Platform CLI.

This touch of tooling helps teams iterate and release new versions of their on-prem software quicker, with less button pressing in our UI, as well as being a great inclusion in their continuous delivery process.

The Platform CLI is focused on simplifying two key interactions with Replicated; developing a new release, and promoting a release from development to beta to GA.

And while the CLI is perfect for local development, its power shines when plugging it into your favorite CI/CD platform, allowing you to automate your releases every time a new Docker image is pushed to your registry of choice.

Getting Started

On a Mac, installation is as simple as:

[.pre]$ brew install replicatedhq/replicated/cli[.pre]

For Linux, you can use the install script to fetch the latest release and extract it to /usr/local/bin:

[.pre]$ curl -o install.sh -sSL https://raw.githubusercontent.com/replicatedhq/replicated/master/install.shsudo bash ./install.sh[.pre]

Now you’re ready to try out a few commands.

Every command requires your application slug and your API token. You may wish to set the REPLICATED_APP and REPLICATED_API_TOKEN environment variables to avoid having to pass them as flag parameters.

You can find the application slug in the URL. For example, the application name in the URL https://vendor.replicated.com/apps/myamazingapp/releases is myamazingapp.

To create an API token, you can go to the Teams & Tokens page and create a new API token with Read and Write permissions.

[.pre]$ replicated channels ls --app my_app --token 39ae133bb503f532858b0171ddacc524a5e5eID NAMEDESCRIPTIONRELEASE_SEQUENCE00a9939b49076c80f4f1b016d6cb002b StableGeneral Availability 120027ef7d78925222f9eeeea37dbc9d761 UnstableBeta 125042050f9b25963a00cf345e5c5e13670 Dev Latest Builds130[.pre]

or

[.pre]$ export REPLICATED_APP=my_app$ export REPLICATED_API_TOKEN=39ae133bb503f532858b0171ddacc524a5e5e$ replicated channels lsID NAMEDESCRIPTIONRELEASE_SEQUENCE00a9939b49076c80f4f1b016d6cb002b StableGeneral Availability 120027ef7d78925222f9eeeea37dbc9d761 UnstableBeta 125042050f9b25963a00cf345e5c5e13670 Dev Latest Builds130[.pre]

Local development made easy

Once you have everything installed, you can now use your favorite text editor, if it be Atom, or Visual Studio Code, or one of the many other great editiors, and push your changes to Replicated:

[.pre]$ replicated release create --promote Unstable --yaml ""[.pre]

This command uploads your release config to Replicated, and then promotes it to your development channel (Unstable), all in one command!

Automating with CI

Creating a new release for every tagged build is a common use of the Replicated Platform CLI.

Assume the applications Replicated config is checked in to git (replicated.yaml) and you have configured Travis CI or CircleCI with your REPLICATED_APP and REPLICATED_API_TOKEN environment variables.

You can then add a release.sh script to your project like this:

[.pre]#!/bin/bash# Create a new release from replicated.yaml and promote the Unstable channel to use it.# Aborts if version tag is empty.set -eVERSION=$1INSTALL_SCRIPT=https://raw.githubusercontent.com/replicatedhq/replicated/master/install.shif [ -z "" ]; thenecho "No version; skipping replicated release"exitfiunstable_channel_id() {replicated channel ls | grep Unstable | awk '{print $1}'}new_sequence() {replicated release create --yaml "$(< replicated.yaml)" | grep 'SEQUENCE:' | grep -Eo '[0-9]+'}# install replicatedcurl -sSL "" > install.shsudo bash ./install.shreplicated release promote --version ""# Channel ee9d99e87b4a5acc2863f68cb2a0c390 successfully promoted to release 15[.pre]

Now you can automate tagged releases in Travis CI or CircleCI:

[.pre]# .travis.ymldeploy:provider: scriptscript: ./release.sh "$TRAVIS_TAG"[.pre][.pre]# circle.ymldeployment:tag:tag: /v.*/owner: replicatedcomcommands:- ./release.sh "$CIRCLE_TAG"[.pre]

We’ve heard some great feedback from our beta users, and we would love to hear how you and your team use the Replicated Platform CLI.

If you have any ideas or requests on possible additions and improvements, you can send us a Pull Request or can get in touch with us at support@replicated.com.

Happy Building,

The Replicated Team