-
Notifications
You must be signed in to change notification settings - Fork 1.1k
129 lines (117 loc) · 4.34 KB
/
Copy pathcheck-release.yaml
File metadata and controls
129 lines (117 loc) · 4.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
name: Check Release
on:
pull_request:
branches:
- master
paths:
- VERSION
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
SEMVER_PATTERN: '^(v)?([0-9]+)\.([0-9]+)\.([0-9]+)(-rc\.([0-9]+))?$'
CHART_FILE: charts/kubeflow-trainer/Chart.yaml
PY_API_VERSION_FILE: api/python_api/kubeflow_trainer_api/__init__.py
jobs:
check:
runs-on: ubuntu-latest
steps:
- name: Checkout source code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Parse version and export env vars
run: |
RAW_VERSION=$(cat VERSION | tr -d ' \n\r')
VERSION=${RAW_VERSION#v}
if [[ ${RAW_VERSION} =~ ${{ env.SEMVER_PATTERN }} ]]; then
echo "Version '${RAW_VERSION}' matches semver pattern."
else
echo "Version '${RAW_VERSION}' does not match semver pattern."
exit 1
fi
TAG="v${VERSION}"
echo "VERSION=${VERSION}" >> $GITHUB_ENV
echo "TAG=${TAG}" >> $GITHUB_ENV
- name: Check if tag exists
run: |
git fetch --tags
if git tag -l | grep -q "^${TAG}$"; then
echo "Tag '${TAG}' already exists."
exit 1
else
echo "Tag '${TAG}' does not exist."
fi
- name: Check if manifests image tag matches version
run: |
MANIFEST_TAGS=$(grep -r 'newTag:' manifests | sed 's/.*newTag:[[:space:]]*//' | tr -d '"' | tr -d "'" | sort | uniq)
if [ -z "$MANIFEST_TAGS" ]; then
echo "No newTag found in manifests."
exit 1
fi
for t in $MANIFEST_TAGS; do
if [ "$t" != "$TAG" ]; then
echo "Image tag in manifests ($t) does not match version tag ($TAG)."
exit 1
fi
done
echo "All image tags in manifests match version tag $TAG."
- name: Check Helm chart version
run: |
CHART_VERSION=$(grep -E '^version:' "$CHART_FILE" | head -n1 | awk '{print $2}')
if [ -z "$CHART_VERSION" ]; then
echo "Chart version not found in $CHART_FILE"
exit 1
fi
if [ "$CHART_VERSION" != "$VERSION" ]; then
echo "Chart version ($CHART_VERSION) does not match VERSION ($VERSION)."
exit 1
fi
echo "Chart version matches VERSION ($VERSION)."
- name: Check Python API version
run: |
PY_VER=$(python - <<'PY'
import os
import re
import sys
from pathlib import Path
path = Path(os.environ["PY_API_VERSION_FILE"])
text = path.read_text()
match = re.search(r"__version__\s*=\s*['\"]([^'\"]+)['\"]", text)
if not match:
print("__version__ not found", file=sys.stderr)
sys.exit(1)
print(match.group(1))
PY
)
if [ "$PY_VER" != "$VERSION" ]; then
echo "Python API version ($PY_VER) does not match VERSION ($VERSION)."
exit 1
fi
echo "Python API version matches VERSION ($VERSION)."
- name: Check configmap version in manager overlay
run: |
MANAGER_KUSTOMIZE="manifests/overlays/manager/kustomization.yaml"
if [ ! -f "$MANAGER_KUSTOMIZE" ]; then
echo "Manager kustomization not found: $MANAGER_KUSTOMIZE"
exit 1
fi
CM_VERSION=$(grep 'kubeflow_trainer_version=' "$MANAGER_KUSTOMIZE" | sed 's/.*kubeflow_trainer_version=//' | tr -d ' \t')
if [ -z "$CM_VERSION" ]; then
echo "kubeflow_trainer_version not found in $MANAGER_KUSTOMIZE."
exit 1
fi
if [ "$CM_VERSION" != "$TAG" ]; then
echo "Configmap version ($CM_VERSION) does not match version tag ($TAG)."
exit 1
fi
echo "Configmap version matches version tag $TAG."
- name: Check data-cache image is pinned
run: |
UNPINNED=$(grep -rn 'ghcr\.io/kubeflow/trainer/[A-Za-z0-9._/-]*:latest' manifests || true)
if [ -n "$UNPINNED" ]; then
echo "Found unpinned :latest image references in manifests:"
echo "$UNPINNED"
exit 1
fi
echo "All inline image references in manifests are pinned (no :latest)."