Releasing LENNAH
Tags: cpp, opensource
Published: 2021-11-26 23:08:29

This week we got the chance to learn how to package and release our SSGs. For my release I decided to use [conan](https://conan.io/) as my package manager and [GitLab](https://gitlab.com/) as my package repository. In order to make my package I had to do a few steps first, I needed to install conan and [cmake](https://cmake.org/download/) so I could run the commands. I already had cmake installed from testing Andrew's SSG so that was nice. Then I had to make a new GitLab account and link it to my GitHub account so I could import my [repo](https://github.com/joshuali7536/LennahSSG) over to GitLab. 

## Steps for packaging and deploying to repo
1. First I had to create a new Conan recipe.```sh
$ conan new LennahSSG/1.0.1 -t
```
2. Then a package for the recipe.```sh
$ conan create . LennahSSG/beta
```
3. The next step is to add a global remote that will allow conan to connect to your GitLab repository. This step requires you to find your project ID, which can be found in the Settings -> General page of your GitLab repo. It will be near the top of the page beside the repo name.```sh
$ conan remote add gitlab https://gitlab.example.com/api/v4/projects/<project_id>/packages/conan
```
4. Once that is done you need to authenticate your connection. You can provide a few different options.```sh
$ conan user <gitlab_username or deploy_token_username> -r gitlab -p <personal_access_token or deploy_token>
```
5. Finally I uploaded the package to the package repository by using the following command:```sh
$ conan upload LennahSSG/1.0.0@LennahSSG/beta --all --remote:gitlab
```
It is important to add the `--remote:gitlab` part otherwise it will go to the default `conancenter` remote. I had some trouble figuring this out, so this we definitely my "ah ha!" moment. You can also set the `gitlab` remote as the default instead by using:```sh
$ conan remote add_ref LennahSSG/1.0.0@LennahSSG/beta gitlab
```
*(Obviously replacing `LennahSSG` with your own project name)*

Conan is nice because I didn't have to modify any of my existing files, by running the commands it added any necessary files on its own.

Testing the installation of the package was pretty easy to do, I had my friend Raymond who doesn't have direct experience with C++ or using Conan, but with some programming experience with web development, test the process. All he had to do to add it as a dependency was add a new text file to a project and run a few commands.

1. He added a 'conanfile.txt' file with the following inside:```
[requires]
LennahSSG/1.0.0@LennahSSG/beta
[generators]
cmake_find_package
msbuild
make
```
2. Then he ran the following commands:
```sh
$ conan remote add gitlab https://gitlab.example.com/api/v4/projects/31641611/packages/conan
```
```sh
$ conan install LennahSSG/1.0.0@LennahSSG/beta --remote=gitlab
```
```sh
$ mkdir build && cd build
```
```sh
$ conan install ..
```
```sh
$ cmake .. && cmake --build .
```
He was able to install LennahSSG as a dependency for his project and could use it in it. You can checkout the package [here](https://gitlab.com/joshuali7536/LennahSSG/-/packages/3940266).

It was an interesting process making a release, I think for future project I would want to try out using other methods as well to see if I find one that I like more or find easier. Because while I did eventually manage to figure out how to create the package with Conan, it was still a bit difficult to figure out how and follow the documentation. It also has a lot of commands you would need to remember, so maybe there are easier options to use. If you want to read more information on how to publish, install, or run packages using conan checkout these docs: [publish & install](https://docs.gitlab.com/ee/user/packages/conan_repository/),  [running](https://docs.conan.io/en/latest/cheatsheet.html#consuming-packages). Until next time take care!