Skip to content
Permalink
Browse files

deploy release tag (#2919)

  • Loading branch information...
sbcgua authored and larshp committed Oct 7, 2019
1 parent 4c3c4e8 commit 2270b625f7a373a09b661a85aba2d9bc8c9e1bb7
Showing with 60 additions and 6 deletions.
  1. +12 −6 .travis.yml
  2. +48 −0 ci/deploy-release-tag.sh
@@ -7,12 +7,18 @@ script:
- npm run eslint
- npm run abaplint
deploy:
provider: script
script: ./ci/deploy-merged-build.sh
skip_cleanup: true
on:
branch: master
tags: false
- provider: script
script: ./ci/deploy-merged-build.sh
skip_cleanup: true
on:
branch: master
tags: false
- provider: script
script: ./ci/deploy-release-tag.sh
skip_cleanup: true
on:
branch: master
tags: false
env:
global:
secure: "JEKitZ+1to7pt4/lLcWJ0mtWuCRFxEBbps9hEFtHrenxBZR0dSekrLkhXBm9qRLJ6b0QLdYV0855/BiZlvOWuecB5kujbYLoCClx7+DWFszLQKgLf9UPbBoqkoLhvAtpGbAx7aMuBrqFnAD4ZBjybjEDJ5SHnxsWfu7AA2YrtPOUZvFZLqdP4muhwfVuYv+1CRZNJMZHtR4lw1R7kVQggaQmD04iMP/NKQuqNyjEC13zUxDLv5tskDAvl3OrPA3Ybx7Z0GM6piA+EkUoXtc3qnpe7e7j0IHBWpLwOjBOju4n1gMdZ13q1UzoLLsJV17jrg8tSoWw/F/Yqlo50qdRAsg6RCX4k5UpIP7mttStb9iT2pZlfwIAWHQF6aN67ic8F/AuPquMHKEgu/qfj1NK+6lfX0OHM6ovtAnNOozkSUikf7JxMeTlZLLOk+ZSTIYbxDsojMra8jeYmLtOLeFRu485fooXPt0n0aAzHDNuq7xQejvWZ0TGgxytc+A5b5y9YTsLSTZrQZmnxPweSgDSfLPY5HXK51nzEYGSP0tP4BlPAxysAsFoeLgr4oiham1ZxKfCNs7g5Cjc6Zbo1Zuq4Iza4HFl57I96QgyjFLgyFTdzfK6HJvUyIb/+fLK2RfCy0QbYboHej2Ki111I5UjkYITd+nyzmYiX9clJqSBeww="
@@ -0,0 +1,48 @@
#!/bin/bash
echo "Detecting version change ..."

VERSION_FILE=src/zif_abapgit_version.intf.abap
VERSION_CONSTANT=gc_abap_version

git diff-tree --no-commit-id --name-only -r HEAD | grep $VERSION_FILE > /dev/null 2>&1
if [ $? -ne 0 ]; then
echo "no version change detected, skipping tag creation"
exit 0
fi

VERSION_DIFF=$(git diff HEAD^:$VERSION_FILE HEAD:$VERSION_FILE)

echo "$VERSION_DIFF" | grep $VERSION_CONSTANT > /dev/null 2>&1
if [ $? -ne 0 ]; then
echo "no version change detected, skipping tag creation"
exit 0
fi

VERSION_BEFORE=$(echo "$VERSION_DIFF" | grep "^-.\+\b$VERSION_CONSTANT\b" | grep -E -o "[0-9]+\.[0-9]+\.[0-9]+")
VERSION_AFTER=$(echo "$VERSION_DIFF" | grep "^+.\+\b$VERSION_CONSTANT\b" | grep -E -o "[0-9]+\.[0-9]+\.[0-9]+")

if [ -z $VERSION_BEFORE ] || [ -z $VERSION_AFTER ]; then
echo "unexpected version parsing error"
echo "$VERSION_DIFF" | grep $VERSION_CONSTANT
exit 1
fi

if [ $VERSION_BEFORE = $VERSION_AFTER ]; then
echo "no version change detected, skipping tag creation"
exit 0
fi

TAG="v$VERSION_AFTER"
echo "version change detected [$VERSION_BEFORE > $VERSION_AFTER], creating a new tag ..."

# DEPLOY

git config user.email "builds@travis-ci.com"
git config user.name "Travis CI"

REPO_URL=$(git remote -v | grep -m1 '^origin' | sed -Ene 's#.*(https://[^[:space:]]+).*#\1#p')
PUSH_URL=$(echo "$REPO_URL" | sed -Ene "s#(https://)#\1$GITHUB_API_KEY@#p")
# e.g. https://$GITHUB_API_KEY@github.com/larshp/abapGit.git

git tag $TAG || exit 1
git push $PUSH_URL $TAG || exit 1

0 comments on commit 2270b62

Please sign in to comment.
You can’t perform that action at this time.