# Versioning

## Overview

The bigger your system grows and the more libs or packages you integrate into your project, the more likely you are to face such a problem as dependency hell.&#x20;

As a solution, code.store platform suggests relying on a simple set of rules and requirements that govern how version numbers are assigned and incremented. There are many approaches to software versioning  and their interfaces, the choice is always up to the developer.

{% hint style="info" %}
code.store platform doesn't enforce any standard on how you need to version your services, but we **highly** **recommend** looking at a standard like [semver](https://semver.org)&#x20;

[semver](https://semver.org)'s  approach can solve most of the versioning issues
{% endhint %}

When you create a new service, by default, it deployed into  **private** and **demo** [environment](/getting-started/fundamentals/environments.md) and it's version is `0.0.1`

## Which version currently deployed?

To find out which version is in use execute `cs service:info` CLI command and select the service. You will find which versions deployed on **private** and **demo** environments.

```
> cs service:info

              Private                                                         Demo                                                            
version       0.0.2                                                           0.0.1                                                           
deployed      8/5/2020, 10:37:21 PM                                           8/5/2020, 10:38:58 PM                                           
developer key null                                                                                                                            
url           https://api.code.store/a6203d238a744492bf1bf33833c3ebf6/graphql https://api.code.store/a858e12ddd2c47f5b381bef9d98dc7a9/graphql 
```

On example above on the **private** environment deployed service with `0.0.2` version and `0.0.1` on the **demo**.&#x20;

If you already include service to project, you can execute `cs project:service:info` CLI command, select project and service to display. &#x20;

```
> cs project:service:info

              Development                                                     Staging                                                         Production                                                      
version       0.0.3                                                           0.0.2                                                           0.0.2                                                           
deployed      8/5/2020, 10:39:22 PM                                           8/5/2020, 10:39:23 PM                                           8/5/2020, 10:39:21 PM                                           
developer key                                                                                                                                                                                                 
url           https://api.code.store/8ddc603ea9dd4a669755bf2125bdca24/graphql https://api.code.store/bb2eae903e924bdeb3f6fe9627055d93/graphql https://api.code.store/efe4caaf5584497599728f3785e8fc7d/graphql 
```

On example above deployed on three environments deployed next versions:

| environment | version |
| ----------- | ------- |
| development | 0.0.3   |
| staging     | 0.0.2   |
| production  | 0.0.2   |

## Create a new service version

To create a new version just push your changes using `cs push` CLI command. More information about pushing changes can be found in [Services](/getting-started/fundamentals/services.md) section. After pushing changes - a new version will be available on the **private** [environment](/getting-started/fundamentals/environments.md).

It's very important to increment service version after making changes to service. Actual service version is always available at `package.json` file.

{% hint style="info" %}
By default, code.store platform will automatically increment path (x.y.**Z**) version of your code after each push, if you follow [semver](https://semver.org/) specification.&#x20;
{% endhint %}

## Publish a new service version

After creating a new service version using `cs push` command - changes will be available only on the **private** [environment](/getting-started/fundamentals/environments.md).&#x20;

**demo** [environment](/getting-started/fundamentals/environments.md) - is the only place, where developed changes can be published. Changes from demo environment is available for including to the project or public [access](/getting-started/fundamentals/access-and-authorization.md).&#x20;

To make a new version available - execute `cs promote` CLI command. This command will deploy changes from **private** to **demo** environment and makes a new version available for update/include into projects. Promoted version to demo environment is marks as `LATEST`

```
cs promote
```

## Manage service version inside project

When you include a new service to the [project](/getting-started/fundamentals/projects.md) - version from **demo** [environment](/getting-started/fundamentals/environments.md) will be deployed. This allows adhering to the concept of public release of new versions to avoid unexpected system behavior. More information about including services to projects can be found in [Projects](/getting-started/fundamentals/projects.md) section.

### Move service version per environment

After including service to the project - it's deployed only to **development** [environment](/getting-started/fundamentals/environments.md). To move service version to another environment use `cs project:service:promote` CLI command. It allows you to move already deployed version to another environment.

```
cs project:service:promote
```

For example, if your project includes some service - you can promote only already deployed service version to another environments.

### Update service version to latest

To update project service to latest version execute `cs project:service:roll` CLI command, where you can select project, environment where will be applied changes, service and version.&#x20;

Select `latest` version if you need a latest available service version.

```
cs project:service:roll
```

### Rollback service version

To rollback service version use the same command `cs project:service:roll` and just select needed version and environment where to deploy needed version.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.code.store/getting-started/fundamentals/versioning.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
