Skip to content

Commit 1db3bf7

Browse files
committed
Merge branch 'feat/dam-2.0-test-cases' of https://github.com/contentstack/contentstack-management-javascript into feat/dam-2.0-test-cases
2 parents 474976f + e756bd1 commit 1db3bf7

File tree

1 file changed

+28
-4
lines changed

1 file changed

+28
-4
lines changed

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

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1-
# Ensures package.json and CHANGELOG.md are bumped compared to the latest tag when relevant files change.
1+
# Ensures package.json and CHANGELOG.md are bumped when merging to release branch (master/main).
2+
# Runs only on PRs targeting master or main (e.g. development → master).
23
name: Check Version Bump
34

45
on:
56
pull_request:
6-
paths:
7-
- 'package.json'
8-
- 'CHANGELOG.md'
7+
branches:
8+
- master
9+
- main
10+
- development
911

1012
jobs:
1113
version-bump:
@@ -23,8 +25,30 @@ jobs:
2325
node-version: '22.x'
2426

2527
- name: Check version bump
28+
env:
29+
BASE_SHA: ${{ github.event.pull_request.base.sha }}
2630
run: |
2731
set -e
32+
# Skip version bump check when only test/docs/config files changed (no production code)
33+
if [ -n "$BASE_SHA" ]; then
34+
CHANGED=$(git diff --name-only "$BASE_SHA" HEAD 2>/dev/null || true)
35+
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+
PROD_CHANGES=$(echo "$PROD_CHANGES" | sed '/^$/d')
37+
if [ -z "$PROD_CHANGES" ]; then
38+
echo "Only test/docs/config files changed. Skipping version bump check."
39+
exit 0
40+
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
51+
fi
2852
PKG_VERSION=$(node -p "require('./package.json').version.replace(/^v/, '')")
2953
if [ -z "$PKG_VERSION" ]; then
3054
echo "::error::Could not read version from package.json"

0 commit comments

Comments
 (0)