2014-03-01 20:46:10 -07:00
SHA := $( shell git rev-parse --short HEAD)
2015-01-12 16:51:54 +03:00
VERSION := $( shell cat VERSION)
ITTERATION := $( shell date +%s)
2014-02-07 03:10:01 -07:00
2014-06-21 14:22:38 -07:00
all : build
2014-04-10 17:44:26 +00:00
deps :
2014-06-12 13:01:11 -07:00
go get github.com/GeertJohan/go.rice/rice
2014-10-10 04:46:41 -04:00
go get -t -v ./...
2014-04-10 17:44:26 +00:00
2014-06-04 14:25:38 -07:00
test :
2015-01-11 18:35:30 +00:00
@test -z " $( shell find . -name '*.go' | xargs gofmt -l) " || ( echo "Need to run 'go fmt ./...'" ; exit 1)
2014-06-04 14:25:38 -07:00
go vet ./...
go test -cover -short ./...
2014-04-10 17:44:26 +00:00
2014-09-30 23:30:42 -07:00
test_mysql :
2014-11-15 16:10:33 +01:00
mysql -P 3306 --protocol= tcp -u root -e 'create database if not exists test;'
2014-09-30 23:30:42 -07:00
TEST_DRIVER = "mysql" TEST_DATASOURCE = "root@tcp(127.0.0.1:3306)/test" go test -short github.com/drone/drone/server/datastore/database
2014-11-15 16:10:33 +01:00
mysql -P 3306 --protocol= tcp -u root -e 'drop database test;'
2014-09-30 23:30:42 -07:00
test_postgres :
TEST_DRIVER = "postgres" TEST_DATASOURCE = "host=127.0.0.1 user=postgres dbname=postgres sslmode=disable" go test -short github.com/drone/drone/server/datastore/database
2014-07-13 19:41:08 -07:00
build :
2014-10-16 20:40:26 -07:00
mkdir -p packaging/output
2014-10-12 20:22:51 +04:00
mkdir -p packaging/root/usr/local/bin
2015-01-12 16:51:54 +03:00
go build -o packaging/root/usr/local/bin/drone -ldflags " -X main.revision $( SHA) -X main.version $( VERSION) " github.com/drone/drone/cli
go build -o packaging/root/usr/local/bin/droned -ldflags " -X main.revision $( SHA) -X main.version $( VERSION) " github.com/drone/drone/server
2014-07-13 19:41:08 -07:00
2014-07-16 22:14:53 -07:00
install :
2014-11-15 16:10:33 +01:00
install -t /usr/local/bin packaging/root/usr/local/bin/drone
install -t /usr/local/bin packaging/root/usr/local/bin/droned
2014-07-16 22:14:53 -07:00
2014-06-21 14:22:38 -07:00
run :
2014-09-28 18:36:24 -07:00
@go run server/main.go --config= $$ HOME/.drone/config.toml
2014-06-21 14:22:38 -07:00
2014-06-04 14:25:38 -07:00
clean :
2014-07-13 19:41:08 -07:00
find . -name "*.out" -delete
2014-10-12 20:22:51 +04:00
rm -rf packaging/output
rm -f packaging/root/usr/local/bin/drone
rm -f packaging/root/usr/local/bin/droned
2014-07-13 19:41:08 -07:00
lessc :
2014-10-29 10:33:07 +01:00
lessc --clean-css server/app/styles/drone.less | autoprefixer > server/app/styles/drone.css
2014-03-02 00:43:20 -05:00
2014-10-12 20:22:51 +04:00
packages : clean build embed deb rpm
2014-06-11 17:42:49 -07:00
2014-06-21 14:22:38 -07:00
# embeds content in go source code so that it is compiled
# and packaged inside the go binary file.
2014-07-13 19:41:08 -07:00
embed :
2014-10-12 20:22:51 +04:00
rice --import-path= "github.com/drone/drone/server" append --exec= "packaging/root/usr/local/bin/droned"
2014-02-07 03:10:01 -07:00
2014-06-21 14:22:38 -07:00
# creates a debian package for drone to install
# `sudo dpkg -i drone.deb`
deb :
2015-01-12 16:51:54 +03:00
fpm -s dir -t deb -n drone -v $( VERSION) -p packaging/output/drone.deb \
2014-10-12 20:22:51 +04:00
--deb-priority optional --category admin \
--force \
2015-01-12 16:51:54 +03:00
--iteration $( ITTERATION) \
2014-10-12 20:22:51 +04:00
--deb-compression bzip2 \
--after-install packaging/scripts/postinst.deb \
--before-remove packaging/scripts/prerm.deb \
--after-remove packaging/scripts/postrm.deb \
--url https://github.com/drone/drone \
--description "Drone continuous integration server" \
-m "Brad Rydzewski <brad@drone.io>" \
--license "Apache License 2.0" \
--vendor "drone.io" -a amd64 \
--config-files /etc/drone/drone.toml \
packaging/root/= /
2015-02-05 19:09:52 -08:00
cp packaging/output/drone.deb packaging/output/drone.deb.$( SHA)
2014-10-12 20:22:51 +04:00
rpm :
2015-01-12 16:51:54 +03:00
fpm -s dir -t rpm -n drone -v $( VERSION) -p packaging/output/drone.rpm \
2014-10-12 20:22:51 +04:00
--rpm-compression bzip2 --rpm-os linux \
--force \
2015-01-12 16:51:54 +03:00
--iteration $( ITTERATION) \
2014-10-12 20:22:51 +04:00
--after-install packaging/scripts/postinst.rpm \
--before-remove packaging/scripts/prerm.rpm \
--after-remove packaging/scripts/postrm.rpm \
--url https://github.com/drone/drone \
--description "Drone continuous integration server" \
-m "Brad Rydzewski <brad@drone.io>" \
--license "Apache License 2.0" \
--vendor "drone.io" -a amd64 \
--config-files /etc/drone/drone.toml \
packaging/root/= /
2014-07-11 15:29:31 -07:00
2014-07-13 19:41:08 -07:00
# deploys drone to a staging server. this requires the following
# environment variables are set:
#
# DRONE_STAGING_HOST -- the hostname or ip
# DRONE_STAGING_USER -- the username used to login
# DRONE_STAGING_KEY -- the identity file path (~/.ssh/id_rsa)
2014-07-11 15:29:31 -07:00
deploy :
2014-10-22 00:13:47 -07:00
scp -i $$ DRONE_STAGING_KEY packaging/output/drone.deb $$ DRONE_STAGING_USER@$$ DRONE_STAGING_HOST:/tmp
2014-10-13 18:49:43 +02:00
ssh -i $$ DRONE_STAGING_KEY $$ DRONE_STAGING_USER@$$ DRONE_STAGING_HOST -- dpkg -i /tmp/drone.deb