Skip to content

Commit 2c5324f

Browse files
committed
feat: add Makefile rule to sync chart version
1 parent b6909e3 commit 2c5324f

File tree

7 files changed

+68
-17
lines changed

7 files changed

+68
-17
lines changed

.github/workflows/lint.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@ jobs:
1313
steps:
1414
- name: Checkout code
1515
uses: actions/checkout@v4
16+
with:
17+
fetch-depth: 0 # Required for fetch git tags step
18+
19+
# Ensure git tags are available for version scripts
20+
- name: Fetch git tags
21+
run: git fetch --tags --force
1622

1723
- name: Setup Go
1824
uses: actions/setup-go@v2

Makefile

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,26 @@ lint/helm/prometheus-rules:
3333

3434
.PHONY: lint/helm/prometheus-rules
3535

36+
# Set coder-observability/Chart.yaml version to the latest stable git tag
37+
# TODO: auto-update chart version in Chart.yaml when a new release is published
38+
chart/version-sync:
39+
version=$(shell ./scripts/version.sh -s) && \
40+
if [ -z "$$version" ]; then \
41+
echo "No git tag found. Cannot set Chart.yaml version" >&2; \
42+
exit 1; \
43+
fi; \
44+
yq -i e ".version = \"$$version\"" coder-observability/Chart.yaml
45+
.PHONY: chart/version-sync
46+
3647
# Usage: publish-patch, publish-minor, publish-major
3748
# Publishing is handled by GitHub Actions, triggered by tag creation.
3849
publish-%:
3950
version=$(shell ./scripts/version.sh --bump $*) && \
40-
git tag --sign "$$version" -m "Release: $$version" && \
51+
git tag --sign "$$version" -m "Release: $$version" && \
4152
git push origin tag "$$version"
4253

43-
readme:
54+
# TODO: auto-update chart version in README files when a new release is published
55+
readme: chart/version-sync
4456
go install github.com/norwoodj/helm-docs/cmd/helm-docs@latest
4557
helm-docs --output-file ../README.md \
4658
--values-file=values.yaml --chart-search-root=coder-observability --template-files=../README.gotmpl

PUBLISH.md

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,29 @@
11
# Publishing the Coder Observability Chart
22

3-
- make desired changes
4-
- run `make publish-{major|minor|patch}` which creates & pushes a new tag, which kicks off a GH Action to publish the chart
3+
This repo supports both official (stable) releases and release candidates (RCs).
4+
5+
## Official release (stable)
6+
7+
Use this when you’re ready to publish a new release.
8+
9+
1) Make desired changes and ensure CI is green
10+
2) Cut and push a new tag:
11+
- Patch: `make publish-patch`
12+
- Minor: `make publish-minor`
13+
- Major: `make publish-major`
14+
15+
This creates and pushes a new stable tag (e.g., 0.4.1), which kicks off a GitHub Action to package and publish the chart.
16+
17+
## Release candidate (RC)
18+
19+
To create a new RC version:
20+
21+
```shell
22+
VERSION=v0.4.0-rc.1
23+
git tag "$VERSION" -m "Release: $VERSION"
24+
git push origin tag "$VERSION"
25+
```
26+
27+
## Helm repo
28+
29+
Use Artifact Hub to browse/search releases: https://artifacthub.io/packages/helm/coder-observability/coder-observability

README.gotmpl

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,9 @@ Logs will be scraped from all pods in the Kubernetes cluster.
2020

2121
## Installation
2222

23-
<!-- TODO: auto-update version here from publish script -->
24-
2523
```bash
2624
helm repo add coder-observability https://helm.coder.com/observability
27-
helm upgrade --install coder-observability coder-observability/coder-observability --version 0.1.1 --namespace coder-observability --create-namespace
25+
helm upgrade --install coder-observability coder-observability/coder-observability --version {{ template "chart.version" . }} --namespace coder-observability --create-namespace
2826
```
2927

3028
## Requirements

