Skip to content

Commit 45ebf0e

Browse files
authored
Merge pull request #1525 from zhanggbj/fix_scr
🐛 Fix releasing scripts
2 parents 72fd620 + b95b32a commit 45ebf0e

File tree

1 file changed

+46
-6
lines changed

1 file changed

+46
-6
lines changed

hack/update-docs.sh

Lines changed: 46 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,44 @@ install_yq() {
2424
}
2525

2626
install_tools() {
27+
# sed
28+
# Detect macOS and install GNU sed if needed
29+
if [[ "$OSTYPE" == "darwin"* ]]; then
30+
SED_INSTALL_DIR="$HOME/.local/gsed"
31+
SED_BIN="${SED_INSTALL_DIR}/bin/sed"
32+
echo "Detected macOS. Checking for gsed..."
33+
34+
if ! command -v gsed >/dev/null 2>&1; then
35+
echo "GNU sed not found. Installing from source..."
36+
37+
TMP_DIR=$(mktemp -d)
38+
pushd "$TMP_DIR"
39+
40+
# Download GNU sed source
41+
curl -LO https://ftp.gnu.org/gnu/sed/sed-4.9.tar.gz
42+
tar -xzf sed-4.9.tar.gz
43+
cd sed-4.9
44+
45+
# Configure, build, install into target dir
46+
./configure --prefix="${SED_INSTALL_DIR}"
47+
make -j"$(sysctl -n hw.logicalcpu)"
48+
make install
49+
50+
popd
51+
rm -rf "$TMP_DIR"
52+
53+
echo "GNU sed installed to ${SED_INSTALL_DIR}"
54+
else
55+
echo "gsed already installed."
56+
SED_BIN=$(command -v gsed)
57+
fi
58+
59+
export PATH="${SED_INSTALL_DIR}/bin:$PATH"
60+
else
61+
echo "Detected Linux. Using system sed."
62+
SED_BIN="sed"
63+
fi
64+
2765
# yq
2866
if ! command -v yq &> /dev/null; then
2967
echo "yq is not installed."
@@ -85,10 +123,10 @@ update_readme_table() {
85123
}
86124

87125
update_readme_files() {
88-
sed -i "s/latest version of cloud provider vsphere(\(.*\))/latest version of cloud provider vsphere(${release_version})/g" "${REPO_ROOT}"/releases/README.md
89-
sed -i "s/the major version of '[0-9]\+\.[0-9]\+.x' is '[0-9]\+\.[0-9]\+'/the major version of '${major_minor_version:1}.x' is '${major_minor_version:1}'/g" "${REPO_ROOT}"/releases/README.md
90-
sed -i "s/VERSION=[0-9]\+\.[0-9]\+/VERSION=${major_minor_version:1}/g" "${REPO_ROOT}"/releases/README.md
91-
sed -i "/<== latest version/c\\registry.k8s.io/cloud-pv-vsphere/cloud-provider-vsphere:${release_version} # <== latest version" "${REPO_ROOT}"/README.md
126+
"${SED_BIN}" "s/latest version of cloud provider vsphere(\(.*\))/latest version of cloud provider vsphere(${release_version})/g" "${REPO_ROOT}/releases/README.md"
127+
"${SED_BIN}" "s/the major version of '[0-9]\+\.[0-9]\+.x' is '[0-9]\+\.[0-9]\+'/the major version of '${major_minor_version:1}.x' is '${major_minor_version:1}'/g" "${REPO_ROOT}/releases/README.md"
128+
"${SED_BIN}" "s/VERSION=[0-9]\+\.[0-9]\+/VERSION=${major_minor_version:1}/g" "${REPO_ROOT}/releases/README.md"
129+
"${SED_BIN}" "/<== latest version/c\\registry.k8s.io/cloud-pv-vsphere/cloud-provider-vsphere:${release_version} # <== latest version" "${REPO_ROOT}/README.md"
92130
if ! grep -q "${major_minor_version}.X" "${REPO_ROOT}/README.md"; then
93131
echo "updating README for release branch release-${major_minor_version:1}"
94132
update_readme_table
@@ -108,8 +146,10 @@ update_release_folder() {
108146
}
109147

110148
update_helm_chart() {
149+
## generate helm chart without prefix "v"
150+
stripped_version="${release_version#v}"
111151
cd "${REPO_ROOT}"/charts
112-
helm package vsphere-cpi --version "${release_version}" --app-version "${release_version}"
152+
helm package vsphere-cpi --version "${stripped_version}" --app-version "${stripped_version}"
113153
cd ..
114154
helm repo index . --url https://kubernetes.github.io/cloud-provider-vsphere
115155
}
@@ -173,7 +213,7 @@ echo "updating release folder files..."
173213
update_release_folder
174214

175215
echo "updating Dockerfile..."
176-
sed -i "s/ARG VERSION=.*/ARG VERSION=${release_version:1}/g" "${REPO_ROOT}"/cluster/images/controller-manager/Dockerfile
216+
"${SED_BIN}" "s/ARG VERSION=.*/ARG VERSION=${release_version:1}/g" "${REPO_ROOT}"/cluster/images/controller-manager/Dockerfile
177217

178218
echo "updating helm chart..."
179219
update_helm_chart

0 commit comments

Comments
 (0)