Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,17 @@ on:
push:
branches:
- main
paths:
- 'src/**'
- 'Cargo.toml'
- 'Cargo.lock'
pull_request:
branches:
- main
paths:
- 'src/**'
- 'Cargo.toml'
- 'Cargo.lock'

env:
RUST_BACKTRACE: 1
Expand Down
39 changes: 23 additions & 16 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,7 @@ on:
- 'src/**'
- 'Cargo.toml'
- 'Cargo.lock'
pull_request:
branches:
- main
paths:
- 'src/**'
- 'Cargo.toml'
- 'Cargo.lock'


env:
CARGO_TERM_COLOR: always
Expand Down Expand Up @@ -72,19 +66,32 @@ jobs:
if [ -z "$BUMP_TYPE" ]; then
echo "Determining version bump from commit messages..."

# Get commit messages since last release
COMMIT_MESSAGES=$(git log --pretty=format:"%s" HEAD~10..HEAD)
# Get commit messages since last tag (or all commits if no tags exist)
LAST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "")
if [ -n "$LAST_TAG" ]; then
echo "Getting commits since last tag: $LAST_TAG"
COMMIT_MESSAGES=$(git log --pretty=format:"%s" "$LAST_TAG"..HEAD)
else
echo "No previous tags found, analyzing all commits"
COMMIT_MESSAGES=$(git log --pretty=format:"%s")
fi
echo "Recent commit messages:"
echo "$COMMIT_MESSAGES"

# Check for breaking changes (major bump)
if echo "$COMMIT_MESSAGES" | grep -i "BREAKING CHANGE\|breaking:" > /dev/null; then
BUMP_TYPE="major"
# Check for features (minor bump)
elif echo "$COMMIT_MESSAGES" | grep -E "^feat(\(.+\))?:" > /dev/null; then
BUMP_TYPE="minor"
# Default to patch bump for fixes and other changes
# Analyze commit messages if any exist
if [ -n "$COMMIT_MESSAGES" ]; then
# Check for breaking changes (major bump)
if echo "$COMMIT_MESSAGES" | grep -i "BREAKING CHANGE\|breaking:" > /dev/null; then
BUMP_TYPE="major"
# Check for features (minor bump)
elif echo "$COMMIT_MESSAGES" | grep -E "^feat(\(.+\))?:" > /dev/null; then
BUMP_TYPE="minor"
# Default to patch bump for fixes and other changes
else
BUMP_TYPE="patch"
fi
else
echo "No commit messages found, defaulting to patch bump"
BUMP_TYPE="patch"
fi
fi
Expand Down
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,3 @@ temp**
tmp**

.env

test-*
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "contract-deployer"
version = "1.0.0"
version = "0.0.9"
edition = "2024"
authors = ["David <0xdavid7@proton.me>"]
description = "Automated deployment tool for Foundry-based repositories"
Expand Down
76 changes: 76 additions & 0 deletions scripts/test-version-logic.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
#!/bin/bash

# Test script to validate the version bump logic
set -e

echo "🧪 Testing version bump logic..."
echo ""

# Get current version from Cargo.toml
CURRENT_VERSION=$(grep "^version = " Cargo.toml | sed 's/version = "\(.*\)"/\1/')
echo "📦 Current version: $CURRENT_VERSION"

# Parse version components
MAJOR=$(echo $CURRENT_VERSION | cut -d. -f1)
MINOR=$(echo $CURRENT_VERSION | cut -d. -f2)
PATCH=$(echo $CURRENT_VERSION | cut -d. -f3)
echo "🔍 Parsed version: MAJOR=$MAJOR, MINOR=$MINOR, PATCH=$PATCH"
echo ""

# Get commit messages since last tag
LAST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "")
if [ -n "$LAST_TAG" ]; then
echo "🏷️ Getting commits since last tag: $LAST_TAG"
COMMIT_MESSAGES=$(git log --pretty=format:"%s" "$LAST_TAG"..HEAD)
else
echo "🏷️ No previous tags found, analyzing all commits"
COMMIT_MESSAGES=$(git log --pretty=format:"%s")
fi

echo "📝 Recent commit messages:"
echo "$COMMIT_MESSAGES"
echo ""

# Determine bump type
if [ -n "$COMMIT_MESSAGES" ]; then
if echo "$COMMIT_MESSAGES" | grep -i "BREAKING CHANGE\|breaking:" > /dev/null; then
BUMP_TYPE="major"
echo "💥 Found breaking changes - MAJOR bump"
elif echo "$COMMIT_MESSAGES" | grep -E "^feat(\(.+\))?:" > /dev/null; then
BUMP_TYPE="minor"
echo "✨ Found feature commits - MINOR bump"
else
BUMP_TYPE="patch"
echo "🔧 Default - PATCH bump"
fi
else
echo "❓ No commit messages found, defaulting to PATCH bump"
BUMP_TYPE="patch"
fi

echo ""
echo "📈 Version bump type: $BUMP_TYPE"

# Calculate new version
case $BUMP_TYPE in
major)
NEW_MAJOR=$((MAJOR + 1))
NEW_MINOR=0
NEW_PATCH=0
;;
minor)
NEW_MAJOR=$MAJOR
NEW_MINOR=$((MINOR + 1))
NEW_PATCH=0
;;
patch)
NEW_MAJOR=$MAJOR
NEW_MINOR=$MINOR
NEW_PATCH=$((PATCH + 1))
;;
esac

NEW_VERSION="$NEW_MAJOR.$NEW_MINOR.$NEW_PATCH"
echo "🎯 New version would be: $NEW_VERSION"
echo ""
echo "✅ Version logic test completed successfully!"
Loading