fix: Improve release process with proper error handling and retry logic
Enhance the release tag creation and Helm package push procedures: Create Helm package improvements: - Add retry logic for git push (up to 3 attempts) - Rebase on failure to resolve conflicts - Fail with exit 1 if push ultimately fails (was silently ignored) - Log success message Create release tag improvements: - Check if tag already exists before creating (avoid duplicate creation) - Add retry logic for tag push (up to 3 attempts) - Fail with exit 1 if push ultimately fails (prevents silent failures) - Suppress error output during retry to keep logs clean - Better logging of tag creation and push success These changes ensure that: 1. Failed releases don't go unnoticed (exit 1 instead of ignoring) 2. Transient network issues are handled gracefully (retry mechanism) 3. Duplicate tags are avoided 4. Release artifacts are reliably pushed to remote Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -315,7 +315,23 @@ jobs:
|
||||
# パッケージファイルをコミット
|
||||
git add ./packages/*.tgz ./packages/index.yaml
|
||||
git commit -m "chore: Add Helm package for version ${{ steps.increment.outputs.new_chart_version }}" || echo "No package changes to commit"
|
||||
git push origin main || echo "Failed to push packages (this may be expected)"
|
||||
|
||||
# パッケージのプッシュをリトライ機構付きで実行
|
||||
MAX_RETRIES=3
|
||||
RETRY_COUNT=0
|
||||
until git push origin main || [ $RETRY_COUNT -eq $MAX_RETRIES ]; do
|
||||
RETRY_COUNT=$((RETRY_COUNT+1))
|
||||
echo "Push failed, retrying ($RETRY_COUNT/$MAX_RETRIES)..."
|
||||
sleep 5
|
||||
git pull --rebase origin main
|
||||
done
|
||||
|
||||
if [ $RETRY_COUNT -eq $MAX_RETRIES ]; then
|
||||
echo "ERROR: Failed to push Helm packages after $MAX_RETRIES attempts"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Successfully pushed Helm packages"
|
||||
|
||||
- name: Create release tag
|
||||
if: steps.update_values.outputs.chart_version_update_needed == 'true'
|
||||
@@ -323,6 +339,11 @@ jobs:
|
||||
# リリースタグを作成(Chart.yaml更新時のみ)
|
||||
TAG_NAME="v${{ steps.increment.outputs.new_chart_version }}"
|
||||
|
||||
# タグが既に存在するか確認
|
||||
if git rev-parse "$TAG_NAME" >/dev/null 2>&1; then
|
||||
echo "INFO: Tag $TAG_NAME already exists locally"
|
||||
else
|
||||
# タグメッセージを作成
|
||||
cat << EOF > /tmp/tag_msg.txt
|
||||
Release $TAG_NAME
|
||||
|
||||
@@ -331,10 +352,25 @@ jobs:
|
||||
EOF
|
||||
|
||||
git tag -a "$TAG_NAME" -F /tmp/tag_msg.txt
|
||||
if ! git push origin "$TAG_NAME"; then
|
||||
echo "WARNING: Failed to push tag (may already exist or network issue)"
|
||||
echo "Created tag: $TAG_NAME"
|
||||
fi
|
||||
|
||||
# タグをプッシュ(リトライ付き)
|
||||
MAX_RETRIES=3
|
||||
RETRY_COUNT=0
|
||||
until git push origin "$TAG_NAME" 2>/dev/null || [ $RETRY_COUNT -eq $MAX_RETRIES ]; do
|
||||
RETRY_COUNT=$((RETRY_COUNT+1))
|
||||
echo "Tag push failed, retrying ($RETRY_COUNT/$MAX_RETRIES)..."
|
||||
sleep 5
|
||||
done
|
||||
|
||||
if [ $RETRY_COUNT -eq $MAX_RETRIES ]; then
|
||||
echo "ERROR: Failed to push tag $TAG_NAME after $MAX_RETRIES attempts"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Successfully pushed tag: $TAG_NAME"
|
||||
|
||||
- name: Summary
|
||||
if: always()
|
||||
run: |
|
||||
|
||||
Reference in New Issue
Block a user