Skip to content

Commit

Permalink
build: store variables using encrypted travis ci
Browse files Browse the repository at this point in the history
upload files against release
  • Loading branch information
antonydenyer authored and Antony Denyer committed Sep 27, 2019
1 parent d37be0f commit 990bfe9
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 24 deletions.
40 changes: 19 additions & 21 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,29 +1,27 @@
language: java

jdk:
- openjdk8

sudo: false # as per http://blog.travis-ci.com/2014-12-17-faster-builds-with-container-based-infrastructure/

# Avoid uploading cache after every build with Gradle - see https://docs.travis-ci.com/user/languages/java/#Caching
- openjdk8
sudo: false
before_cache:
- rm -f $HOME/.gradle/caches/modules-2/modules-2.lock
- rm -fr $HOME/.gradle/caches/*/plugin-resolution/
- rm -f $HOME/.gradle/caches/modules-2/modules-2.lock
- rm -fr $HOME/.gradle/caches/*/plugin-resolution/
cache:
directories:
- $HOME/.gradle/caches/
- $HOME/.gradle/wrapper/

- "$HOME/.gradle/caches/"
- "$HOME/.gradle/wrapper/"
jobs:
include:
- stage: spotlessCheck
script: ./gradlew spotlessCheck
- stage: build & test
script: ./gradlew --info check jacocoTestReport
- stage: release
if: branch != master
script: ./scripts/release.sh

# Upload code coverage metrics
- stage: build & test
script:
- "./gradlew spotlessCheck"
- "./gradlew check jacocoTestReport"
- stage: release
if: branch =~ /release/
script:
- "./gradlew distZip"
- "./scripts/release.sh"
after_success:
- bash <(curl -s https://codecov.io/bash)
- bash <(curl -s https://codecov.io/bash)
env:
matrix:
- secure: UGlPwgcOSfbfiOQ88B920Fg/BMFZoQltgXNd8igCVSP8mllDkKQa5KLmM0YAZS0RxIKP5NB5h6xj/tP+zm90xzIU96BmNoPO8S+uRMAGa0MXhf0mUNxwUaHocuPGcOgyjToX1OQNgr0VupyLP8eL1XYgm9vzcvKP+IPkt8rzzF0xDn/nkZnstlrjhTneMaFCLTpQFMYrxbTBcespxv0xvK45n8bJCqk30eV18mwbTNSDh+3ljYYiFElvIgLGUQaFujM73z1u/EYPezs0c8uLEK+9IINSX1UQS5GhuOR2um+7oy1VrK4dpnn22c9WOh5cEEXsFnEzRzKI/vYm6vdusx+sQT8gvZZdwx0EtwWvoqEIoUZmMv6KBNEd0pi3Coe9P28GtPuNI9vyfGPvF9i1tO8uxrGFpxdVmvABkXlbPWoQKQSfJHSwiNIgdWVVyc1rl6qkPiEfrkXUEIf+R4quCWitDay4yXAFWoV4LXf8KHOpwzl3i7weI9cuM7sT7Y6hctKJOt6mxjzm/3viX+BsOwWmSFbniJgtDIRt7jiK0o54HwCoSGRI41itJhBNeUE4BKmtGEoA6M9kB8nx26JI5wLHkunfPGq6eqlpw+t4jWyS7Y+T8Xx4Hs/vIlCda4UgpVXBBoHvuvP/Jv4SJO1m8UJ/YiVn605qZuKW3oFjeZg=
13 changes: 10 additions & 3 deletions scripts/release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@

set -eo pipefail

VERSION=${TRAVIS_BRANCH#"release/"}
VERSION=${TRAVIS_BRANCH#"release/v"}

export PREVIOUS_RELEASE=$(curl -H "Authorization: token ${GITHUB_PERSONAL_ACCESS_TOKEN}" -s https://api.github.com/repos/web3j/web3j/releases/latest | jq -r '.target_commitish' )
export PREVIOUS_RELEASE=$(curl -H "Authorization: token ${GITHUB_PERSONAL_ACCESS_TOKEN}" -s https://api.github.com/repos/web3j/web3j-cli/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"
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)\",
Expand All @@ -18,7 +20,12 @@ API_JSON="{
}"


export RESULT=$(curl -H "Authorization: token ${GITHUB_PERSONAL_ACCESS_TOKEN}" --data "$API_JSON" -s https://api.github.com/repos/web3j/web3j-cli/releases)
export UPLOAD_URL=$(echo ${RESULT} | jq -r ".upload_url")

for FILE in `find ./build/distributions -type f -name "web3j.*"`;
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"

0 comments on commit 990bfe9

Please sign in to comment.