|
| 1 | +# Helm Chart Publishing Scripts |
| 2 | + |
| 3 | +This directory contains scripts for publishing RedHat-specific Argo CD Agent Helm charts. These scripts update the argocd-agent helm chart with RedHat-specific configurations and prepare them for distribution. |
| 4 | + |
| 5 | +## Overview |
| 6 | + |
| 7 | +The scripts in this directory automate the process of: |
| 8 | +- Extracting the Argo CD Agent helm chart from the submodule |
| 9 | +- Applying RedHat-specific configurations |
| 10 | +- Updating image repositories and tags |
| 11 | +- Generating documentation |
| 12 | +- (For stage releases) Packaging and pushing to OCI registry |
| 13 | + |
| 14 | +## Prerequisites |
| 15 | + |
| 16 | +### Common Prerequisites (Both Scripts) |
| 17 | + |
| 18 | +- **Git submodule initialized**: The `sources/argocd-agent` submodule must be initialized |
| 19 | +- **yq**: Must be installed and available at `bin/yq` in the repository root |
| 20 | +- **helm-docs**: Must be installed and available in PATH. [download binary](https://github.com/norwoodj/helm-docs/releases). |
| 21 | +- **config.yaml**: Must exist in the repository root with proper source configuration |
| 22 | +- **Git repository**: Should be run from the `main` branch or a tagged commit (warning shown if not) |
| 23 | + |
| 24 | +### Additional Prerequisites for `publish-stage.sh` |
| 25 | + |
| 26 | +- **helm**: Must be installed and available in PATH |
| 27 | + ```bash |
| 28 | + # Installation: https://helm.sh/docs/intro/install/ |
| 29 | + ``` |
| 30 | + |
| 31 | +## Scripts |
| 32 | + |
| 33 | +### `publish.sh` |
| 34 | + |
| 35 | +**Purpose**: Updates the argocd-agent helm chart with RedHat-specific configurations for production releases. |
| 36 | + |
| 37 | +**What it does**: |
| 38 | +1. Validates the image tag format |
| 39 | +2. Reads commit and ref from `config.yaml` |
| 40 | +3. Initializes and updates the `sources/argocd-agent` submodule |
| 41 | +4. Copies the helm chart to an output directory named `{commit}-{ref}` |
| 42 | +5. Updates `Chart.yaml` with RedHat-specific metadata |
| 43 | +6. Updates `values.yaml` with production image repository: |
| 44 | + - Image repository: `registry.redhat.io/openshift-gitops-1/argocd-agent-rhel8` |
| 45 | + - Image tag: Provided as argument, should be similar to what is present on the catalog. e.g. v1.18.1, v1.18.1-2 |
| 46 | +7. Generates helm chart documentation using `helm-docs` |
| 47 | + |
| 48 | +**Usage**: |
| 49 | +```bash |
| 50 | +./helm-chart/publish.sh <tag> |
| 51 | +``` |
| 52 | + |
| 53 | +**Arguments**: |
| 54 | +- `tag` (required): The image tag in format `v<major>.<minor>.<patch>[-<build>]` |
| 55 | + - Examples: `v1.18.1`, `v1.18.1-2` |
| 56 | + |
| 57 | +**Example**: |
| 58 | +```bash |
| 59 | +./helm-chart/publish.sh v1.18.1-2 |
| 60 | +``` |
| 61 | + |
| 62 | +**Output**: |
| 63 | +- Creates a directory: `helm-chart/{commit}-{ref}/` |
| 64 | +- Contains the updated helm chart with RedHat configurations |
| 65 | +- Includes generated `README.md` documentation |
| 66 | + |
| 67 | +**Image Repository**: |
| 68 | +- Production: `registry.redhat.io/openshift-gitops-1/argocd-agent-rhel8` |
| 69 | + |
| 70 | +--- |
| 71 | + |
| 72 | +### `publish-stage.sh` |
| 73 | + |
| 74 | +**Purpose**: Updates the argocd-agent helm chart with RedHat-specific configurations for stage releases and publishes to OCI registry. |
| 75 | + |
| 76 | +**What it does**: |
| 77 | +1. Reads commit and ref from `config.yaml` |
| 78 | +2. Initializes and updates the `sources/argocd-agent` submodule |
| 79 | +3. Copies the helm chart to an output directory named `{commit}-{ref}-stage` |
| 80 | +4. Updates `Chart.yaml` with RedHat-specific metadata |
| 81 | +5. Updates `values.yaml` with stage image repository: |
| 82 | + - Image repository: `quay.io/redhat-user-workloads/rh-openshift-gitops-tenant/argocd-agent-rhel8` |
| 83 | + - Image tag: Provided as argument |
| 84 | +6. Generates helm chart documentation using `helm-docs` |
| 85 | +7. Packages the helm chart using `helm package` |
| 86 | +8. Pushes the packaged chart to OCI registry (default: `oci://quay.io/anandrkskd/argocd-agent`, can be overridden with `HELM_OCI_REGISTRY` environment variable) |
| 87 | + |
| 88 | +**Usage**: |
| 89 | +```bash |
| 90 | +./helm-chart/publish-stage.sh <tag> |
| 91 | +``` |
| 92 | + |
| 93 | +**Arguments**: |
| 94 | +- `tag` (required): The image tag (e.g., `v1.18.1-2`) |
| 95 | + |
| 96 | +**Environment Variables**: |
| 97 | +- `HELM_OCI_REGISTRY` (optional): Override the default OCI registry. If not set, defaults to `oci://quay.io/anandrkskd/argocd-agent` |
| 98 | + |
| 99 | +**Example**: |
| 100 | +```bash |
| 101 | +# Using default OCI registry |
| 102 | +./helm-chart/publish-stage.sh v1.18.1-2 |
| 103 | + |
| 104 | +# Using custom OCI registry |
| 105 | +HELM_OCI_REGISTRY="oci://quay.io/my-org/my-charts" ./helm-chart/publish-stage.sh v1.18.1-2 |
| 106 | +``` |
| 107 | + |
| 108 | +**Output**: |
| 109 | +- Creates a directory: `helm-chart/{commit}-{ref}-stage/` |
| 110 | +- Contains the updated helm chart with RedHat configurations |
| 111 | +- Includes generated `README.md` documentation |
| 112 | +- Creates a packaged chart: `{chart-name}-{version}.tgz` |
| 113 | +- Pushes the chart to OCI registry |
| 114 | + |
| 115 | +**Image Repository**: |
| 116 | +- Stage: `quay.io/redhat-user-workloads/rh-openshift-gitops-tenant/argocd-agent-rhel8` |
| 117 | + |
| 118 | +**OCI Registry**: |
| 119 | +- Default: `oci://quay.io/anandrkskd/argocd-agent` |
| 120 | +- Can be overridden using `HELM_OCI_REGISTRY` environment variable |
| 121 | + |
| 122 | +--- |
| 123 | + |
| 124 | +## Key Differences |
| 125 | + |
| 126 | +| Feature | `publish.sh` | `publish-stage.sh` | |
| 127 | +|---------|--------------|-------------------| |
| 128 | +| **Purpose** | Production release | Stage release | |
| 129 | +| **Image Repository** | `registry.redhat.io/openshift-gitops-1/argocd-agent-rhel8` | `quay.io/redhat-user-workloads/rh-openshift-gitops-tenant/argocd-agent-rhel8` | |
| 130 | +| **Output Directory** | `{commit}-{ref}` | `{commit}-{ref}-stage` | |
| 131 | +| **Tag Validation** | Strict format validation | No strict validation | |
| 132 | +| **Packaging** | No | Yes (creates `.tgz` file) | |
| 133 | +| **OCI Push** | No | Yes (pushes to OCI registry) | |
| 134 | +| **Helm Required** | No | Yes | |
| 135 | + |
| 136 | +## Workflow |
| 137 | + |
| 138 | +### Production Release (`publish.sh`) |
| 139 | + |
| 140 | +```bash |
| 141 | +# 1. Ensure you're on main branch or a tagged commit |
| 142 | +git checkout main |
| 143 | +# or |
| 144 | +git checkout <tagged-branch> |
| 145 | + |
| 146 | +# 2. Run the script with the image tag |
| 147 | +./helm-chart/publish.sh v1.18.1-2 |
| 148 | + |
| 149 | +# 3. The updated chart is available in: |
| 150 | +# helm-chart/{commit}-{ref}/ |
| 151 | +``` |
| 152 | + |
| 153 | +### Stage Release (`publish-stage.sh`) |
| 154 | + |
| 155 | +```bash |
| 156 | +# 1. Ensure you're on main branch or a tagged commit |
| 157 | +git checkout main |
| 158 | +# or |
| 159 | +git checkout <tagged-branch> |
| 160 | + |
| 161 | +# 2. Ensure you're authenticated to the OCI registry |
| 162 | +# (helm will use your configured credentials) |
| 163 | + |
| 164 | +# 3. Run the script with the image tag |
| 165 | +# Using default OCI registry |
| 166 | +./helm-chart/publish-stage.sh v1.18.1-2 |
| 167 | + |
| 168 | +# Or use a custom OCI registry |
| 169 | +HELM_OCI_REGISTRY="oci://quay.io/my-org/my-charts" ./helm-chart/publish-stage.sh v1.18.1-2 |
| 170 | + |
| 171 | +# 4. The chart is packaged and pushed to the OCI registry |
| 172 | +# (default: oci://quay.io/anandrkskd/argocd-agent) |
| 173 | +``` |
| 174 | + |
| 175 | +## Configuration |
| 176 | + |
| 177 | +Both scripts read configuration from `config.yaml` in the repository root. They extract: |
| 178 | +- `commit`: The commit hash for `sources/argocd-agent` |
| 179 | +- `ref`: The reference (branch/tag) for `sources/argocd-agent` |
| 180 | + |
| 181 | +Example `config.yaml` structure: |
| 182 | +```yaml |
| 183 | +sources: |
| 184 | + - path: sources/argocd-agent |
| 185 | + commit: abc123def456 |
| 186 | + ref: v1.18.1 |
| 187 | +``` |
| 188 | +
|
| 189 | +## Output Structure |
| 190 | +
|
| 191 | +After running either script, the output directory contains: |
| 192 | +``` |
| 193 | +{commit}-{ref}[-stage]/ |
| 194 | +├── Chart.yaml # Updated with RedHat metadata |
| 195 | +├── values.yaml # Updated with RedHat image repository and tag |
| 196 | +├── README.md # Auto-generated documentation |
| 197 | +├── templates/ # Helm chart templates |
| 198 | +└── ... # Other chart files |
| 199 | +``` |
| 200 | + |
| 201 | +For `publish-stage.sh`, an additional `.tgz` file is created: |
| 202 | +``` |
| 203 | +{chart-name}-{version}.tgz # Packaged helm chart |
| 204 | +``` |
| 205 | + |
| 206 | +## Troubleshooting |
| 207 | + |
| 208 | +### Common Issues |
| 209 | + |
| 210 | +1. **"yq not found"** |
| 211 | + - Ensure `yq` is installed at `bin/yq` in the repository root |
| 212 | + - Check file permissions |
| 213 | + |
| 214 | +2. **"helm-docs is not installed"** |
| 215 | + - Install: `go install github.com/norwoodj/helm-docs/cmd/helm-docs@latest` |
| 216 | + - Ensure `$GOPATH/bin` or `$GOBIN` is in your PATH |
| 217 | + |
| 218 | +3. **"Failed to initialize argocd-agent submodule"** |
| 219 | + - Run: `git submodule update --init --recursive sources/argocd-agent` |
| 220 | + - Check submodule configuration in `.gitmodules` |
| 221 | + |
| 222 | +4. **"config.yaml not found"** |
| 223 | + - Ensure `config.yaml` exists in the repository root |
| 224 | + - Verify the file contains the required `sources` section |
| 225 | + |
| 226 | +5. **"Failed to push helm chart to OCI registry"** (publish-stage.sh only) |
| 227 | + - Ensure you're authenticated to the OCI registry |
| 228 | + - Check registry permissions |
| 229 | + - Verify the registry URL is correct |
| 230 | + |
| 231 | +6. **"Invalid tag format"** (publish.sh only) |
| 232 | + - Tag must match: `v<major>.<minor>.<patch>[-<build>]` |
| 233 | + - Examples: `v1.18.1`, `v1.18.1-2` |
| 234 | + - Note: `publish-stage.sh` does not validate tag format |
| 235 | + |
| 236 | +## Notes |
| 237 | + |
| 238 | +- ⚠️ **Important**: These scripts should be run from a tagged branch or from the `main` branch |
| 239 | +- The scripts create copies of the helm chart; they do not modify the original submodule |
| 240 | +- All file operations preserve attributes and permissions using `cp -a` |
| 241 | +- The scripts use colored output for better readability (INFO=green, WARN=yellow, ERROR=red) |
| 242 | + |
0 commit comments