Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions scripts/after_deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# > This script is designed to be run within a travis CI job, on the after_deploy step
# > The will do the following:
# 1. Commit the new versions of the docker-compose.yml and dappnode_package.json
# 2. Create a new branch with the next version number
# 3. Commit the new*new versions of the docker-compose.yml and dappnode_package.json
# 4. Open a pull request to master

# > How to include the script in a .travis.yml
# jobs:
# include:
# - stage: release
# after_deploy:
# - wget -O - https://raw.githubusercontent.com/dappnode/DAppNode/<path-to-script>/after_deploy.sh | bash

echo "Running DAppNode travis CI after_deploy.sh script"

# NOTE: git user and remote origin should be already configured from the before script

# 1. Commit the new versions of the docker-compose.yml and dappnode_package.json
git add "dappnode_package.json"
git add "docker-compose.yml"
# Attempt the commit and push. In case of error (no changes), ignore
git commit -m "Update manifest and docker-compose versions to current release: $TRAVIS_TAG" && git push origin || echo "Files are already updated"

# 2. Create a new branch with the next version number
# Check if the dappnodesdk is available
dappnodesdk --help
export FUTURE_VERSION=$(dappnodesdk increase patch -p infura -s)
echo "dappnodesdk increase patch output: $FUTURE_VERSION"
export BRANCH_NAME="v${FUTURE_VERSION}"
echo "Run dappnodesdk and increased version to FUTURE_VERSION: $FUTURE_VERSION"
git checkout -b $BRANCH_NAME

# 3. Commit the new*new versions of the docker-compose.yml and dappnode_package.json
git add "dappnode_package.json"
git add "docker-compose.yml"
git commit -m "Advance manifest and docker-compose versions to new version: $FUTURE_VERSION"
git push origin $BRANCH_NAME

# 4. Open a pull request to master
# It's not straight forward so this step will be skipped by now.

echo "Successfully completed DAppNode travis CI after_deploy.sh script"
59 changes: 59 additions & 0 deletions scripts/before_deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# > 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
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"