|
| 1 | +# Publishing to Packages.Microsoft |
| 2 | +> Please ensure that stable versions of rpm and deb have already been published to daily storage. |
| 3 | +
|
| 4 | +> Publishing to the Microsoft Repo may only be completed on corp-net. Support for non-corp-net access is not available at the time of this writing. Repo CLI docs may be accessed [here](http://csd-linux-publishing-service.azurewebsites.net/). |
| 5 | +
|
| 6 | +The following steps are required to deploy Linux packages to Packages.Microsoft: |
| 7 | +1. Build a Linux environment which supports the Repo CLI installation. |
| 8 | +2. Install [Repo CLI](http://csd-linux-publishing-service.azurewebsites.net/client#commands), a tool used to publish to Packages.Microsoft. |
| 9 | +3. Publish to each supported Linux distribution. |
| 10 | + |
| 11 | +Much of this process has been automated, however, each step may be conducted manually if desired. |
| 12 | + |
| 13 | +## Creating Linux Environment |
| 14 | +A Linux environment needs to be created to install [Repo CLI](http://csd-linux-publishing-service.azurewebsites.net/client#commands), which requires: |
| 15 | +1. AMD architecture. |
| 16 | +2. Connection to corp-net. |
| 17 | +3. Include both config and certificate files, detailed below. |
| 18 | + |
| 19 | +### Required Files for Repo CLI |
| 20 | +[Repo CLI](http://csd-linux-publishing-service.azurewebsites.net/client#commands) is the required API to publish Linux packages to Packages.Microsoft. Two files are required to use this tool: |
| 21 | +1. **A certificate** used for authenticating with the tool. |
| 22 | +2. **A JSON config file** as listed on the [Repo CLI docs](http://csd-linux-publishing-service.azurewebsites.net/client#commands). |
| 23 | + |
| 24 | +#### Certificate |
| 25 | +The certificate is hosted on our team's Key Vault account in Azure, under 'Certificates'. Download the certificate as a PEM file and include it in this directory (Packages.Microsoft). Rename the file as **private.pem**. |
| 26 | + |
| 27 | +* If you plan to use the automated publishing process, place **private.pem** in this directory (`<repo root>/release_scripts/Packages.Microsoft/private.pem`). |
| 28 | +* If a custom Linux environment is used, the location needs to be in `/root/private.pem`. |
| 29 | + |
| 30 | +#### Config |
| 31 | +An incomplete `config.json` file is located in this directory. Complete the empty attributes as follows: |
| 32 | +* `"AADClientId"`: points to the mssql-cli app registration, titled **mssql-cli (Registered with Packages.Microsoft)**. The ID can be obtained by accessing the Azure Portal. |
| 33 | +* `"AADResource"` and `"AADTenant"`: both point to Packages.Microsoft-specific resources. To obtain these values, access the [Repo CLI](http://csd-linux-publishing-service.azurewebsites.net/client) home page, click the **Configure the Repo CLI** tab, followed by the **Packages.Microsoft** sub-tab. |
| 34 | + |
| 35 | +If you plan to use the automated publishing process, keep this file located as is. Otherwise, copy this file to `/root/.repoclient/config.json` on your Linux machine. |
| 36 | + |
| 37 | +### Create Linux Container |
| 38 | +This directory contains a dockerfile that generates a Linux environment that's compliant with Repo CLI. |
| 39 | + |
| 40 | +If a non-Docker Linux environment is desired, you may skip to [Repo CLI Installation](#repo-cli-installation). However, please ensure your Linux machine: |
| 41 | +1. Uses AMD architecture |
| 42 | +2. Is connected to corp-net |
| 43 | + |
| 44 | +#### Building Docker Container |
| 45 | +> Docker Desktop is required and may be installed for macOS or Windows [here](https://www.docker.com/products/docker-desktop). |
| 46 | +
|
| 47 | +Complete the below command below to create a Docker container with dependencies installed for publishing. |
| 48 | + |
| 49 | +From the root repo directory, run: |
| 50 | +```sh |
| 51 | +docker build -t mssqlcli-publish-msftrepo -f release_scripts/Packages.Microsoft/Dockerfile . --no-cache |
| 52 | +``` |
| 53 | + |
| 54 | +#### Running Docker Container |
| 55 | +This will run the Docker container that was built using the previous command. |
| 56 | +```sh |
| 57 | +docker run -it mssqlcli-publish-msftrepo bash |
| 58 | +``` |
| 59 | + |
| 60 | +You may now complete the Repo CLI installation, detailed in the next section. |
| 61 | + |
| 62 | +## Repo CLI Installation |
| 63 | +[Repo CLI](http://csd-linux-publishing-service.azurewebsites.net/client) is the the tool used to publish packages to Packages.Microsoft. Install the Repo CLI in your Linux environment as follows: |
| 64 | + |
| 65 | +```sh |
| 66 | +sudo apt-get -y install azure-repoapi-client |
| 67 | +``` |
| 68 | + |
| 69 | +Respond to all prompts to complete installation. |
| 70 | + |
| 71 | +## Publishing to Packages.Microsoft Using Repo CLI |
| 72 | +The `publish.sh` script will upload deb and rpm packages to Packages.Microsoft by consulting the `supported_repos_prod.json` or `supported_repos_testing.json` file. This data is used to find supported repositories located in Packages.Microsoft. |
| 73 | + |
| 74 | +`publish.sh` takes `'testing'` or `'prod'` parameters as its second argument. Uploading to the testing distribution is effective for testing the installation and usage of mssql-cli on various Linux systems without affecting production. |
| 75 | + |
| 76 | +### Publishing to Testing Channel |
| 77 | +From the mssql-cli folder root, make the following command to upload packages to all repositories in the `supported_repos_testing.json` file: |
| 78 | +```sh |
| 79 | +# default call will display commands rather than upload packages |
| 80 | +release_scripts/Packages.Microsoft/publish.sh $(pwd) 'testing' |
| 81 | + |
| 82 | +# use --upload to publish to Packages.Microsoft |
| 83 | +release_scripts/Packages.Microsoft/publish.sh $(pwd) 'testing' --upload |
| 84 | +``` |
| 85 | + |
| 86 | +Visit the [testing](#testing-distribution-downloads) section for more information on downloading builds from the testing distribution. |
| 87 | + |
| 88 | +### Publishing to Production Channel |
| 89 | +When ready for production, change `'testing'` with `'prod'`, which will upload to all repositories in the `supported_repos_prod.json` file: |
| 90 | +```sh |
| 91 | +# default call will display commands rather than upload packages |
| 92 | +release_scripts/Packages.Microsoft/publish.sh $(pwd) 'prod' |
| 93 | + |
| 94 | +# use --upload to publish to Packages.Microsoft |
| 95 | +release_scripts/Packages.Microsoft/publish.sh $(pwd) 'prod' --upload |
| 96 | +``` |
| 97 | + |
| 98 | +## Repo CLI Commands |
| 99 | +This list below contains frequently used commands to navigate the Repo CLI API: |
| 100 | + |
| 101 | +#### Upload Single Package |
| 102 | +Packages.Microsoft uses **repositories** to distinguish publishing channels. mssql-cli publishes .deb and .rpm packages directly to repositories, which map to a Linux distribution (i.e. Ubuntu 16.04) along with it's distribution channel (i.e. prod or testing). The [list uploaded pacakges](#list-uploaded-packages) command will display a list respositories with previously-published mssql-cli packages. |
| 103 | + |
| 104 | +The call below uploads a .deb or .rpm package to a specificed repository in Packages.Microsoft: |
| 105 | +```sh |
| 106 | +repoclient package add <package filepath> -r <repo ID> |
| 107 | +``` |
| 108 | + |
| 109 | +#### List Uploaded Packages |
| 110 | +Use the call below to display a history of previously-published mssql-cli packages: |
| 111 | +```sh |
| 112 | +repoclient package list | jq '.[] | select(.name=="mssql-cli")' |
| 113 | +``` |
| 114 | + |
| 115 | +#### List Repositories by Linux Version and Distribution Channel |
| 116 | +Use the below command to list Packages.Microsoft repository information, with filters for Linux OS and distribution channel: |
| 117 | + |
| 118 | +```sh |
| 119 | +repoclient repo list | jq '.[] | select(.url=="<Linux OS name>" and .distribution=="<distribution>")' |
| 120 | + |
| 121 | +# For example: |
| 122 | +repoclient repo list | jq '.[] | select(.url=="microsoft-ubuntu-xenial-prod" and .distribution=="testing")' |
| 123 | +``` |
0 commit comments