-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
38 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#!/bin/bash | ||
|
||
# Get the current version from your composer.json | ||
currentVersion=$(jq -r .version composer.json) | ||
|
||
# Function to increment the version in the format 0.0.0 | ||
incrementVersion() { | ||
local currentVersion=$1 | ||
local regex="^([0-9]+)\.([0-9]+)\.([0-9]+)$" | ||
|
||
if [[ $currentVersion =~ $regex ]]; then | ||
local major="${BASH_REMATCH[1]}" | ||
local minor="${BASH_REMATCH[2]}" | ||
local patch="${BASH_REMATCH[3]}" | ||
local newVersion="$((major)).$((minor)).$((patch + 1))" | ||
echo "$newVersion" | ||
else | ||
echo "Error: Incorrect version format." | ||
exit 1 | ||
fi | ||
} | ||
|
||
# Calculate the new version | ||
newVersion=$(incrementVersion "$currentVersion") | ||
|
||
# Display the new version | ||
echo "Creating a new release for $(jq -r .name composer.json)..." | ||
echo "Current version: $currentVersion" | ||
echo "New version: $newVersion" | ||
|
||
# Create the tag | ||
git tag "v$newVersion" | ||
|
||
# Push the tag to the remote repository | ||
git push origin "v$newVersion" | ||
|
||
echo "Release created successfully." |