Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions .github/workflows/crds.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,27 @@ jobs:
token: ${{ secrets.VM_BOT_GH_TOKEN }}
path: __vm-charts-repo

- name: Check operator chart app version
id: chart
env:
RELEASE_VERSION: ${{ github.event.release.tag_name }}
run: |
chart_app_version=$(yq -r '.appVersion // ""' charts/victoria-metrics-operator/Chart.yaml)
if [ -z "$chart_app_version" ]; then
echo "failed to read chart appVersion"
exit 1
fi

update=$(python3 ../__vm-operator-repo/hack/compare_versions.py "$chart_app_version" "$RELEASE_VERSION")
echo "update=$update" >> "$GITHUB_OUTPUT"

if [ "$update" = "false" ]; then
echo "Skipping CRD update for $RELEASE_VERSION, chart appVersion is $chart_app_version"
fi
working-directory: __vm-charts-repo

- name: Import GPG key
if: steps.chart.outputs.update == 'true'
uses: crazy-max/ghaction-import-gpg@2dc316deee8e90f13e1a351ab510b4d5bc0c82cd # v7.0.0
id: import-gpg
with:
Expand All @@ -41,6 +61,7 @@ jobs:
workdir: __vm-charts-repo

- name: Update crd yaml in chart repo
if: steps.chart.outputs.update == 'true'
id: update
run: |
cp ../__vm-operator-repo/config/crd/overlay/crd.descriptionless.yaml charts/victoria-metrics-operator/charts/crds/crds/crd.yaml
Expand All @@ -52,6 +73,7 @@ jobs:
working-directory: __vm-charts-repo

- name: Create Pull Request
if: steps.chart.outputs.update == 'true'
uses: peter-evans/create-pull-request@5f6978faf089d4d20b00c7766989d076bb2fc7f1 # v8.1.1
with:
add-paths: charts
Expand Down
32 changes: 32 additions & 0 deletions hack/compare_versions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/usr/bin/env python3
import sys


def parse_version(version):
"""Parses a version string into a tuple of integers."""
return tuple(
int(part) for part in version.removeprefix("v").split("-", 1)[0].split(".")
)


def main():
if len(sys.argv) != 3:
print(
"usage: compare_versions.py <current-version> <release-version>",
file=sys.stderr,
)
return 2

try:
current_version = parse_version(sys.argv[1])
release_version = parse_version(sys.argv[2])
except ValueError as e:
print(f"failed to parse version: {e}", file=sys.stderr)
return 2

print("true" if release_version >= current_version else "false")
return 0


if __name__ == "__main__":
sys.exit(main())