Skip to content

Commit

Permalink
Merge pull request #421 from nervosnetwork/github-release
Browse files Browse the repository at this point in the history
chore: build release packages in travis
  • Loading branch information
doitian committed Apr 10, 2019
2 parents 3473406 + fa52571 commit 79a9ea2
Show file tree
Hide file tree
Showing 6 changed files with 170 additions and 3 deletions.
16 changes: 13 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ git:
depth: 2
submodules: false

if: 'branch IN (master, develop, staging, trying) OR type != push OR fork = true OR tag =~ ^v'
if: 'branch IN (master, develop, staging, trying) OR type != push OR fork = true OR tag IS present'

env:
global:
Expand All @@ -18,10 +18,10 @@ matrix:
include:
- rust: 1.33.0
os: osx
env: FMT=true CHECK=true TEST=true
env: FMT=true CHECK=true TEST=true REL_PKG=darwin_amd64.zip
- rust: 1.33.0
os: linux
env: TEST=true
env: TEST=true REL_PKG=linux_amd64.tar.gz

addons:
apt:
Expand All @@ -37,6 +37,16 @@ before_install: if [ "$TRAVIS_OS_NAME" = "osx" ]; then ulimit -n 8192; fi
install: ./devtools/ci/install.sh
script: ./devtools/ci/script.sh

deploy:
provider: releases
api_key: "$GITHUB_TOKEN"
file: "releases/ckb_${TRAVIS_TAG}_${REL_PKG}"
skip_cleanup: true
draft: true
on:
tags: true
condition: '"$GITHUB_TOKEN" != "" && "$REL_PKG" != ""'

before_cache:
- rm -rf ./target/debug/incremental/
- cargo sweep -f
22 changes: 22 additions & 0 deletions devtools/ci/script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,25 @@ if [ "$TRAVIS_BRANCH" = master -o "$TRAVIS_BRANCH" = staging -o "$TRAVIS_BRANCH"
# cargo build --release
# cargo run --release -p ckb-test target/release/ckb
fi

if [ -n "$TRAVIS_TAG" -a -n "$GITHUB_TOKEN" -a -n "$REL_PKG" ]; then
make build
rm -rf releases
mkdir releases
PKG_NAME="ckb_${TRAVIS_TAG}_${REL_PKG%%.*}"
mkdir "releases/$PKG_NAME"
mv target/release/ckb "releases/$PKG_NAME"
cp README.md CHANGELOG.md COPYING "releases/$PKG_NAME"
cp -R devtools/init/ "releases/$PKG_NAME"
if [ -d docs ]; then
cp -R docs "releases/$PKG_NAME"
fi

pushd releases
if [ "${REL_PKG#*.}" = "tar.gz" ]; then
tar -czf $PKG_NAME.tar.gz $PKG_NAME
else
zip -r $PKG_NAME.zip $PKG_NAME
fi
popd
fi
11 changes: 11 additions & 0 deletions devtools/init/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Init/Service Scripts

This folder provides the init/service scripts to start CKB node and miner as
daemons on various Unix like distributions.

See the README in each folder for the detailed instructions.

## Disclaimer

Users are expected to know how to administer their system, and these files
should be considered as only a guide or suggestion to setup CKB.
82 changes: 82 additions & 0 deletions devtools/init/linux-systemd/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
# CKB systemd unit configuration

The provided files should work with systemd version 219 or later.

## Instructions

The following instructions assume that:

* you want to run ckb as user `ckb` and group `ckb`, and store data in `/var/lib/ckb`.
* you want to join testnet.
* you are logging in as a non-root user account that has `sudo` permissions to execute commands as root.

First, get ckb and move the binary into the system binary directory, and setup the appropriate ownership and permissions:

```bash
sudo cp /path/to/ckb /usr/local/bin
sudo chown root:root /usr/local/bin/ckb
sudo chmod 755 /usr/local/bin/ckb
```

Setup the directories and generate config files for testnet.

```bash
sudo mkdir /var/lib/ckb
sudo /usr/local/bin/ckb init -C /var/lib/ckb --spec testnet --log stdout
```

Setup the user and group and the appropriate ownership and permissions.

```bash
sudo groupadd ckb
sudo useradd \
-g ckb --no-user-group \
--home-dir /var/lib/ckb --no-create-home \
--shell /usr/sbin/nologin \
--system ckb

sudo chown -R ckb:ckb /var/lib/ckb
sudo chmod 755 /var/lib/ckb
sudo chmod 644 /var/lib/ckb/ckb.toml /var/lib/ckb/ckb-miner.toml
```

Install the systemd service unit configuration file, reload the systemd daemon,
and start the node:

```bash
curl -L -O https://raw.githubusercontent.com/nervosnetwork/ckb/master/devtools/init/linux-systemd/ckb.service
sudo cp ckb.service /etc/systemd/system/
sudo chown root:root /etc/systemd/system/ckb.service
sudo chmod 644 /etc/systemd/system/ckb.service
sudo systemctl daemon-reload
sudo systemctl start ckb.service
```

Start the node automatically on boot if you like:

```bash
sudo systemctl enable ckb.service
```

If ckb doesn't seem to start properly you can view the logs to figure out the problem:

```bash
journalctl --boot -u ckb.service
```

Following the similar instructions to start a miner:

```bash
curl -L -O https://raw.githubusercontent.com/nervosnetwork/ckb/master/devtools/init/linux-systemd/ckb-miner.service
sudo cp ckb-miner.service /etc/systemd/system/
sudo chown root:root /etc/systemd/system/ckb-miner.service
sudo chmod 644 /etc/systemd/system/ckb-miner.service
sudo systemctl daemon-reload
sudo systemctl start ckb-miner.service
```

Let the miner starts automatically on boot:

```bash
sudo systemctl enable ckb-miner.service
```
21 changes: 21 additions & 0 deletions devtools/init/linux-systemd/ckb-miner.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
[Unit]
Description=Nervos CKB Miner
Documentation=https://github.com/nervosnetwork/ckb
After=network-online.target
Wants=network-online.target systemd-networkd-wait-online.service

[Service]
User=ckb
Group=ckb
WorkingDirectory=/var/lib/ckb

ExecStart=/usr/local/bin/ckb miner
Restart=on-abnormal
KillMode=mixed
TimeoutStopSec=5s

LimitNOFILE=1048576
LimitNPROC=512

[Install]
WantedBy=multi-user.target
21 changes: 21 additions & 0 deletions devtools/init/linux-systemd/ckb.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
[Unit]
Description=Nervos CKB Node
Documentation=https://github.com/nervosnetwork/ckb
After=network-online.target
Wants=network-online.target systemd-networkd-wait-online.service

[Service]
User=ckb
Group=ckb
WorkingDirectory=/var/lib/ckb

ExecStart=/usr/local/bin/ckb
Restart=on-abnormal
KillMode=mixed
TimeoutStopSec=5s

LimitNOFILE=1048576
LimitNPROC=512

[Install]
WantedBy=multi-user.target

0 comments on commit 79a9ea2

Please sign in to comment.