Skip to content
Merged
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
39 changes: 37 additions & 2 deletions .github/workflows/version_stamp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,51 @@ jobs:
echo "has_changes=false" >> "$GITHUB_OUTPUT"
fi

- name: Increment version
- name: Check if changes are comment-only since last version bump
id: check_comments
if: steps.check_changes.outputs.has_changes == 'true'
run: |
LAST_BUMP=$(git log --first-parent origin/master --format="%H %s" | grep " Version bump to v" | head -1 | awk '{print $1}')
echo "Last version bump commit: ${LAST_BUMP}"

if [ -z "$LAST_BUMP" ]; then
echo "No previous version bump found; treating as having real changes."
echo "only_comments=false" >> "$GITHUB_OUTPUT"
exit 0
fi

# Get all added/removed lines since last version bump, excluding version.scad
CHANGED_LINES=$(git diff "${LAST_BUMP}"..origin/master -- ':!version.scad' \
| grep -E '^[+-]' \
| grep -Ev '^(\+\+\+|---)')

if [ -z "$CHANGED_LINES" ]; then
echo "No non-version changes found."
echo "only_comments=true" >> "$GITHUB_OUTPUT"
exit 0
fi

# Strip leading +/- and check for any non-comment, non-blank lines
NON_COMMENT=$(echo "$CHANGED_LINES" | sed 's/^[+-]//' | grep -Ev '^[[:space:]]*//' | grep -Ev '^[[:space:]]*$')

if [ -z "$NON_COMMENT" ]; then
echo "All changes are comment-only; skipping version bump."
echo "only_comments=true" >> "$GITHUB_OUTPUT"
else
echo "Real code changes detected; proceeding with version bump."
echo "only_comments=false" >> "$GITHUB_OUTPUT"
fi

- name: Increment version
if: steps.check_changes.outputs.has_changes == 'true' && steps.check_comments.outputs.only_comments != 'true'
id: version
run: |
./scripts/increment_version.sh
NEW_VERSION=$(grep -oP 'BOSL_VERSION = \[\K[0-9]+,[0-9]+,[0-9]+' version.scad | tr ',' '.')
echo "new_version=${NEW_VERSION}" >> "$GITHUB_OUTPUT"

- name: Commit and push
if: steps.check_changes.outputs.has_changes == 'true'
if: steps.check_changes.outputs.has_changes == 'true' && steps.check_comments.outputs.only_comments != 'true'
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
Expand Down