diff --git a/.drone.yml b/.drone.yml index a391db185..38eb3d1a1 100644 --- a/.drone.yml +++ b/.drone.yml @@ -9,11 +9,11 @@ pipeline: - make deps gen - make test test_postgres test_mysql - compile: + dist: image: golang:1.8 commands: - - export PATH=$PATH:/go/bin - - make build + - ./ci.sh + - ./dist.sh when: event: push @@ -28,19 +28,17 @@ pipeline: event: push branch: master - trigger: - image: plugins/downstream - server: https://beta.drone.io - fork: true - secrets: [ downstream_token ] - repositories: drone/drone-enterprise + publish: + image: plugins/docker + repo: drone/drone + secrets: [ docker_username, docker_password ] + tag: [ latest, 0.6, 0.6.0, 0.6.0-rc.2 ] when: branch: master event: push notify: image: plugins/gitter - dummy: true # todo remove this secrets: [ gitter_webhook ] when: status: [ success, failure ] diff --git a/.gitignore b/.gitignore index e722eade2..f722aaba0 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,6 @@ drone/drone *.sqlite *_gen.go -*_ee.go !store/datastore/sql/sqlite/sql_gen.go !store/datastore/sql/mysql/sql_gen.go !store/datastore/sql/postgres/sql_gen.go @@ -14,6 +13,7 @@ drone/drone *.deb .env temp/ +extras/ release/ server/frontend/bower_components diff --git a/ci.sh b/ci.sh new file mode 100755 index 000000000..6ff76fdae --- /dev/null +++ b/ci.sh @@ -0,0 +1,20 @@ +#!/bin/sh +set -e + +# only execute this script as part of the pipeline. +[ -z $CI ] && exit 1 + +# only execute the script when github token exists. +[ -z $SSH_KEY ] && exit 1 + +# write a netrc file for authorization. +mkdir -p $HOME/.ssh +echo -n "$SSH_KEY" > $HOME/.ssh/id_rsa +chmod 600 $HOME/.netrc + +# clone the extras project. +set +x +git clone git@github.com:drone/drone-enterprise.git extras + +# build a static binary with the build number and extra features. +go build -ldflags '-extldflags "-static" -X github.com/drone/drone/version.VersionDev=build.${DRONE_BUILD_NUMBER}' -tags extras -o release/drone github.com/drone/drone/drone diff --git a/dist.sh b/dist.sh new file mode 100755 index 000000000..8385f5309 --- /dev/null +++ b/dist.sh @@ -0,0 +1,21 @@ +#!/bin/sh +set -e +set -v + +GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -ldflags "-X github.com/drone/drone/version.VersionDev=build.${DRONE_BUILD_NUMBER}" -o release/linux/amd64/drone github.com/drone/drone/drone +GOOS=linux GOARCH=arm64 CGO_ENABLED=0 go build -ldflags "-X github.com/drone/drone/version.VersionDev=build.${DRONE_BUILD_NUMBER}" -o release/linux/arm64/drone github.com/drone/drone/drone +GOOS=linux GOARCH=arm CGO_ENABLED=0 go build -ldflags "-X github.com/drone/drone/version.VersionDev=build.${DRONE_BUILD_NUMBER}" -o release/linux/arm/drone github.com/drone/drone/drone +GOOS=windows GOARCH=amd64 CGO_ENABLED=0 go build -ldflags "-X github.com/drone/drone/version.VersionDev=build.${DRONE_BUILD_NUMBER}" -o release/windows/amd64/drone github.com/drone/drone/drone +GOOS=darwin GOARCH=amd64 CGO_ENABLED=0 go build -ldflags "-X github.com/drone/drone/version.VersionDev=build.${DRONE_BUILD_NUMBER}" -o release/darwin/amd64/drone github.com/drone/drone/drone + +tar -cvzf release/linux/amd64/drone.tar.gz -C release/linux/amd64 drone +tar -cvzf release/linux/arm64/drone.tar.gz -C release/linux/arm64 drone +tar -cvzf release/linux/arm/drone.tar.gz -C release/linux/arm drone +tar -cvzf release/windows/amd64/drone.tar.gz -C release/windows/amd64 drone +tar -cvzf release/darwin/amd64/drone.tar.gz -C release/darwin/amd64 drone + +sha256sum release/linux/amd64/drone.tar.gz > release/linux/amd64/drone.sha256 +sha256sum release/linux/arm64/drone.tar.gz > release/linux/arm64/drone.sha256 +sha256sum release/linux/arm/drone.tar.gz > release/linux/arm/drone.sha256 +sha256sum release/windows/amd64/drone.tar.gz > release/windows/amd64/drone.sha256 +sha256sum release/darwin/amd64/drone.tar.gz > release/darwin/amd64/drone.sha256 diff --git a/drone/main.go b/drone/main.go index 5d027692b..4a860715e 100644 --- a/drone/main.go +++ b/drone/main.go @@ -1,3 +1,5 @@ +// +build !extras + package main import ( diff --git a/drone/main_extras.go b/drone/main_extras.go new file mode 100644 index 000000000..61ae92802 --- /dev/null +++ b/drone/main_extras.go @@ -0,0 +1,63 @@ +// +build extras + +package main + +import ( + "fmt" + "os" + + "github.com/drone/drone/drone/agent" + "github.com/drone/drone/drone/build" + "github.com/drone/drone/drone/deploy" + "github.com/drone/drone/drone/exec" + "github.com/drone/drone/drone/info" + "github.com/drone/drone/drone/registry" + "github.com/drone/drone/drone/repo" + "github.com/drone/drone/drone/secret" + "github.com/drone/drone/drone/user" + "github.com/drone/drone/version" + + "github.com/drone/drone/extras/cmd/drone/server" + + "github.com/ianschenck/envflag" + _ "github.com/joho/godotenv/autoload" + "github.com/urfave/cli" +) + +func main() { + envflag.Parse() + + app := cli.NewApp() + app.Name = "drone" + app.Version = version.Version.String() + app.Usage = "command line utility" + app.Flags = []cli.Flag{ + cli.StringFlag{ + Name: "t, token", + Usage: "server auth token", + EnvVar: "DRONE_TOKEN", + }, + cli.StringFlag{ + Name: "s, server", + Usage: "server location", + EnvVar: "DRONE_SERVER", + }, + } + app.Commands = []cli.Command{ + agent.Command, + build.Command, + deploy.Command, + exec.Command, + info.Command, + registry.Command, + secret.Command, + server.Command, + repo.Command, + user.Command, + } + + if err := app.Run(os.Args); err != nil { + fmt.Fprintln(os.Stderr, err) + os.Exit(1) + } +}