Skip to content

Commit 896445d

Browse files
feat(helm-release-oci): Add input to override apiVersion (#60)
1 parent 3f7be40 commit 896445d

6 files changed

Lines changed: 40 additions & 4 deletions

File tree

.github/actions/helm-release-oci/action.yaml

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ inputs:
3131
description: Optional values file for helm lint (path is resolved from chart_path working directory)
3232
required: false
3333
default: ""
34+
chart_version:
35+
description: Helm chart version (overrides appVersion-derived version when provided)
36+
required: false
37+
default: ""
3438

3539
outputs:
3640
chart_name:
@@ -96,6 +100,8 @@ runs:
96100
- name: Update versions
97101
shell: bash
98102
working-directory: ${{ inputs.chart_path }}
103+
env:
104+
CHART_VERSION_OVERRIDE: ${{ inputs.chart_version }}
99105
run: |
100106
if [[ "$GITHUB_REF_TYPE" == "branch" ]]
101107
then
@@ -108,14 +114,20 @@ runs:
108114
else
109115
APP_VERSION="${GITHUB_REF_NAME##*/}"
110116
fi
111-
117+
118+
if [[ -n "$CHART_VERSION_OVERRIDE" ]]; then
119+
CHART_VERSION="$CHART_VERSION_OVERRIDE"
120+
else
121+
CHART_VERSION="$(echo "$APP_VERSION" | sed 's/^v//')"
122+
fi
123+
112124
echo "Updating Chart.yaml"
113125
114-
APP_VERSION="$APP_VERSION" yq -i '
115-
.version = (strenv(APP_VERSION) | sub("^v"; "")) |
126+
APP_VERSION="$APP_VERSION" CHART_VERSION="$CHART_VERSION" yq -i '
127+
.version = strenv(CHART_VERSION) |
116128
.appVersion = strenv(APP_VERSION)
117129
' Chart.yaml
118-
130+
119131
cat Chart.yaml
120132
121133
- name: Read chart metadata

.github/workflows/helm-release-ecr.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,11 @@ on:
5050
type: string
5151
required: false
5252
default: ""
53+
chart_version:
54+
description: Helm chart version (overrides appVersion-derived version when provided)
55+
type: string
56+
required: false
57+
default: ""
5358
runner:
5459
description: GitHub Actions runner to use. Supports a single label or a JSON array of labels.
5560
type: string
@@ -139,3 +144,4 @@ jobs:
139144
bump_version_git_branch: ${{ inputs.bump_version_git_branch }}
140145
lint_enabled: ${{ inputs.lint_enabled }}
141146
lint_values_file: ${{ inputs.lint_values_file }}
147+
chart_version: ${{ inputs.chart_version }}

.github/workflows/helm-release-gar.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,11 @@ on:
5050
type: string
5151
required: false
5252
default: ""
53+
chart_version:
54+
description: Helm chart version (overrides appVersion-derived version when provided)
55+
type: string
56+
required: false
57+
default: ""
5358
runner:
5459
description: GitHub Actions runner to use. Supports a single label or a JSON array of labels.
5560
type: string
@@ -144,3 +149,4 @@ jobs:
144149
bump_version_git_branch: ${{ inputs.bump_version_git_branch }}
145150
lint_enabled: ${{ inputs.lint_enabled }}
146151
lint_values_file: ${{ inputs.lint_values_file }}
152+
chart_version: ${{ inputs.chart_version }}

.github/workflows/helm-release-github.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@ on:
4141
type: string
4242
required: false
4343
default: ""
44+
chart_version:
45+
description: Helm chart version (overrides appVersion-derived version when provided)
46+
type: string
47+
required: false
48+
default: ""
4449
runner:
4550
description: GitHub Actions runner to use. Supports a single label or a JSON array of labels.
4651
type: string
@@ -118,3 +123,4 @@ jobs:
118123
bump_version_git_branch: ${{ inputs.bump_version_git_branch }}
119124
lint_enabled: ${{ inputs.lint_enabled }}
120125
lint_values_file: ${{ inputs.lint_values_file }}
126+
chart_version: ${{ inputs.chart_version }}

.github/workflows/helm-release-oci-test.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ jobs:
2424
push_chart: "false"
2525
bump_version_in_git: "false"
2626
lint_enabled: "true"
27+
chart_version: "" # test empty
2728

2829
case_github_wrapper_success:
2930
name: Case - GitHub wrapper succeeds
@@ -34,6 +35,7 @@ jobs:
3435
push_chart: false
3536
bump_version_in_git: false
3637
lint_enabled: true
38+
chart_version: "1.0.0-override" # test override
3739

3840
case_ecr_wrapper_success:
3941
name: Case - ECR wrapper succeeds

docs/helm-release.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ Legacy note:
2222
- `bump_version_git_branch` (`string`, optional, default `""`): Override target branch for bump commit. If empty, uses current ref name.
2323
- `lint_enabled` (`boolean`, optional, default `true`): Run `helm lint` before package.
2424
- `lint_values_file` (`string`, optional, default `""`): Optional values file for helm lint (path is resolved from `chart_path`).
25+
- `chart_version` (`string`, optional, default `""`): Optional helm chart version (overrides appVersion-derived version when provided).
2526

2627
Note:
2728
- Version bump commit is intentionally tied to `push_chart=true`.
@@ -45,6 +46,7 @@ Inputs:
4546
- `bump_version_git_branch` (optional, default empty)
4647
- `lint_enabled` (optional, default `true`)
4748
- `lint_values_file` (optional, default empty)
49+
- `chart_version` (`string`, optional, default `""`): Optional helm chart version (overrides appVersion-derived version when provided).
4850

4951
Secrets:
5052
- `token` (required when `push_chart=true`): token used for GHCR login.
@@ -94,6 +96,7 @@ Inputs:
9496
- `bump_version_git_branch` (optional, default empty)
9597
- `lint_enabled` (optional, default `true`)
9698
- `lint_values_file` (optional, default empty)
99+
- `chart_version` (`string`, optional, default `""`): Optional helm chart version (overrides appVersion-derived version when provided).
97100

98101
Secrets:
99102
- `GITHUB_APP_ID` and `GITHUB_APP_KEY` (optional): only needed when both `push_chart=true` and `bump_version_in_git=true`.
@@ -142,6 +145,7 @@ Inputs:
142145
- `bump_version_git_branch` (optional, default empty)
143146
- `lint_enabled` (optional, default `true`)
144147
- `lint_values_file` (optional, default empty)
148+
- `chart_version` (`string`, optional, default `""`): Optional helm chart version (overrides appVersion-derived version when provided).
145149

146150
Secrets:
147151
- `GITHUB_APP_ID` and `GITHUB_APP_KEY` (optional): only needed when both `push_chart=true` and `bump_version_in_git=true`.

0 commit comments

Comments
 (0)