|
| 1 | +# > This script is designed to be run within a travis CI job, on the before_deploy step |
| 2 | +# > The will do the following: |
| 3 | +# 1. Configure the git user to dappnode |
| 4 | +# 2. Correct origin modify tags and push branches |
| 5 | +# 3. Remove current tag before creating the v0.X.Y tag. |
| 6 | +# 4. Install and run the dappnodesdk |
| 7 | +# 5. Compute the next version from the mainnet APM smart contract |
| 8 | +# 6. Generate the release files running the dappnodesdk |
| 9 | +# 7. Tag release with the correct version |
| 10 | + |
| 11 | +# > How to include the script in a .travis.yml |
| 12 | +# jobs: |
| 13 | +# include: |
| 14 | +# - stage: release |
| 15 | +# before_deploy: |
| 16 | +# - wget -O - https://raw.githubusercontent.com/dappnode/DAppNode/<path-to-script>/before_deploy.sh | bash |
| 17 | + |
| 18 | +echo "Running DAppNode travis CI before_deploy.sh script" |
| 19 | + |
| 20 | +# 1. Configure the git user to dappnode |
| 21 | +git config --global user.email "dappnode@dappnode.io" |
| 22 | +git config --global user.name "dappnode" |
| 23 | + |
| 24 | +# 2. Correct origin modify tags and push branches |
| 25 | +git remote rm origin |
| 26 | +git remote add origin https://user:${GITHUB_TOKEN}@github.com/${TRAVIS_REPO_SLUG}.git |
| 27 | + |
| 28 | +# 3. Remove current tag before creating the v0.X.Y tag. Fail safe, catch errors with || |
| 29 | +echo "Deleting previous tag $TRAVIS_TAG" |
| 30 | +git push --delete origin $TRAVIS_TAG || echo "Error deleting previous tag $TRAVIS_TAG from origin" |
| 31 | +git tag --delete $TRAVIS_TAG || echo "Error deleting previous tag $TRAVIS_TAG locally" |
| 32 | + |
| 33 | +# 4. Install the dappnodesdk |
| 34 | +# `travis_retry` does not work in an external script. Also travis mentioned that it doesn't work on the deploy stage |
| 35 | +npm install -g @dappnode/dappnodesdk |
| 36 | + |
| 37 | +# 5. Compute the next version from the mainnet APM smart contract |
| 38 | +export RELEASE_VERSION=$(dappnodesdk next patch -p infura) |
| 39 | +export TRAVIS_TAG="v${RELEASE_VERSION}" |
| 40 | +echo "NEXT TRAVIS_TAG $TRAVIS_TAG" |
| 41 | + |
| 42 | +# 6. Generate the release files running the dappnodesdk |
| 43 | +dappnodesdk publish patch -p infura |
| 44 | + |
| 45 | +# 7. Tag release with the correct version |
| 46 | +# (7.) Check if the tag exists, if so delete it. Fail safe, catch errors with || |
| 47 | +if [ $(git tag -l "$TRAVIS_TAG") ]; then export DELETE_TAG=true ; fi |
| 48 | +if [ $DELETE_TAG ]; then git push --delete origin $TRAVIS_TAG || echo "Error deleting tag $TRAVIS_TAG from origin" ; fi |
| 49 | +if [ $DELETE_TAG ]; then git tag --delete $TRAVIS_TAG || echo "Error deleting tag $TRAVIS_TAG locally" ; fi |
| 50 | +# (7.) Tag this commit |
| 51 | +git tag $TRAVIS_TAG |
| 52 | +# (7.) Return to master. |
| 53 | +# When travis is triggered by a tag this error happens: |
| 54 | +# > error: pathspec 'master' did not match any file(s) known to git. |
| 55 | +# A `git fetch` will be run to ensure that the master branch is present |
| 56 | +git fetch |
| 57 | +git checkout master |
| 58 | + |
| 59 | +echo "Successfully completed DAppNode travis CI before_deploy.sh script" |
0 commit comments