2021-10-25 14:34:00 +00:00
|
|
|
#!/bin/bash
|
|
|
|
#
|
|
|
|
# Script to update the version number, commit the changes to the version files,
|
|
|
|
# and tag the new commit.
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
|
|
|
origDir=$(pwd)
|
|
|
|
rootDir=$(git rev-parse --show-toplevel)
|
|
|
|
cd "$rootDir"
|
|
|
|
|
|
|
|
currentBranch=$(git rev-parse --abbrev-ref HEAD)
|
2024-08-12 18:18:19 +00:00
|
|
|
if [ "$currentBranch" != "main" ]; then
|
2021-10-25 14:34:00 +00:00
|
|
|
printf "You are currently on the '%s' branch. Is this intended (yes/no)? " "$currentBranch"
|
|
|
|
read -r confirmation
|
|
|
|
|
|
|
|
if [ "$confirmation" != "yes" ]; then exit 1; fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
lastVersion=$(jq -r .version web/package.json)
|
|
|
|
printf "Last version: %s\n" "$lastVersion"
|
|
|
|
printf "New version: "
|
|
|
|
read -r newVersion
|
|
|
|
|
|
|
|
printf "New version will be \"%s\". Is this correct (yes/no)? " "$newVersion"
|
|
|
|
read -r confirmation
|
|
|
|
|
|
|
|
if [ "$confirmation" != "yes" ]; then
|
|
|
|
printf "\n"
|
|
|
|
"$origDir/$0"
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
|
|
|
printf ">> Updating /web/package.json with \"version\": \"%s\"\n" "$newVersion"
|
|
|
|
printf "jq \".version = \\\"%s\\\"\" web/package.json > temp.json\n" "$newVersion"
|
|
|
|
jq ".version = \"${newVersion}\"" web/package.json > temp.json
|
|
|
|
printf "mv temp.json web/package.json\n"
|
|
|
|
mv temp.json web/package.json
|
|
|
|
|
|
|
|
printf ">> Updating /web/package-lock.json with \"version\": \"%s\"\n" "$newVersion"
|
|
|
|
printf "jq \".version = \\\"%s\\\"\" web/package-lock.json > temp.json\n" "$newVersion"
|
|
|
|
jq ".version = \"${newVersion}\"" web/package-lock.json > temp.json
|
|
|
|
printf "mv temp.json web/package-lock.json\n"
|
|
|
|
mv temp.json web/package-lock.json
|
|
|
|
|
|
|
|
printf ">> Updating /api/src/hff_entry_forms_apipkg/version.nim with PM_API_VERSION* = \"%s\"" "$newVersion"
|
|
|
|
printf "sed -i \"s/%s/%s/\" api/src/hff_entry_forms_apipkg/version.nim" "$lastVersion" "$newVersion"
|
|
|
|
sed -i "s/${lastVersion}/${newVersion}/" api/src/hff_entry_forms_apipkg/version.nim
|
|
|
|
|
|
|
|
printf ">> Updating /api/hff_entry_forms_api.nimble with version = \"%s\"" "$newVersion"
|
|
|
|
printf "sed -i \"s/%s/%s/\" api/hff_entry_forms_api.nimble" "$lastVersion" "$newVersion"
|
|
|
|
sed -i "s/${lastVersion}/${newVersion}/" api/hff_entry_forms_api.nimble
|
|
|
|
|
|
|
|
printf ">> Committing new version.\n"
|
|
|
|
printf "git add web/package.json web/package-lock.json api/src/hff_entry_forms_apipkg/version.nim"
|
2021-10-26 16:51:55 +00:00
|
|
|
git add web/package.json web/package-lock.json api/src/hff_entry_forms_apipkg/version.nim api/hff_entry_forms_api.nimble
|
2021-10-25 14:34:00 +00:00
|
|
|
printf "git commit -m \"Update package version to %s\"\n" "$newVersion"
|
|
|
|
git commit -m "Update package version to ${newVersion}"
|
|
|
|
|
|
|
|
printf ">> Tagging commit.\n"
|
|
|
|
printf "git tag -m \"Version %s\" \"%s\"\n" "$newVersion" "$newVersion"
|
|
|
|
git tag -m "Version ${newVersion}" "${newVersion}"
|