Download the Conan package manager to your local development environment by following
the instructions at [conan.io](https://conan.io/downloads.html).
Download the Conan package manager to your local development environment by
following the instructions at [conan.io](https://conan.io/downloads.html).
When installation is complete, verify you can use Conan in your terminal by running:
When installation is complete, verify you can use Conan in your terminal by
running:
```shell
conan --version
...
...
@@ -42,15 +46,16 @@ Conan version 1.20.5
### Install CMake
When you develop with C++ and Conan, you have a range of compilers to choose from.
This example uses the CMake compiler.
When you develop with C++ and Conan, you can select from many available
compilers. This example uses the CMake compiler.
To install CMake:
- For Mac, use [homebrew](https://brew.sh/) and run `brew install cmake`.
- For other operating systems, follow the instructions at [cmake.org](https://cmake.org/install/).
When installation is complete, verify you can use CMake in your terminal by running:
When installation is complete, verify you can use CMake in your terminal by
running:
```shell
cmake --version
...
...
@@ -60,8 +65,8 @@ The CMake version is printed in the output.
### Create a project
To test the Package Registry, you need a C++ project. If you don't already have one, you can clone the
Conan [hello world starter project](https://github.com/conan-io/hello).
To test the Package Registry, you need a C++ project. If you don't already have
one, you can clone the Conan [hello world starter project](https://github.com/conan-io/hello).
### Build a package
...
...
@@ -74,22 +79,26 @@ To build a package:
conan new Hello/0.1 -t
```
1. Create a package for the recipe by running `conan create` with the Conan user and channel:
1. Create a package for the recipe by running `conan create` with the Conan user
and channel:
```shell
conan create . mycompany/beta
```
NOTE: **Note:**
If you use an [instance remote](#add-a-remote-for-your-instance), you must follow a specific [naming convention](#package-recipe-naming-convention-for-instance-remotes).
If you use an [instance remote](#add-a-remote-for-your-instance), you must
follow a specific [naming convention](#package-recipe-naming-convention-for-instance-remotes).
A package with the recipe `Hello/0.1@mycompany/beta` is created.
For more details on creating and managing Conan packages, see the [Conan docs](https://docs.conan.io/en/latest/creating_packages.html).
For more details about creating and managing Conan packages, see the
| `gitlab-org/gitlab-ce` | `my-package/1.0.0@foo/stable` | No |
[Project remotes](#add-a-remote-for-your-project) have a more flexible naming convention.
[Project remotes](#add-a-remote-for-your-project) have a more flexible naming
convention.
## Authenticate to the Package Registry
To authenticate to the Package Registry, you need either a personal access token or deploy token.
To authenticate to the Package Registry, you need either a personal access token
or deploy token.
- If you use a [personal access token](../../../user/profile/personal_access_tokens.md), set the scope to `api`.
- If you use a [deploy token](../../project/deploy_tokens/index.md), set the scope to `read_package_registry`, `write_package_registry`, or both.
- If you use a [personal access token](../../../user/profile/personal_access_tokens.md),
set the scope to `api`.
- If you use a [deploy token](../../project/deploy_tokens/index.md), set the
scope to `read_package_registry`, `write_package_registry`, or both.
### Add your credentials to the GitLab remote
Associate your token with the GitLab remote, so that you don't have to explicitly
add a token to every Conan command.
Associate your token with the GitLab remote, so that you don't have to
explicitly add a token to every Conan command.
Prerequisites:
- You must have an authentication token.
- The Conan remote [must be set](#add-the-package-registry-as-a-conan-remote).
- The Conan remote [must be configured](#add-the-package-registry-as-a-conan-remote).
In a terminal, run this command. In this example, the remote name is `gitlab`. Use the name of your remote.
In a terminal, run this command. In this example, the remote name is `gitlab`.
Use the name of your remote.
```shell
conan user <gitlab_username or deploy_token_username> -r gitlab -p <personal_access_token or deploy_token>
```
Now when you run commands with `--remote=gitlab`, your username and password are automatically included in the requests.
Now when you run commands with `--remote=gitlab`, your username and password are
included in the requests.
Alternately, you can explicitly include your credentials in any given command. For example:
Alternatively, you can explicitly include your credentials in any given command.
For example:
```shell
CONAN_LOGIN_USERNAME=<gitlab_username or deploy_token_username> CONAN_PASSWORD=<personal_access_token or deploy_token> conan upload Hello/0.1@mycompany/beta --all--remote=gitlab
```
NOTE: **Note:**
Your authentication with GitLab expires on a regular basis,
so occasionally you may need to re-enter your personal access token.
Because your authentication with GitLab expires on a regular basis, you may
occasionally need to re-enter your personal access token.
### Set a default remote for your project (optional)
If you want to interact with the GitLab Package Registry without having to specify a remote,
you can tell Conan to always use the Package Registry for your packages.
If you want to interact with the GitLab Package Registry without having to
specify a remote, you can tell Conan to always use the Package Registry for your