#!/bin/bash # SPDX-License-Identifier: Apache-2.0 # Copyright (c) 2012-2024 Scott Penrose and WII5 Buoy contributors # # This file is part of WII5 Buoy firmware. # See LICENSE for full terms. #get highest tag number VERSION=`git describe --abbrev=0 --tags` SHORT=$(git log -1 --pretty=format:%h) #replace . with space so can split into an array VERSION_BITS=(${VERSION//./ }) #get number parts and increase last one by 1 VNUM1=${VERSION_BITS[0]} VNUM2=${VERSION_BITS[1]} VNUM3=${VERSION_BITS[2]} VNUM3=$((VNUM3+1)) #create new tag NEW_TAG="$VNUM1.$VNUM2.$VNUM3" echo "Updating $VERSION to $NEW_TAG" #get current hash and see if it already has a tag GIT_COMMIT=`git rev-parse HEAD` NEEDS_TAG=`git describe --contains $GIT_COMMIT 2>/dev/null` #only tag if no tag already if [ -z "$NEEDS_TAG" ]; then echo "version=$NEW_TAG" > VERSION echo "short=$SHORT" >> VERSION git add VERSION git commit -m 'Auto update version file' git tag $NEW_TAG echo "Tagged with $NEW_TAG" git push --tags else echo "Already a tag on this commit" fi