fix: Improve release process with proper error handling and retry logic
All checks were successful
Helm Chart Release / release-chart (push) Successful in 12s
Update Docker Images and Helm Chart / update (push) Successful in 15s

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:
2026-02-12 08:19:59 +09:00
parent 20081bdda9
commit d970cfa84a

View File

@@ -315,7 +315,23 @@ jobs:
# パッケージファイルをコミット # パッケージファイルをコミット
git add ./packages/*.tgz ./packages/index.yaml 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 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 - name: Create release tag
if: steps.update_values.outputs.chart_version_update_needed == 'true' if: steps.update_values.outputs.chart_version_update_needed == 'true'
@@ -323,18 +339,38 @@ jobs:
# リリースタグを作成Chart.yaml更新時のみ # リリースタグを作成Chart.yaml更新時のみ
TAG_NAME="v${{ steps.increment.outputs.new_chart_version }}" TAG_NAME="v${{ steps.increment.outputs.new_chart_version }}"
cat << EOF > /tmp/tag_msg.txt # タグが既に存在するか確認
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 Release $TAG_NAME
${{ steps.check.outputs.changes }} ${{ steps.check.outputs.changes }}
Chart version: ${{ steps.increment.outputs.new_chart_version }} Chart version: ${{ steps.increment.outputs.new_chart_version }}
EOF EOF
git tag -a "$TAG_NAME" -F /tmp/tag_msg.txt git tag -a "$TAG_NAME" -F /tmp/tag_msg.txt
if ! git push origin "$TAG_NAME"; then echo "Created tag: $TAG_NAME"
echo "WARNING: Failed to push tag (may already exist or network issue)"
fi 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 - name: Summary
if: always() if: always()
run: | run: |