Skip to content

Commit

Permalink
travis: auto deploy for patch pr. (tangcent#315)
Browse files Browse the repository at this point in the history
  • Loading branch information
tangcent authored Aug 2, 2020
1 parent aa5ebf2 commit cf22d80
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 5 deletions.
24 changes: 21 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,31 @@ matrix:
jdk: openjdk8

script:
- ./plugin-script/build_plugin.sh

- ./plugin-script/package_plugin.sh

before_cache:
- rm -f $HOME/.gradle/caches/**

cache:
directories:
- $HOME/.gradle/caches/
- $HOME/.gradle/wrapper/
- $HOME/.gradle/wrapper/

before_deploy:
- git config --local user.name "tangcent"
- git config --local user.email "[email protected]"
- echo jars- `ls plugin`
- ./plugin-script/push_tag.sh

deploy:
provider: releases
api_key: $GITHUB_TOKEN
name: $TRAVIS_TAG_TITLE
body: $TRAVIS_TAG_BODY
file_glob: true
file: plugin/*
overwrite: true
skip_cleanup: true
on:
branch: master
repo: tangcent/easy-api
2 changes: 1 addition & 1 deletion plugin-script/build_plugin.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/usr/bin/env bash
#

SOURCE="$0"
Expand Down
2 changes: 1 addition & 1 deletion plugin-script/package_plugin.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/usr/bin/env bash
#

SOURCE="$0"
Expand Down
26 changes: 26 additions & 0 deletions plugin-script/push_tag.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/usr/bin/env bash
#

SOURCE="$0"
while [[ -L "$SOURCE" ]]; do # resolve $SOURCE until the file is no longer a symlink
scriptDir="$(cd -P "$(dirname "$SOURCE")" && pwd)"
SOURCE="$(readlink "$SOURCE")"
[[ ${SOURCE} != /* ]] && SOURCE="$scriptDir/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
done
scriptDir="$(cd -P "$(dirname "$SOURCE")" && pwd)"
basedir=${scriptDir%/*}
echo "baseDir:"${basedir}

version=$(cat ${basedir}/build.gradle | grep -Eo '[0-9][0-9.]+')
echo "version:"${version}
export DEPLOY_VERSION=version
export TRAVIS_TAG="${version}-patch"
git push origin :refs/tags/$TRAVIS_TAG
git tag -a $TRAVIS_TAG -m "Auto deployment"
export TRAVIS_TAG_TITLE="Auto deployment ${version}-patch"

if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then
export TRAVIS_TAG_BODY="patch with [#${TRAVIS_PULL_REQUEST}](https://github.com/${TRAVIS_REPO_SLUG}/pull/${TRAVIS_PULL_REQUEST})"
else
export TRAVIS_TAG_BODY="patch with [#${TRAVIS_COMMIT_MESSAGE}](https://github.com/${TRAVIS_REPO_SLUG}/commit/${TRAVIS_COMMIT})"
fi

0 comments on commit cf22d80

Please sign in to comment.