diff --git a/.drone.yml b/.drone.yml index 6ab5db4..3b96ff0 100755 --- a/.drone.yml +++ b/.drone.yml @@ -10,91 +10,82 @@ pipeline: - dep ensure test: - image: golang:1.9 + image: golang:1.10 commands: - - go vet - - go test -cover -coverprofile=coverage.out + - go vet + - go test -cover -coverprofile=coverage.out build_linux_amd64: - image: golang:1.9 + image: golang:1.10 group: build environment: - - GOOS=linux - - GOARCH=amd64 - - CGO_ENABLED=0 + - GOOS=linux + - GOARCH=amd64 + - CGO_ENABLED=0 commands: - - go build -v -ldflags "-X main.build=${DRONE_BUILD_NUMBER}" -a -o release/linux/amd64/drone-rancher + - | + if test "${DRONE_TAG}" = ""; then + go build -v -ldflags "-X main.build=${DRONE_BUILD_NUMBER}" -a -o release/linux/amd64/${DRONE_REPO_NAME} + else + go build -v -ldflags "-X main.version=${DRONE_TAG##v} -X main.build=${DRONE_BUILD_NUMBER}" -a -o release/linux/amd64/${DRONE_REPO_NAME} + fi build_linux_arm64: - image: golang:1.9 + image: golang:1.10 group: build environment: - - GOOS=linux - - GOARCH=arm64 - - CGO_ENABLED=0 + - GOOS=linux + - GOARCH=arm64 + - CGO_ENABLED=0 commands: - - go build -v -ldflags "-X main.build=${DRONE_BUILD_NUMBER}" -a -o release/linux/arm64/drone-rancher + - | + if test "${DRONE_TAG}" = ""; then + go build -v -ldflags "-X main.build=${DRONE_BUILD_NUMBER}" -a -o release/linux/arm64/${DRONE_REPO_NAME} + else + go build -v -ldflags "-X main.version=${DRONE_TAG##v} -X main.build=${DRONE_BUILD_NUMBER}" -a -o release/linux/arm64/${DRONE_REPO_NAME} + fi build_linux_arm: - image: golang:1.9 + image: golang:1.10 group: build environment: - - GOOS=linux - - GOARCH=arm - - CGO_ENABLED=0 - - GOARM=7 + - GOOS=linux + - GOARCH=arm + - CGO_ENABLED=0 + - GOARM=7 commands: - - go build -v -ldflags "-X main.build=${DRONE_BUILD_NUMBER}" -a -o release/linux/arm/drone-rancher - - # build_windows_amd64: - # image: golang:1.9-nanoserver - # group: build - # environment: - # - GOOS=windows - # - GOARCH=amd64 - # - CGO_ENABLED=0 - # commands: - # - go build -v -ldflags "-X main.build=${DRONE_BUILD_NUMBER}" -a -o release/windows/amd64/drone-webhook + - | + if test "${DRONE_TAG}" = ""; then + go build -v -ldflags "-X main.build=${DRONE_BUILD_NUMBER}" -a -o release/linux/arm/${DRONE_REPO_NAME} + else + go build -v -ldflags "-X main.version=${DRONE_TAG##v} -X main.build=${DRONE_BUILD_NUMBER}" -a -o release/linux/arm/${DRONE_REPO_NAME} + fi publish_linux_amd64: image: plugins/docker - username: josmo - repo: peloton/drone-rancher + group: publish auto_tag: true - secrets: [ docker_password ] + secrets: [ docker_password, docker_username, plugin_repo ] dockerfile: Dockerfile when: event: [ tag, push ] publish_linux_arm64: image: plugins/docker - username: josmo - repo: peloton/drone-rancher + group: publish auto_tag: true auto_tag_suffix: linux-arm64 - secrets: [ docker_password ] + secrets: [ docker_password, docker_username, plugin_repo ] dockerfile: Dockerfile.arm64 when: event: [ tag, push ] publish_linux_arm: image: plugins/docker - username: josmo - repo: peloton/drone-rancher + group: publish auto_tag: true auto_tag_suffix: linux-arm - secrets: [ docker_password ] + secrets: [ docker_password, docker_username, plugin_repo ] dockerfile: Dockerfile.arm when: event: [ tag, push ] - - # publish_windows_amd64: - # image: plugins/docker - # username: josmo - # repo: peloton/drone-rancher - # tags: [ windows-amd64 ] - # secrets: [ docker_password ] - # dockerfile: Dockerfile.windows - # when: - # branch: master - # event: push diff --git a/.gitignore b/.gitignore index 617578b..f83f86d 100755 --- a/.gitignore +++ b/.gitignore @@ -28,3 +28,4 @@ drone-rancher *.idea vendor +release diff --git a/README.md b/README.md index f0d7f69..331ce17 100755 --- a/README.md +++ b/README.md @@ -33,3 +33,12 @@ docker run --rm \ -w $(pwd) \ peloton/drone-rancher ``` + +### Contribution + +This repo is setup in a way that if you enable a personal drone server to build your fork it will + build and publish your image (makes it easier to test PRs and use the image till the contributions get merged) + +* Build local ```DRONE_REPO_OWNER=josmo DRONE_REPO_NAME=drone-rancher drone exec``` +* on your server just make sure you have DOCKER_USERNAME, DOCKER_PASSWORD, and PLUGIN_REPO set as secrets + \ No newline at end of file diff --git a/main.go b/main.go index 7660865..80a1c4b 100755 --- a/main.go +++ b/main.go @@ -8,14 +8,17 @@ import ( "github.com/urfave/cli" ) -var build string // build number set at compile-time +var ( + version = "0.0.0" + build = "0" +) func main() { app := cli.NewApp() app.Name = "rancher publish" app.Usage = "rancher publish" app.Action = run - app.Version = fmt.Sprintf("1.0.0+%s", build) + app.Version = fmt.Sprintf("%s+%s", version, build) app.Flags = []cli.Flag{