From 11b1bf230e599557246059a58a93e37bd1b5505c Mon Sep 17 00:00:00 2001
From: gabriel klawitter <gabreal@users.noreply.github.com>
Date: Sat, 4 Jan 2020 03:30:53 +0900
Subject: [PATCH] ci: fix release tagging after tags are added on the master
 branch (#714)

* ci: fix release tagging after tags are added on the master branch

* ci: latest tag applied to latest tag
---
 polkadot/.gitlab-ci.yml | 13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)

diff --git a/polkadot/.gitlab-ci.yml b/polkadot/.gitlab-ci.yml
index 50d98d9d37e..938ee00ad64 100644
--- a/polkadot/.gitlab-ci.yml
+++ b/polkadot/.gitlab-ci.yml
@@ -176,18 +176,13 @@ build-linux-release:               &build
     - mkdir -p ./artifacts
     - mv ./target/release/polkadot ./artifacts/.
     - sha256sum ./artifacts/polkadot | tee ./artifacts/polkadot.sha256
+    - VERSION="${CI_COMMIT_REF_NAME}" # will be tag or branch name
     - if [ "${CI_COMMIT_TAG}" ]; then
-        VERSION="${CI_COMMIT_TAG}";
-      else
-        VERSION="$(./artifacts/polkadot --version |
-          sed -n -r 's/^polkadot ([0-9.]+.*-[0-9a-f]{7,13})-.*$/\1/p')";
-        VERSION="${VERSION}-$(cut -c 1-8 ./artifacts/polkadot.sha256)";
-      fi
-    - LATEST_BRANCH="$(ls -1 .git/refs/remotes/origin/ | sed -r -n 's:v([0-9]+)\.([0-9]+):v\1.\2:p' | sort -V | tail -n1)"
-    - if expr match x${CI_COMMIT_TAG} x${LATEST_BRANCH}; then
         EXTRATAG="latest";
       else
-        EXTRATAG="latest-${CI_COMMIT_REF_NAME}";
+        EXTRATAG="$(./artifacts/polkadot --version |
+          sed -n -r 's/^polkadot ([0-9.]+.*-[0-9a-f]{7,13})-.*$/\1/p')";
+        EXTRATAG="${CI_COMMIT_REF_NAME}-${EXTRATAG}-$(cut -c 1-8 ./artifacts/polkadot.sha256)";
       fi
     - echo "Polkadot version = ${VERSION} (EXTRATAG ${EXTRATAG})"
     - echo -n ${VERSION} > ./artifacts/VERSION
-- 
GitLab