README.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,9 @@ Logs will be scraped from all pods in the Kubernetes cluster.
2020

2121
## Installation
2222

23-
<!-- TODO: auto-update version here from publish script -->
24-
2523
```bash
2624
helm repo add coder-observability https://helm.coder.com/observability
27-
helm upgrade --install coder-observability coder-observability/coder-observability --version 0.1.1 --namespace coder-observability --create-namespace
25+
helm upgrade --install coder-observability coder-observability/coder-observability --version 0.3.5 --namespace coder-observability --create-namespace
2826
```
2927

3028
## Requirements

coder-observability/Chart.yaml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
apiVersion: v2
22
name: coder-observability
33
description: Gain insights into your Coder deployment
4-
54
type: application
6-
version: 0.1.0
5+
version: 0.3.5
76
dependencies:
87
- name: pyroscope
98
condition: pyroscope.enabled
@@ -39,4 +38,4 @@ sources:
3938
- https://github.com/coder/observability
4039
icon: https://helm.coder.com/coder_logo_black.png
4140
annotations:
42-
artifacthub.io/category: monitoring-logging
41+
artifacthub.io/category: monitoring-logging

scripts/version.sh

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,18 @@
88
set -euo pipefail
99

1010
remote_url=$(git remote get-url origin)
11+
# Newest tag by semantic version (may include prerelease like -rc/-beta/-alpha)
1112
current_version="$(git tag -l | sort --version-sort | tail -n1)"
13+
# Newest stable version tag (strict X.Y.Z; excludes prereleases)
14+
stable_version="$(git tag -l | sort --version-sort | grep -E '^(v)?[0-9]+\.[0-9]+\.[0-9]+$' | tail -n1)"
1215

1316
function help() {
1417
echo "$0 [options] [arguments]"
1518
echo " "
1619
echo "options:"
1720
echo "-h, --help show brief help"
1821
echo "-c, --current show the current version"
22+
echo "-s, --stable show the current stable version"
1923
echo "-b, --bump bump the version based on the given argument"
2024
exit 0
2125
}
@@ -25,11 +29,11 @@ function bump_version() {
2529
local new_version
2630

2731
if [[ $version == "major" ]]; then
28-
new_version=$(echo $current_version | sed 's/^v//' | awk -F. '{print "v" $1+1".0.0"}')
32+
new_version=$(echo $stable_version | sed 's/^v//' | awk -F. '{print "v" $1+1".0.0"}')
2933
elif [[ $version == "minor" ]]; then
30-
new_version=$(echo $current_version | awk -F. '{print $1"."$2+1".0"}')
34+
new_version=$(echo $stable_version | awk -F. '{print $1"."$2+1".0"}')
3135
elif [[ $version == "patch" ]]; then
32-
new_version=$(echo $current_version | awk -F. '{print $1"."$2"."$3+1}')
36+
new_version=$(echo $stable_version | awk -F. '{print $1"."$2"."$3+1}')
3337
else
3438
echo "Error: Unknown argument $version"
3539
exit 1
@@ -38,11 +42,16 @@ function bump_version() {
3842
echo $new_version
3943
}
4044

45+
# Show the newest tag (stable or prerelease like -rc/-beta/-alpha), without the leading 'v'.
4146
function show_current() {
42-
# Version without the "v" prefix.
4347
echo "${current_version#v}"
4448
}
4549

50+
# Show the newest stable tag (strict X.Y.Z), without the leading 'v'.
51+
function show_stable() {
52+
echo "${stable_version#v}"
53+
}
54+
4655
if [ $# == 0 ]; then
4756
show_current
4857
fi
@@ -56,6 +65,10 @@ while test $# -gt 0; do
5665
show_current
5766
shift
5867
;;
68+
-s|--stable)
69+
show_stable
70+
shift
71+
;;
5972
-b|--bump)
6073
if [ $# -lt 2 ]; then
6174
echo "Error: Missing argument for bump"

0 commit comments

Comments
 (0)