fix: put entire version script in single shell block
Each command runs in separate shell - variables don't persist. Moving everything into one script block. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
+9
-30
@@ -27,57 +27,36 @@ steps:
|
||||
image: alpine/git
|
||||
commands:
|
||||
- |
|
||||
# Get the latest tag or default to v0.0.0
|
||||
set -e
|
||||
LATEST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "v0.0.0")
|
||||
echo "Latest tag: $LATEST_TAG"
|
||||
|
||||
# Parse current version (strip 'v' prefix using sed)
|
||||
VERSION=$(echo "$LATEST_TAG" | sed 's/^v//')
|
||||
MAJOR=$(echo "$VERSION" | cut -d. -f1)
|
||||
MINOR=$(echo "$VERSION" | cut -d. -f2)
|
||||
PATCH=$(echo "$VERSION" | cut -d. -f3)
|
||||
|
||||
echo "Current: $MAJOR.$MINOR.$PATCH"
|
||||
|
||||
# Get commits since last tag
|
||||
if [ "$LATEST_TAG" = "v0.0.0" ]; then
|
||||
COMMITS=$(git log --pretty=format:"%s" HEAD)
|
||||
else
|
||||
COMMITS=$(git log --pretty=format:"%s" "${LATEST_TAG}..HEAD")
|
||||
fi
|
||||
|
||||
# Determine bump type from conventional commits
|
||||
BUMP="patch"
|
||||
if echo "$COMMITS" | grep -qiE "^feat(\(.+\))?!:|BREAKING CHANGE:"; then
|
||||
BUMP="major"
|
||||
elif echo "$COMMITS" | grep -qiE "^feat(\(.+\))?:"; then
|
||||
BUMP="minor"
|
||||
fi
|
||||
|
||||
echo "Bump type: $BUMP"
|
||||
|
||||
# Calculate new version
|
||||
case $BUMP in
|
||||
major)
|
||||
MAJOR=$((MAJOR + 1))
|
||||
MINOR=0
|
||||
PATCH=0
|
||||
;;
|
||||
minor)
|
||||
MINOR=$((MINOR + 1))
|
||||
PATCH=0
|
||||
;;
|
||||
patch)
|
||||
PATCH=$((PATCH + 1))
|
||||
;;
|
||||
major) MAJOR=$((MAJOR + 1)); MINOR=0; PATCH=0 ;;
|
||||
minor) MINOR=$((MINOR + 1)); PATCH=0 ;;
|
||||
patch) PATCH=$((PATCH + 1)) ;;
|
||||
esac
|
||||
|
||||
NEW_VERSION="${MAJOR}.${MINOR}.${PATCH}"
|
||||
echo "New version: $NEW_VERSION"
|
||||
|
||||
# Save version for other steps
|
||||
echo "$NEW_VERSION" > .version
|
||||
echo "v${NEW_VERSION}" > .tag
|
||||
echo "New version: $MAJOR.$MINOR.$PATCH"
|
||||
echo "$MAJOR.$MINOR.$PATCH" > .version
|
||||
echo "v$MAJOR.$MINOR.$PATCH" > .tag
|
||||
cat .version
|
||||
cat .tag
|
||||
depends_on: [build-and-test]
|
||||
|
||||
# Package NuGet
|
||||
|
||||
Reference in New Issue
Block a user