Skip to content

Commit 7110f55

Browse files
authored
Merge pull request #9 from lupuletic/additional-automation
fix: npm publish fix
2 parents 41b790a + 15d871f commit 7110f55

1 file changed

Lines changed: 34 additions & 1 deletion

File tree

.github/workflows/npm-publish.yml

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,20 @@ jobs:
8787
# Function to check for conventional commit prefixes
8888
check_for_prefixes() {
8989
local message="$1"
90-
90+
91+
# Skip GitHub's automated merge commit messages
92+
if [[ "$message" =~ ^Merge\ pull\ request\ #[0-9]+\ from\ .* ]]; then
93+
echo "Detected GitHub merge commit message, skipping: $message"
94+
# Don't change BUMP_TYPE for merge commits, just return success
95+
return 0
96+
fi
97+
98+
# Continue with conventional commit checking
9199
# Check for breaking changes (highest priority)
92100
if [[ "$message" == *"BREAKING CHANGE"* ]] || [[ "$message" == *"!"* ]]; then
93101
echo "Detected breaking change - using major version bump"
94102
BUMP_TYPE="major"
103+
FOUND_CONVENTIONAL_COMMIT=true
95104
return 0
96105
fi
97106
@@ -101,6 +110,7 @@ jobs:
101110
if [[ "$BUMP_TYPE" != "major" ]]; then
102111
echo "Detected new feature - using minor version bump"
103112
BUMP_TYPE="minor"
113+
FOUND_CONVENTIONAL_COMMIT=true
104114
fi
105115
return 0
106116
fi
@@ -111,31 +121,54 @@ jobs:
111121
if [[ "$BUMP_TYPE" != "major" ]] && [[ "$BUMP_TYPE" != "minor" ]]; then
112122
echo "Detected bug fix - using patch version bump"
113123
BUMP_TYPE="patch"
124+
FOUND_CONVENTIONAL_COMMIT=true
114125
fi
115126
return 0
116127
fi
117128
129+
# For non-merge commits that don't match conventions, we should report an error
130+
echo "WARNING: No conventional commit prefix found in: $message"
118131
return 1
119132
}
120133
121134
# First check the PR title (highest priority)
122135
check_for_prefixes "$PR_TITLE"
136+
# If the check failed but it's not a merge commit, we need to handle it
137+
PR_CHECK_RESULT=$?
138+
if [[ $PR_CHECK_RESULT -ne 0 ]]; then
139+
echo "PR title doesn't follow conventional commit format and is not a merge commit"
140+
echo "Will still check individual commits for version bump determination"
141+
fi
123142
124143
# Save the current BUMP_TYPE after checking PR title
125144
echo "After PR title check: BUMP_TYPE=$BUMP_TYPE"
126145
127146
# Process commit messages one by one
128147
echo "Processing commit messages:"
148+
# Set error handling to continue even if a command fails
149+
set +e
129150
echo "$COMMIT_MESSAGES" > /tmp/commit_messages.txt
151+
FOUND_CONVENTIONAL_COMMIT=false
130152
while IFS= read -r message; do
131153
echo "Processing message: $message"
132154
if [[ -n "$message" ]]; then
133155
check_for_prefixes "$message"
134156
echo "After checking message: BUMP_TYPE=$BUMP_TYPE"
135157
fi
136158
done < /tmp/commit_messages.txt
159+
# Restore error handling
160+
set -e
137161
138162
echo "BUMP_TYPE after processing all messages: $BUMP_TYPE"
163+
164+
# Check if we found at least one conventional commit
165+
if [[ "$BUMP_TYPE" == "patch" ]] && [[ "$FOUND_CONVENTIONAL_COMMIT" == "false" ]]; then
166+
echo "WARNING: No conventional commits found in this PR"
167+
echo "Using default patch version bump"
168+
else
169+
echo "Found conventional commits, using determined version bump: $BUMP_TYPE"
170+
fi
171+
139172
140173
# Output the final decision
141174
echo "Final decision: $BUMP_TYPE version bump"

0 commit comments

Comments
 (0)