|
| 1 | +## Overview |
| 2 | + |
| 3 | +This document provides a step-by-step guide for maintainers to create and publish a release for the project using GoReleaser. The release process is automated via GitHub Actions, and includes generating a changelog, signing the release, and pushing artifacts to the specified container registry. |
| 4 | + |
| 5 | +## Prerequisites |
| 6 | + |
| 7 | +Before creating a release, ensure the following: |
| 8 | +- You have **write access** to the repository. |
| 9 | +- The required **repository secrets** and **environment variables** are set. |
| 10 | +- You have **cosign** installed locally to generate the signing key-pair for release verification. |
| 11 | + |
| 12 | +--- |
| 13 | + |
| 14 | +### 1. Set Up Cosign Key-Pair |
| 15 | + |
| 16 | +Before releasing, you need to generate a cosign key-pair (in local env) to sign the release. |
| 17 | + |
| 18 | +**Steps**: |
| 19 | +1. Install cosign (if not installed): |
| 20 | + ```bash |
| 21 | + cosign install |
| 22 | + ``` |
| 23 | +2. Generate a new cosign key-pair: |
| 24 | + ```bash |
| 25 | + cosign generate-key-pair |
| 26 | + ``` |
| 27 | + This will generate two files: |
| 28 | + - `cosign.key` (the private key) |
| 29 | + - `cosign.pub` (the public key) |
| 30 | + |
| 31 | +3. Set the **private key** and **password** as GitHub repository secrets: |
| 32 | + - **COSIGN_KEY**: Content of `cosign.key` |
| 33 | + - **COSIGN_PASSWORD**: Password used to generate the key-pair |
| 34 | + |
| 35 | + Navigate to **Settings > Secrets and Variables > Repository secrets** and add both secrets. |
| 36 | + |
| 37 | +--- |
| 38 | + |
| 39 | +### 2. Configure GitHub Environments |
| 40 | + |
| 41 | +Next, create a new GitHub environment called **`production`** with the necessary secrets and variables for the release. |
| 42 | + |
| 43 | +#### Secrets for the Production Environment |
| 44 | + |
| 45 | +1. **REGISTRY_USERNAME**: The username for authenticating with the container registry. |
| 46 | +2. **REGISTRY_PASSWORD**: The password for authenticating with the container registry. |
| 47 | + |
| 48 | +**Steps**: |
| 49 | +- Go to **Settings > Environments**. |
| 50 | +- Click **Add environment** and name it `production`. |
| 51 | +- Add the secrets **REGISTRY_USERNAME** and **REGISTRY_PASSWORD** under the `production` environment. |
| 52 | + |
| 53 | +#### Environment Variables for the Production Environment |
| 54 | + |
| 55 | +1. **REGISTRY_ADDRESS**: The address of the registry (e.g., `registry.bupd.xyz`). |
| 56 | +2. **PUBLISH_ADDRESS**: The address to which the CLI artifacts will be published (e.g., `registry.bupd.xyz/harbor/cli`). |
| 57 | + |
| 58 | +**Steps**: |
| 59 | +- After adding secrets, add the following environment variables under `production`: |
| 60 | + - **REGISTRY_ADDRESS** |
| 61 | + - **PUBLISH_ADDRESS** |
| 62 | + |
| 63 | +--- |
| 64 | + |
| 65 | +### 3. Create a GitHub Release |
| 66 | + |
| 67 | +Once the secrets and environment are set, follow these steps to create a release: |
| 68 | + |
| 69 | +1. Go to the **GitHub repository** and click on **Releases**. |
| 70 | +2. Click **Draft a new release**. |
| 71 | +3. In the **Tag version** field, specify the version number (e.g., `v0.2.0`). |
| 72 | +4. **Do not add a description**—the changelog will be generated automatically via GitHub Actions. |
| 73 | +5. Click **Publish Release**. |
| 74 | + |
| 75 | +Once the release is created, the GitHub Actions workflow will: |
| 76 | +- Generate the release changelog. |
| 77 | +- Sign the release using `cosign` (with the `COSIGN_KEY` and `COSIGN_PASSWORD`). |
| 78 | +- Push the CLI binaries to the container registry. |
| 79 | + |
| 80 | +--- |
| 81 | +### 4. Verifying the Release |
| 82 | + |
| 83 | +Once the release is completed, you can verify it by: |
| 84 | + |
| 85 | +- Checking the GitHub Actions log for successful execution. |
| 86 | +- Pulling the image or artifact from the registry using: |
| 87 | + ```bash |
| 88 | + # example |
| 89 | + docker pull registry.bupd.xyz/harbor/cli:v0.2.0 |
| 90 | + ``` |
| 91 | + |
| 92 | +--- |
| 93 | + |
| 94 | +### 5. Troubleshooting |
| 95 | + |
| 96 | +- **Missing GITHUB_TOKEN, GITLAB_TOKEN, or GITEA_TOKEN**: |
| 97 | + Ensure the required environment variables are set in GitHub secrets and accessible to the workflow. |
| 98 | + |
| 99 | +- **Error Signing Release**: |
| 100 | + Double-check that the `COSIGN_KEY` and `COSIGN_PASSWORD` secrets are correctly set in GitHub. |
| 101 | + |
| 102 | +--- |
0 commit comments