Skip to content

Commit e756bd1

Browse files
Enhance version bump workflow to skip checks when only comments are modified in production files, improving accuracy of versioning logic.
1 parent 334f10d commit e756bd1

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

.github/workflows/check-version-bump.yml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,21 @@ jobs:
3333
if [ -n "$BASE_SHA" ]; then
3434
CHANGED=$(git diff --name-only "$BASE_SHA" HEAD 2>/dev/null || true)
3535
PROD_CHANGES=$(echo "$CHANGED" | grep -v -e '^test/' -e '^package\.json$' -e '^CHANGELOG\.md$' -e '^\.github/' -e '^README' -e '^\.' -e '^docs/' -e '^jest\.config' -e '^\.eslintrc' -e '^\.prettierrc' || true)
36-
# Remove empty lines; if no production changes left, skip check
3736
PROD_CHANGES=$(echo "$PROD_CHANGES" | sed '/^$/d')
3837
if [ -z "$PROD_CHANGES" ]; then
3938
echo "Only test/docs/config files changed. Skipping version bump check."
4039
exit 0
4140
fi
41+
# Skip when only comments changed in production files (//, /*, *, */, #)
42+
if git diff "$BASE_SHA" HEAD | node -e "
43+
const lines = require('fs').readFileSync(0,'utf8').split('\n').filter(l=>l.startsWith('+')||l.startsWith('-'));
44+
const isComment = (s) => { const t=(s||'').slice(1).replace(/^\s+|\s+$/g,''); return !t || /^\/\//.test(t) || /^\/\*/.test(t) || /^\*\//.test(t) || /^\s*\*/.test(t) || /^#/.test(t); };
45+
const hasCode = lines.some(l => !isComment(l));
46+
process.exit(hasCode ? 1 : 0);
47+
" 2>/dev/null; then
48+
echo "Only comments changed in code. Skipping version bump check."
49+
exit 0
50+
fi
4251
fi
4352
PKG_VERSION=$(node -p "require('./package.json').version.replace(/^v/, '')")
4453
if [ -z "$PKG_VERSION" ]; then

0 commit comments

Comments
 (0)