Skip to content

Commit facaa35

Browse files
committed
Improve version number logic for pull request numbers in zip file
1 parent f29574e commit facaa35

1 file changed

Lines changed: 23 additions & 2 deletions

File tree

.github/workflows/playground.yml

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,30 @@ jobs:
4545
PLUGIN_FILE="${{ steps.prep.outputs.PKG_DIR }}/${{ github.event.repository.name }}.php"
4646
PR_NUMBER="${{ github.event.number }}"
4747
48-
# Extract current version and add PR number
48+
# Extract current version
4949
CURRENT_VERSION=$(grep -o "Version:[[:space:]]*[0-9.]*" "$PLUGIN_FILE" | sed 's/Version:[[:space:]]*//')
50-
NEW_VERSION="${CURRENT_VERSION} - PR ${PR_NUMBER}"
50+
51+
# Increment patch version if it exists, otherwise increment minor version
52+
# Handle versions like 2.1.5 or 2.1
53+
if [[ "$CURRENT_VERSION" =~ ^([0-9]+)\.([0-9]+)(\.([0-9]+))?$ ]]; then
54+
MAJOR="${BASH_REMATCH[1]}"
55+
MINOR="${BASH_REMATCH[2]}"
56+
PATCH="${BASH_REMATCH[4]}"
57+
58+
# Build new version with 'b' suffix
59+
if [ -n "$PATCH" ]; then
60+
# If patch exists, increment patch by 1
61+
PATCH=$((PATCH + 1))
62+
NEW_VERSION="${MAJOR}.${MINOR}.${PATCH}b"
63+
else
64+
# If no patch, increment minor by 1
65+
MINOR=$((MINOR + 1))
66+
NEW_VERSION="${MAJOR}.${MINOR}b"
67+
fi
68+
else
69+
# Fallback: if version format is unexpected, just add .1 and 'b'
70+
NEW_VERSION="${CURRENT_VERSION}.1b"
71+
fi
5172
5273
# Replace the version line
5374
sed -i "s/Version:[[:space:]]*[0-9.]*/Version: ${NEW_VERSION}/" "$PLUGIN_FILE"

0 commit comments

Comments
 (0)