🐛 fix: cross-platform sed and badge replacement issues
This commit is contained in:
@@ -71,7 +71,17 @@ if [ "$BADGE_TYPE" = "bdd" ] || [ "$BADGE_TYPE" = "unit" ]; then
|
||||
$SED_CMD "s|https://img.shields.io/badge/${BADGE_TYPE}_Coverage-.*-.*?style=flat-square|${BADGE_URL}|" README.md
|
||||
else
|
||||
# Add new badge line after the main coverage badge
|
||||
$SED_CMD "/coverage-.*-.*?style=flat-square/a\\n${BADGE_URL}" README.md
|
||||
# Use a more reliable approach with temporary file for cross-platform compatibility
|
||||
TEMP_FILE=$(mktemp)
|
||||
awk -v new_badge="${BADGE_URL}" '
|
||||
/coverage-.*-.*?style=flat-square/ {
|
||||
print $0
|
||||
print new_badge
|
||||
next
|
||||
}
|
||||
{print}
|
||||
' README.md > "$TEMP_FILE"
|
||||
mv "$TEMP_FILE" README.md
|
||||
fi
|
||||
else
|
||||
# For combined coverage, use the original logic
|
||||
|
||||
@@ -40,7 +40,19 @@ fi
|
||||
# Update swagger version regardless of bump
|
||||
source VERSION
|
||||
NEW_VERSION="$MAJOR.$MINOR.$PATCH${PRERELEASE:+-$PRERELEASE}"
|
||||
sed -i "s|// @version [0-9.]*|// @version $NEW_VERSION|" cmd/server/main.go
|
||||
|
||||
# Cross-platform sed command
|
||||
# Detect if we're on macOS (BSD sed) or Linux (GNU sed)
|
||||
SED_CMD=""
|
||||
if [[ "$(uname)" == "Darwin" ]]; then
|
||||
# macOS - requires empty string after -i
|
||||
SED_CMD="sed -i ''"
|
||||
else
|
||||
# Linux - standard GNU sed
|
||||
SED_CMD="sed -i"
|
||||
fi
|
||||
|
||||
$SED_CMD "s|// @version [0-9.]*|// @version $NEW_VERSION|" cmd/server/main.go
|
||||
|
||||
# Commit version changes if bumped
|
||||
if [ "$VERSION_BUMPED" = "true" ]; then
|
||||
|
||||
Reference in New Issue
Block a user