-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Xavier Arias
committed
Nov 26, 2019
1 parent
70cdf3e
commit 7b98a38
Showing
3 changed files
with
83 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
set -eo pipefail | ||
|
||
[[ "$TRACE" ]] && set -x | ||
|
||
configure_github_user() { | ||
git config --global user.email "git@antonydenyer.co.uk" | ||
git config --global user.name "Antony Denyer" | ||
} | ||
|
||
github_clone() { | ||
git clone https://antonydenyer:${GITHUB_PERSONAL_ACCESS_TOKEN}@github.com/web3j/$1.git | ||
cd $1 | ||
} | ||
|
||
ensure_version() { | ||
if [[ -z "$VERSION" ]]; then | ||
VERSION="${TRAVIS_BRANCH//release\/}" | ||
fi | ||
|
||
if [[ "$VERSION" = "" ]]; then | ||
echo "ERROR: Missing VERSION specify it using an env variable" | ||
exit 1 | ||
fi | ||
} | ||
|
||
ensure_product() { | ||
if [[ -z "$PRODUCT" ]]; then | ||
PRODUCT="${TRAVIS_REPO_SLUG//release\/}" | ||
fi | ||
|
||
if [[ "$VERSION" = "" ]]; then | ||
echo "ERROR: Missing PRODUCT specify it using an env variable" | ||
exit 1 | ||
fi | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#!/bin/bash | ||
|
||
set -eo pipefail | ||
|
||
SOURCE="${BASH_SOURCE[0]}" | ||
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink | ||
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )" | ||
SOURCE="$(readlink "$SOURCE")" | ||
[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located | ||
done | ||
|
||
trap 'last_command=$current_command; current_command=$BASH_COMMAND' DEBUG | ||
# echo an error message before exiting | ||
trap 'echo "\"${last_command}\" command filed with exit code $?."' EXIT | ||
|
||
export SCRIPTS_DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )" | ||
|
||
source "$SCRIPTS_DIR/common.bash" | ||
|
||
ensure_version | ||
|
||
ensure_product | ||
|
||
export PREVIOUS_RELEASE=$(curl -H "Authorization: token ${GITHUB_PERSONAL_ACCESS_TOKEN}" -s "https://api.github.com/repos/web3j/${PRODUCT}/releases/latest" | jq -r '.target_commitish' ) | ||
export CHANGELOG=$(git rev-list --format=oneline --abbrev-commit --max-count=50 "${PREVIOUS_RELEASE}"..HEAD | jq --slurp --raw-input . ) | ||
|
||
echo "Creating a new release on GitHub with changes" | ||
echo -e "\n${CHANGELOG:1:-1}" | ||
|
||
API_JSON="{ | ||
\"tag_name\": \"v${VERSION}\", | ||
\"target_commitish\": \"$(git rev-parse HEAD)\", | ||
\"name\": \"v${VERSION}\", | ||
\"body\": \"Release of version ${VERSION}: \n\n ${CHANGELOG:1:-1}\", | ||
\"draft\": false, | ||
\"prerelease\": false | ||
}" | ||
|
||
export RESULT=$(curl -H "Authorization: token ${GITHUB_PERSONAL_ACCESS_TOKEN}" --data "$API_JSON" -s "https://api.github.com/repos/web3j/${PRODUCT}/releases") | ||
export UPLOAD_URL=$(echo ${RESULT} | jq -r ".upload_url") | ||
|
||
for FILE in $(find ./ -type f -name "${PRODUCT}-${VERSION}.*"); | ||
do | ||
curl -H "Authorization: token ${GITHUB_PERSONAL_ACCESS_TOKEN}" -s "${UPLOAD_URL:0:-13}?name=$(basename -- $FILE)" -H "Content-Type: $(file -b --mime-type $FILE)" --data-binary @"${FILE}" | ||
done | ||
|
||
echo "Release finished" |