Skip to content

Commit ba06689

Browse files
committed
Correct "Release on Tag" GHA
The original GHA commit (d4db430) was merged preemptively before it was sufficiently tests. This commit contains a variety of fixes discovered while testing the original implementation. (cherry picked from commit b23b0e1)
1 parent b983f14 commit ba06689

File tree

7 files changed

+1486
-1467
lines changed

7 files changed

+1486
-1467
lines changed

.changie.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ projects:
4343
# Update operator's Chart.yaml
4444
- path: operator/chart/Chart.yaml
4545
find: '^version: .*$'
46-
replace: 'version: {{.Version}}'
46+
replace: 'version: {{.VersionNoPrefix}}'
4747
- path: operator/chart/Chart.yaml
4848
find: '^appVersion: .*$'
4949
replace: 'appVersion: {{.Version}}'

.github/workflows/release.yml

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ jobs:
3131
tag="${{ github.ref_name }}"
3232
fi
3333
echo "using ref name: $tag"
34-
echo "ref_name=$tag" >> "$github_output"
34+
echo "ref_name=$tag" >> "$GITHUB_OUTPUT"
3535
3636
- name: checkout code
3737
uses: actions/checkout@v4
@@ -53,35 +53,52 @@ jobs:
5353
run: |
5454
# turn refs into slightly friendlier names. e.g. operator/v1.2.3 -> operator: v1.2.3
5555
release_name="$(echo "${{ steps.get_ref.outputs.ref_name }}" | sed 's|/v|: v|')"
56-
echo "release_name=$release_name" >> "$github_output"
56+
echo "release_name=$release_name" >> "$GITHUB_OUTPUT"
5757
5858
- name: package helm chart
5959
run: |
60+
set -ex
6061
tag="${{ steps.get_ref.outputs.ref_name }}"
6162
# extract the directory from the tag (e.g., "operator" from "operator/v1.2.3")
6263
dir="$(dirname "$tag")"
6364
# search for chart.yaml in $dir or one directory deep (e.g., operator/chart)
64-
chart_path=$(find "$dir" -maxdepth 2 -type f -name "chart.yaml" | head -n 1)
65+
chart_path=$(find "$dir" -maxdepth 2 -type f -name "Chart.yaml" | head -n 1)
6566
# exit early if no chart.yaml file is found
6667
if [[ -z "$chart_path" ]]; then
6768
echo "no chart.yaml found for $tag. skipping step."
6869
exit 0
6970
fi
7071
72+
# Explicitly set the version based on the tag, stripping the leading
73+
# v. This is done due to a mishap in managing the operator's version.
74+
# All our charts specify `version` without a leading v but the
75+
# operator's chart accidentally began doing so when binding version
76+
# and appVersion.
77+
# We enforce uniformity here, which retroactively corrects this
78+
# issue.
79+
version="$(basename "$tag")"
80+
version="${version#v}"
81+
7182
echo "packaging chart at $chart_path"
72-
helm package -u "$(dirname "$chart_path")"
83+
helm package -u --version "$version" "$(dirname "$chart_path")"
84+
85+
- name: reformat change log
86+
run: |
87+
# Our CHANGE LOGS begin with '## VERSION - DATE', which is
88+
# duplicative to include in the GH release body. tail -n +2 will
89+
# remove the first line.
90+
tail -n +2 .changes/${{ steps.get_ref.outputs.ref_name }}.md > RELEASE_BODY.md
7391
7492
# create github release and upload file
7593
- name: create github release
76-
if: github.ref_type == 'tag'
7794
uses: softprops/action-gh-release@v2
7895
with:
79-
name: steps.release_name.outputs.release_name
80-
tag_name: steps.get_ref.outputs.ref_name
96+
name: ${{ steps.release_name.outputs.release_name }}
97+
tag_name: ${{ steps.get_ref.outputs.ref_name }}
8198
draft: false
8299
make_latest: false
83100
prerelease: ${{ contains(steps.get_ref.outputs.ref_name, '-alpha') || contains(steps.get_ref.outputs.ref_name, '-beta') }}
84-
body_path: ".changes/${{ steps.get_ref.outputs.ref_name }}.md" # pull the release body from changie.
101+
body_path: RELEASE_BODY.md
85102
# if a chart was packaged, we'll upload it to this release preserving helm's naming convention.
86103
files: |
87104
./*.tgz

CONTRIBUTING.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,11 +97,12 @@ Releases](https://redpandadata.atlassian.net/projects/K8S?selectedItem=com.atlas
9797
To release any project in this repository:
9898
1. Mint the version and its CHANGELOG.md entry via `changie batch -j <project> <version>`
9999
- If minting a pre-release, specify `-k` to keep the unreleased changes in place for the official release.
100+
- Manually review the contents and make any formatting or language adjustments as need be.
100101
2. Run `task test:unit` and `task lint`, they will report additional required actions, if any.
101102
4. Commit the resultant diff with the commit message `<project>: cut release <version>` and rebase it into master via a Pull Request.
102103
5. Tag the above commit with as `<project>/v<version>` with `git tag $(changie latest -j <project>) <commit-sha>`.
103104
6. Push the tags.
104-
7. Verify that the Release Workflow ran successfully.
105+
7. Verify that the [Release Workflow](./.github/workflows/release.yml) ran successfully.
105106
8. If applicable, mark the newly minted release as the "latest".
106107

107108
## Nightly build

operator/chart/Chart.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@ description: Redpanda operator helm chart
44
type: application
55

66
# The operator helm chart is considered part of the operator itself. Therefore
7-
# version == appVersion.
8-
version: v25.1.1-beta3
7+
# version == appVersion. Our charts' versions, don't include a leading `v`, so
8+
# we match that precedence here.
9+
version: 25.1.1-beta3
910
appVersion: v25.1.1-beta3
1011
kubeVersion: ">= 1.25.0-0"
1112

operator/chart/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
description: Find the default values and descriptions of settings in the Redpanda Operator Helm chart.
44
---
55

6-
![Version: v25.1.1-beta3](https://img.shields.io/badge/Version-v25.1.1--beta3-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: v25.1.1-beta3](https://img.shields.io/badge/AppVersion-v25.1.1--beta3-informational?style=flat-square)
6+
![Version: 25.1.1-beta3](https://img.shields.io/badge/Version-25.1.1--beta3-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: v25.1.1-beta3](https://img.shields.io/badge/AppVersion-v25.1.1--beta3-informational?style=flat-square)
77

88
This page describes the official Redpanda Operator Helm Chart. In particular, this page describes the contents of the chart’s [`values.yaml` file](./values.yaml). Each of the settings is listed and described on this page, along with any default values.
99

operator/chart/chart_test.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,9 @@ import (
4040
"github.com/redpanda-data/redpanda-operator/pkg/testutil"
4141
)
4242

43-
type ChartYAML struct {
44-
Version string `json:"version"`
45-
AppVersion string `json:"appVersion"`
46-
Annotations map[string]string `json:"annotations"`
43+
type ImageAnnotation struct {
44+
Name string `json:"name"`
45+
Image string `json:"image"`
4746
}
4847

4948
func TestChartYaml(t *testing.T) {
@@ -55,16 +54,17 @@ func TestChartYaml(t *testing.T) {
5554

5655
expectedVersion := string(out[len("operator/"):])
5756

58-
assert.Equal(t, expectedVersion, Chart.Metadata().Version, "Chart.yaml's version should match `%s: %s", changieCmd, expectedVersion)
57+
assert.Equal(t, expectedVersion, Chart.Metadata().AppVersion, "Chart.yaml's appVersion should match `%s: %s", changieCmd, expectedVersion)
58+
assert.Equal(t, expectedVersion[1:], Chart.Metadata().Version, "Chart.yaml's version should match `%s: %s", changieCmd, expectedVersion)
5959

60-
assert.Equal(t, Chart.Metadata().AppVersion, Chart.Metadata().Version, "The Operator and its chart are distributed as the same package. Any changes to appVersion should be made to version and visa vera.")
60+
var operatorImages []ImageAnnotation
61+
require.NoError(t, yaml.Unmarshal([]byte(Chart.Metadata().Annotations["artifacthub.io/images"]), &operatorImages))
6162

62-
assert.Contains(
63-
t,
64-
Chart.Metadata().Annotations["artifacthub.io/images"],
65-
fmt.Sprintf("%s:%s", operatorRepo, expectedVersion),
66-
"artifacthub.io/images should be in sync with .version",
67-
)
63+
var redpandaImages []ImageAnnotation
64+
require.NoError(t, yaml.Unmarshal([]byte(redpanda.Chart.Metadata().Annotations["artifacthub.io/images"]), &redpandaImages))
65+
66+
assert.Equal(t, operatorImages[1], redpandaImages[0], "artifacthub.io/images should be in sync with the vendored redpanda chart")
67+
assert.Equal(t, fmt.Sprintf("%s:%s", operatorRepo, expectedVersion), operatorImages[0].Image, "artifacthub.io/images should be in sync with appVersion")
6868
}
6969

7070
func TestRBACBindings(t *testing.T) {

0 commit comments

Comments
 (0)