Skip to content

Commit

Permalink
feat: release script
Browse files Browse the repository at this point in the history
  • Loading branch information
npldevfr committed Jan 29, 2024
1 parent 5151c34 commit d43de90
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"description": "A PHP client for the Liquipedia v3 API",
"keywords": ["php", "liquipedia", "mediawiki", "api", "client"],
"license": "MIT",
"version": "0.0.5",
"authors": [
{
"name": "npldev",
Expand Down
37 changes: 37 additions & 0 deletions scripts/release.sh
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."

0 comments on commit d43de90

Please sign in to comment.