diff --git a/.woodpecker/release.yml b/.woodpecker/release.yml index a4c6205..003f01e 100644 --- a/.woodpecker/release.yml +++ b/.woodpecker/release.yml @@ -11,7 +11,7 @@ clone: image: woodpeckerci/plugin-git settings: lfs: false - depth: 0 # Full clone needed for version calculation + partial: false tags: true steps: @@ -19,13 +19,24 @@ steps: - name: calculate-version image: alpine commands: - - apk add --no-cache git jq + - apk add --no-cache git - | set -e + # Ensure we have all tags and history + echo "=== Fetching tags and history ===" + git fetch --tags --unshallow 2>/dev/null || git fetch --tags || true + git fetch origin main --unshallow 2>/dev/null || git fetch origin main || true + + echo "=== Git log (last 10 commits) ===" + git log --oneline -10 + + echo "=== All tags ===" + git tag -l + # Get latest tag LATEST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "v0.0.0") - echo "Latest tag: $LATEST_TAG" + echo "=== Latest tag: $LATEST_TAG ===" # Parse current version VERSION=$(echo "$LATEST_TAG" | sed 's/^v//') @@ -41,24 +52,35 @@ steps: COMMITS=$(git log --pretty=format:"%s" "${LATEST_TAG}..HEAD") fi - echo "Commits since last tag:" + echo "=== Commits since last tag ===" echo "$COMMITS" + echo "=== End commits ===" + + # Check if COMMITS is empty + if [ -z "$COMMITS" ]; then + echo "No commits found since last tag" + echo "none" > .bump-type + exit 0 + fi # Determine bump type from conventional commits BUMP="none" # Check for breaking changes (major bump) - if echo "$COMMITS" | grep -qE "^[a-z]+(\(.+\))?!:|BREAKING CHANGE:"; then + if echo "$COMMITS" | grep -qE '^[a-z]+(\(.+\))?!:|BREAKING CHANGE:'; then BUMP="major" + echo "Found breaking change commit" # Check for features (minor bump) - elif echo "$COMMITS" | grep -qE "^feat(\(.+\))?:"; then + elif echo "$COMMITS" | grep -qE '^feat(\(.+\))?:'; then BUMP="minor" + echo "Found feat commit" # Check for fixes or other conventional commits (patch bump) - elif echo "$COMMITS" | grep -qE "^(fix|perf|refactor|build|ci|docs|style|test)(\(.+\))?:"; then + elif echo "$COMMITS" | grep -qE '^(fix|perf|refactor|build|ci|docs|style|test)(\(.+\))?:'; then BUMP="patch" + echo "Found fix/patch commit" fi - echo "Bump type: $BUMP" + echo "=== Bump type: $BUMP ===" # Exit if no version bump needed if [ "$BUMP" = "none" ]; then