ensure gerrit is unlocked even on failure

Change-Id: I318a429fc44a5f4615e68e74e1a29dd85519faef
diff --git a/tools/onos-yang-tools-build-release b/tools/onos-yang-tools-build-release
index 0e77756..6b96c39 100755
--- a/tools/onos-yang-tools-build-release
+++ b/tools/onos-yang-tools-build-release
@@ -18,7 +18,12 @@
 
 export OYT_TAG=$OYT_VERSION
 
+function cleanup {
+  ssh -p 29418 gerrit.onosproject.org projectlock unlock onos-yang-tools $OYT_BRANCH
+}
+
 ssh -p 29418 gerrit.onosproject.org projectlock lock onos-yang-tools $OYT_BRANCH
+trap cleanup EXIT
 
 mvn versions:set -DnewVersion=$OYT_VERSION versions:commit
 mvn -Prelease clean deploy
@@ -30,6 +35,5 @@
 git push origin $OYT_BRANCH
 git push origin $OYT_TAG
 
-ssh -p 29418 gerrit.onosproject.org projectlock unlock onos-yang-tools $OYT_BRANCH
 
 unset OYT_VERSION OYT_SNAPSHOT OYT_BRANCH OYT_TAG