From d43de90bc345a9438cb776087f68a5a8577e77eb Mon Sep 17 00:00:00 2001 From: npldevfr Date: Mon, 29 Jan 2024 17:21:31 +0100 Subject: [PATCH] feat: release script --- composer.json | 1 + scripts/release.sh | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100755 scripts/release.sh diff --git a/composer.json b/composer.json index 52d1b0f..574ba23 100644 --- a/composer.json +++ b/composer.json @@ -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", diff --git a/scripts/release.sh b/scripts/release.sh new file mode 100755 index 0000000..1f5ef63 --- /dev/null +++ b/scripts/release.sh @@ -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."