From 202a235d368ed9d077e4dda2ed6e6a86d31dd467 Mon Sep 17 00:00:00 2001
From: Eugenio Romano <eromano@users.noreply.github.com>
Date: Mon, 4 May 2020 15:26:34 +0100
Subject: [PATCH] add tag end release (#1442)

---
 .travis.yml                       |  8 +++++++-
 scripts/travis/release/git-tag.sh | 14 ++++++++++++++
 2 files changed, 21 insertions(+), 1 deletion(-)
 create mode 100755 scripts/travis/release/git-tag.sh

diff --git a/.travis.yml b/.travis.yml
index 47e89c359..7475097af 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -34,7 +34,11 @@ stages:
     if: (type = push AND tag IS blank)  OR type = api
   - name: Release Libraries
     if: branch = master AND type = push
+  - name: Release Tag
+    if: branch = master AND type = push
   - name: e2e
+  - name: Trigger DW
+    if: (branch = master OR branch = development OR (tag =~ .*beta.*)) AND (type = push OR type = api)
 
 jobs:
   include:
@@ -100,8 +104,10 @@ jobs:
         - npm run build.extensions || exit 1;
         - ./scripts/travis/release/release-npm.sh || exit 1;
 
+    - stage: Release Tag
+      script: ./scripts/travis/release/git-tag.sh
+
     - stage: Trigger DW
-      if: (branch = master OR branch = development OR (tag =~ .*beta.*)) AND (type = push OR type = api)
       script: ./scripts/trigger-travis.sh --pro --branch $TRAVIS_BRANCH Alfresco digital-workspace $TRAVIS_ACCESS_TOKEN
 
 after_failure:
diff --git a/scripts/travis/release/git-tag.sh b/scripts/travis/release/git-tag.sh
new file mode 100755
index 000000000..de546ca4e
--- /dev/null
+++ b/scripts/travis/release/git-tag.sh
@@ -0,0 +1,14 @@
+#!/bin/bash
+
+if [[  $TRAVIS_BRANCH == "master" ]]; then
+    VERSION=$(grep -m1 version package.json | awk '{ print $2 }' | sed 's/[", ]//g')
+fi;
+
+echo "git tag -a ${VERSION} -m ${VERSION}"
+git config --local user.name "alfresco-build"
+git config --local user.email "build@alfresco.com"
+git tag -a ${VERSION} -m "${VERSION} [ci skip] "
+git remote rm origin
+GITHUB_REPO=https://$GITHUB_TOKEN:x-oauth-basic@github.com/Alfresco/alfresco-content-app.git
+git remote add origin $GITHUB_REPO
+git push origin --tags