-
Notifications
You must be signed in to change notification settings - Fork 103
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
Showing
2 changed files
with
110 additions
and
0 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
language: node_js | ||
dist: trusty | ||
sudo: required | ||
|
||
stages: | ||
- name: build-test | ||
if: tag !~ ^release*$" | ||
- name: release | ||
if: tag =~ ^release*$" | ||
|
||
jobs: | ||
include: | ||
# Test that it builds correctly | ||
############################### | ||
- stage: build-test | ||
if: env(TRAVIS_TAG) != master | ||
services: | ||
- docker | ||
script: | ||
- docker-compose build | ||
|
||
# Deploy stage | ||
# - code below is common between DAppNode packages | ||
################################################## | ||
- stage: release | ||
services: | ||
- docker | ||
script: skip | ||
node_js: lts/* | ||
before_deploy: | ||
- wget https://raw.githubusercontent.com/dappnode/DAppNode/master/scripts/before_deploy.sh | ||
- source before_deploy.sh | ||
deploy: | ||
provider: releases | ||
prerelease: true | ||
api_key: "$GITHUB_TOKEN" | ||
file_glob: true | ||
# $RELEASE_VERSION is exported on before_deploy.sh | ||
file: build_${RELEASE_VERSION}/* | ||
skip_cleanup: true | ||
# $TRAVIS_TAG is exported on before_deploy.sh | ||
name: "$TRAVIS_TAG" | ||
body: "# Changelog" | ||
on: | ||
branch: master | ||
tags: true | ||
condition: "$TRAVIS_TAG =~ ^release*$" | ||
after_deploy: | ||
- wget https://raw.githubusercontent.com/dappnode/DAppNode/master/scripts/after_deploy.sh | ||
- source after_deploy.sh |
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,60 @@ | ||
# > This script is designed to be run within a travis CI job, on the before_deploy step | ||
# > The will do the following: | ||
# 1. Configure the git user to dappnode | ||
# 2. Correct origin modify tags and push branches | ||
# 3. Remove current tag before creating the v0.X.Y tag. | ||
# 4. Install and run the dappnodesdk | ||
# 5. Compute the next version from the mainnet APM smart contract | ||
# 6. Generate the release files running the dappnodesdk | ||
# 7. Tag release with the correct version | ||
|
||
# > How to include the script in a .travis.yml | ||
# jobs: | ||
# include: | ||
# - stage: release | ||
# before_deploy: | ||
# - wget -O - https://raw.githubusercontent.com/dappnode/DAppNode/<path-to-script>/before_deploy.sh | bash | ||
|
||
echo "Running DAppNode travis CI before_deploy.sh script" | ||
|
||
# 1. Configure the git user to dappnode | ||
git config --global user.email "dappnode@dappnode.io" | ||
git config --global user.name "dappnode" | ||
|
||
# 2. Correct origin modify tags and push branches | ||
git remote rm origin | ||
git remote add origin https://user:${GITHUB_TOKEN}@github.com/${TRAVIS_REPO_SLUG}.git | ||
|
||
# 3. Remove current tag before creating the v0.X.Y tag. Fail safe, catch errors with || | ||
echo "Deleting previous tag $TRAVIS_TAG" | ||
git push --delete origin $TRAVIS_TAG || echo "Error deleting previous tag $TRAVIS_TAG from origin" | ||
git tag --delete $TRAVIS_TAG || echo "Error deleting previous tag $TRAVIS_TAG locally" | ||
|
||
# 4. Install the dappnodesdk | ||
# `travis_retry` does not work in an external script. Also travis mentioned that it doesn't work on the deploy stage | ||
npm install -g @dappnode/dappnodesdk | ||
|
||
# 5. Compute the next version from the mainnet APM smart contract | ||
export RELEASE_VERSION=$(dappnodesdk next patch -p infura) | ||
export TRAVIS_TAG="v${RELEASE_VERSION}" | ||
echo "NEXT TRAVIS_TAG $TRAVIS_TAG" | ||
|
||
# 6. Generate the release files running the dappnodesdk | ||
# The DNP_ETHCHAIN takes > 60 min to build. This command triggers a timeout and should be run directly from the travis yml to prevent it. | ||
# dappnodesdk publish patch -p infura | ||
|
||
# 7. Tag release with the correct version | ||
# (7.) Check if the tag exists, if so delete it. Fail safe, catch errors with || | ||
if [ $(git tag -l "$TRAVIS_TAG") ]; then export DELETE_TAG=true ; fi | ||
if [ $DELETE_TAG ]; then git push --delete origin $TRAVIS_TAG || echo "Error deleting tag $TRAVIS_TAG from origin" ; fi | ||
if [ $DELETE_TAG ]; then git tag --delete $TRAVIS_TAG || echo "Error deleting tag $TRAVIS_TAG locally" ; fi | ||
# (7.) Tag this commit | ||
git tag $TRAVIS_TAG | ||
# (7.) Return to master. | ||
# When travis is triggered by a tag this error happens: | ||
# > error: pathspec 'master' did not match any file(s) known to git. | ||
# A `git fetch` will be run to ensure that the master branch is present | ||
git fetch | ||
git checkout master | ||
|
||
echo "Successfully completed DAppNode travis CI before_deploy.sh script" |