Skip to content

Commit 71469a1

Browse files
authored
Merge pull request #53 from dappnode/dapplion-patch-1
Add common deploy scripts for all DNPs
2 parents a1d0e0d + 12338ce commit 71469a1

File tree

2 files changed

+102
-0
lines changed

2 files changed

+102
-0
lines changed

scripts/after_deploy.sh

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# > This script is designed to be run within a travis CI job, on the after_deploy step
2+
# > The will do the following:
3+
# 1. Commit the new versions of the docker-compose.yml and dappnode_package.json
4+
# 2. Create a new branch with the next version number
5+
# 3. Commit the new*new versions of the docker-compose.yml and dappnode_package.json
6+
# 4. Open a pull request to master
7+
8+
# > How to include the script in a .travis.yml
9+
# jobs:
10+
# include:
11+
# - stage: release
12+
# after_deploy:
13+
# - wget -O - https://raw.githubusercontent.com/dappnode/DAppNode/<path-to-script>/after_deploy.sh | bash
14+
15+
echo "Running DAppNode travis CI after_deploy.sh script"
16+
17+
# NOTE: git user and remote origin should be already configured from the before script
18+
19+
# 1. Commit the new versions of the docker-compose.yml and dappnode_package.json
20+
git add "dappnode_package.json"
21+
git add "docker-compose.yml"
22+
# Attempt the commit and push. In case of error (no changes), ignore
23+
git commit -m "Update manifest and docker-compose versions to current release: $TRAVIS_TAG" && git push origin || echo "Files are already updated"
24+
25+
# 2. Create a new branch with the next version number
26+
# Check if the dappnodesdk is available
27+
dappnodesdk --help
28+
export FUTURE_VERSION=$(dappnodesdk increase patch -p infura -s)
29+
echo "dappnodesdk increase patch output: $FUTURE_VERSION"
30+
export BRANCH_NAME="v${FUTURE_VERSION}"
31+
echo "Run dappnodesdk and increased version to FUTURE_VERSION: $FUTURE_VERSION"
32+
git checkout -b $BRANCH_NAME
33+
34+
# 3. Commit the new*new versions of the docker-compose.yml and dappnode_package.json
35+
git add "dappnode_package.json"
36+
git add "docker-compose.yml"
37+
git commit -m "Advance manifest and docker-compose versions to new version: $FUTURE_VERSION"
38+
git push origin $BRANCH_NAME
39+
40+
# 4. Open a pull request to master
41+
# It's not straight forward so this step will be skipped by now.
42+
43+
echo "Successfully completed DAppNode travis CI after_deploy.sh script"

scripts/before_deploy.sh

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
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

Comments
 (0)