Skip to content

Commit

Permalink
Added a script to increase the version (ethereum#850)
Browse files Browse the repository at this point in the history
* added script to update the bor version across all the locations

* minor update
  • Loading branch information
pratikspatil024 authored May 8, 2023
1 parent f8032db commit 1e181a9
Showing 1 changed file with 81 additions and 0 deletions.
81 changes: 81 additions & 0 deletions scripts/updateVersion.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
#!/bin/bash
set -e

DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"

echo "The version is of form - VersionMajor.VersionMinor.VersionPatch-VersionMeta"
echo "Let's take 0.3.4-beta as an example. Here:"
echo "* VersionMajor is - 0"
echo "* VersionMinor is - 3"
echo "* VersionPatch is - 4"
echo "* VersionMeta is - beta"
echo ""
echo "Now, enter the new version step-by-step below:"

version=""

# VersionMajor
read -p "* VersionMajor: " VersionMajor
if [ -z "$VersionMajor" ]
then
echo "VersionMajor cannot be NULL"
exit -1
fi
version+=$VersionMajor

# VersionMinor
read -p "* VersionMinor: " VersionMinor
if [ -z "$VersionMinor" ]
then
echo "VersionMinor cannot be NULL"
exit -1
fi
version+="."$VersionMinor

# VersionPatch
read -p "* VersionPatch: " VersionPatch
if [ -z "$VersionPatch" ]
then
echo "VersionPatch cannot be NULL"
exit -1
fi
version+="."$VersionPatch

# VersionMeta (optional)
read -p "* VersionMeta (optional, press enter if not needed): " VersionMeta
if [[ ! -z "$VersionMeta" ]]
then
version+="-"$VersionMeta
fi

echo ""
echo "New version is: $version"

# update version in all the 6 templates
replace="Version: "$version
fileArray=(
"${DIR}/../packaging/templates/package_scripts/control"
"${DIR}/../packaging/templates/package_scripts/control.arm64"
"${DIR}/../packaging/templates/package_scripts/control.profile.amd64"
"${DIR}/../packaging/templates/package_scripts/control.profile.arm64"
"${DIR}/../packaging/templates/package_scripts/control.validator"
"${DIR}/../packaging/templates/package_scripts/control.validator.arm64"
)
for file in ${fileArray[@]}; do
# get the line starting with `Version` in the control file and store it in the $temp variable
temp=$(grep "^Version.*" $file)
sed -i '' "s%$temp%$replace%" $file
done

# update version in ../params/version.go
versionFile="${DIR}/../params/version.go"
sed -i '' "s% = .*// Major% = $VersionMajor // Major%g" $versionFile
sed -i '' "s% = .*// Minor% = $VersionMinor // Minor%g" $versionFile
sed -i '' "s% = .*// Patch% = $VersionPatch // Patch%g" $versionFile
sed -i '' "s% = .*// Version metadata% = \"$VersionMeta\" // Version metadata%g" $versionFile
gofmt -w $versionFile

echo ""
echo "Updating Version Done"

exit 0

0 comments on commit 1e181a9

Please sign in to comment.