Skip to content

Commit c0e1323

Browse files
committed
feat(ci): prevent concurrent pipeline runs to avoid S3 index.yaml conflicts
1 parent e52d42c commit c0e1323

2 files changed

Lines changed: 44 additions & 12 deletions

File tree

.github/workflows/manage_release.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@ on:
1818
required: false
1919
default: "false"
2020
type: boolean
21+
22+
# Ensure only one release pipeline runs at a time
23+
# to avoid concurrent writes to the S3 index.yaml
24+
concurrency:
25+
group: manage_release
26+
cancel-in-progress: false
2127

2228
jobs:
2329

scripts/build_release.sh

Lines changed: 38 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ set -euo pipefail
44

55
# Build and release Helm charts to Harbor OCI registry and S3 backup.
66
# Decrypts Harbor and rclone credentials from the development repository,
7-
# logs into the registry, then releases each chart.
7+
# logs into the registry, then releases each chart using kash functions.
88
#
99
# Usage (CI mode):
1010
# bash ./scripts/build_release.sh -p chart1 chart2
@@ -71,6 +71,7 @@ end_group "Setup rclone config"
7171
## Release charts
7272
##
7373
FORCE_DEV="${FORCE_DEV:-false}"
74+
RCLONE_REMOTE="kalisio_charts"
7475

7576
# Set git identity for tag creation — CI mode only
7677
if [ "$CI" = true ]; then
@@ -79,29 +80,54 @@ if [ "$CI" = true ]; then
7980
fi
8081

8182
if [ "$PUBLISH" = true ]; then
83+
# Shared temp directory for all charts
84+
TMP=$(mktemp -d)
85+
PROD_TAGS=()
86+
87+
# Package all charts first
8288
for CHART in "$@"; do
83-
VERSION=$(sed -En 's/^version: (.*)$/\1/p' "charts/${CHART}/Chart.yaml")
89+
VERSION=$(get_yaml_value "$ROOT_DIR/charts/$CHART/Chart.yaml" "version")
8490
TAG_NAME="${CHART}-${VERSION}"
8591

86-
begin_group "Release ${CHART} (${VERSION})"
92+
begin_group "Package ${CHART} (${VERSION})"
8793

8894
if [ "$FORCE_DEV" = "true" ]; then
89-
echo "-> FORCE_DEV enabled, releasing dev version (0.0.0-dev)"
90-
bash "$THIS_DIR/release-dev-chart.sh" "${CHART}"
91-
elif git show-ref --tags "${TAG_NAME}" --quiet; then
92-
echo "-> Tag ${TAG_NAME} already exists, releasing dev version (0.0.0-dev)"
93-
bash "$THIS_DIR/release-dev-chart.sh" "${CHART}"
95+
echo "-> FORCE_DEV enabled, packaging dev version (0.0.0-dev)"
96+
package_chart "$CHART" "$TMP" "0.0.0-dev" "$ROOT_DIR"
97+
elif git_tag_exists "$TAG_NAME" "$ROOT_DIR"; then
98+
echo "-> Tag ${TAG_NAME} exists, packaging dev version (0.0.0-dev)"
99+
package_chart "$CHART" "$TMP" "0.0.0-dev" "$ROOT_DIR"
94100
else
95-
echo "-> Tag ${TAG_NAME} not found, releasing production version (${VERSION})"
96-
bash "$THIS_DIR/release-chart.sh" "${CHART}"
101+
echo "-> Tag ${TAG_NAME} not found, packaging production version (${VERSION})"
102+
package_chart "$CHART" "$TMP" "" "$ROOT_DIR"
103+
PROD_TAGS+=("$TAG_NAME")
97104
fi
98105

99-
end_group "Release ${CHART} (${VERSION})"
106+
end_group "Package ${CHART} (${VERSION})"
107+
done
108+
109+
# Push all charts to Harbor OCI — one single operation
110+
begin_group "Push charts to Harbor OCI"
111+
push_charts_oci "$TMP" "$KALISIO_HARBOR_URL/kalisio/helm"
112+
end_group "Push charts to Harbor OCI"
113+
114+
# Push all charts to S3 + rebuild index.yaml once
115+
begin_group "Push charts to S3"
116+
push_charts_s3 "$TMP" "$RCLONE_REMOTE" "$RCLONE_DEC_CONF"
117+
end_group "Push charts to S3"
118+
119+
# Create git tags for production releases only
120+
for TAG_NAME in "${PROD_TAGS[@]:-}"; do
121+
git tag "$TAG_NAME"
122+
git push origin "$TAG_NAME"
123+
echo "-> Tag ${TAG_NAME} created."
100124
done
125+
126+
rm -rf "$TMP"
101127
else
102128
echo "-> Dry run mode: skipping publish (use -p to publish)"
103129
fi
104130

105131
## Logout from Harbor OCI registry
106132
##
107-
helm registry logout "$KALISIO_HARBOR_URL"
133+
helm registry logout "$KALISIO_HARBOR_URL"

0 commit comments

Comments
 (0)