From bbcc572d481817938d574f06d97c3294bc76fde3 Mon Sep 17 00:00:00 2001 From: Thomas Boerger Date: Sun, 20 Jan 2019 23:51:58 +0100 Subject: [PATCH] Migrate configs to drone 1.0.0 and drop appveyor --- .appveyor.yml | 66 -------- .drone.jsonnet | 161 ++++++++++++++++++ .drone.windows.yml | 70 ++++++++ .drone.yml | 408 ++++++++++++++++++++++++++++++--------------- 4 files changed, 507 insertions(+), 198 deletions(-) delete mode 100644 .appveyor.yml create mode 100644 .drone.jsonnet create mode 100644 .drone.windows.yml diff --git a/.appveyor.yml b/.appveyor.yml deleted file mode 100644 index 5bfa10a..0000000 --- a/.appveyor.yml +++ /dev/null @@ -1,66 +0,0 @@ -version: '{build}' -image: 'Visual Studio 2017' -platform: 'x64' - -clone_folder: 'c:\gopath\src\github.com\drone-plugins\drone-ansible' -max_jobs: 1 - -environment: - GOPATH: c:\gopath - DOCKER_USERNAME: - secure: '4YzzahbEiMZQJpOCOd1LAw==' - DOCKER_PASSWORD: - secure: 'VqO/G3Zfslu6zSLdwHKO+Q==' - GO111MODULE: on - -install: - - ps: | - docker version - go version - - ps: | - $env:Path = "c:\gopath\bin;$env:Path" - -build_script: - - ps: | - if ( $env:APPVEYOR_REPO_TAG -eq 'false' ) { - go build -ldflags "-X main.build=$env:APPVEYOR_BUILD_VERSION" -a -o release/drone-ansible.exe - } else { - $version = $env:APPVEYOR_REPO_TAG_NAME.substring(1) - go build -ldflags "-X main.version=$version -X main.build=$env:APPVEYOR_BUILD_VERSION" -a -o release/drone-ansible.exe - } - - docker pull microsoft/nanoserver:10.0.14393.1593 - docker build -f Dockerfile.windows -t plugins/ansible:windows-amd64 . - -test_script: - - ps: | - docker run --rm plugins/ansible:windows-amd64 --version - -deploy_script: - - ps: | - $ErrorActionPreference = 'Stop'; - - if ( $env:APPVEYOR_PULL_REQUEST_NUMBER ) { - Write-Host Nothing to deploy. - } else { - echo $env:DOCKER_PASSWORD | docker login --username $env:DOCKER_USERNAME --password-stdin - - if ( $env:APPVEYOR_REPO_TAG -eq 'true' ) { - $major,$minor,$patch = $env:APPVEYOR_REPO_TAG_NAME.substring(1).split('.') - - docker push plugins/ansible:windows-amd64 - - docker tag plugins/ansible:windows-amd64 plugins/ansible:$major.$minor.$patch-windows-amd64 - docker push plugins/ansible:$major.$minor.$patch-windows-amd64 - - docker tag plugins/ansible:windows-amd64 plugins/ansible:$major.$minor-windows-amd64 - docker push plugins/ansible:$major.$minor-windows-amd64 - - docker tag plugins/ansible:windows-amd64 plugins/ansible:$major-windows-amd64 - docker push plugins/ansible:$major-windows-amd64 - } else { - if ( $env:APPVEYOR_REPO_BRANCH -eq 'master' ) { - docker push plugins/ansible:windows-amd64 - } - } - } diff --git a/.drone.jsonnet b/.drone.jsonnet new file mode 100644 index 0000000..5de825a --- /dev/null +++ b/.drone.jsonnet @@ -0,0 +1,161 @@ +local PipelineTesting = { + kind: "pipeline", + name: "testing", + platform: { + os: "linux", + arch: "amd64", + }, + steps: [ + { + name: "vet", + image: "golang:1.11", + pull: "always", + environment: { + GO111MODULE: "on", + }, + commands: [ + "go vet ./...", + ], + }, + { + name: "test", + image: "golang:1.11", + pull: "always", + environment: { + GO111MODULE: "on", + }, + commands: [ + "go test -cover ./...", + ], + }, + ], + trigger: { + branch: [ "master" ], + }, +}; + +local PipelineBuild(os="linux", arch="amd64") = { + kind: "pipeline", + name: os + "-" + arch, + platform: { + os: os, + arch: arch, + }, + steps: [ + { + name: "build", + image: "golang:1.11", + pull: "always", + environment: { + CGO_ENABLED: "0", + GO111MODULE: "on", + }, + commands: [ + "go build -v -ldflags \"-X main.build=${DRONE_BUILD_NUMBER}\" -a -o release/" + os + "/" + arch + "/drone-ansible", + ], + when: { + event: [ "push", "pull_request" ], + }, + }, + { + name: "build", + image: "golang:1.11", + pull: "always", + environment: { + CGO_ENABLED: "0", + GO111MODULE: "on", + }, + commands: [ + "go build -v -ldflags \"-X main.version=${DRONE_TAG##v} -X main.build=${DRONE_BUILD_NUMBER}\" -a -o release/" + os + "/" + arch + "/drone-ansible", + ], + when: { + event: [ "tag" ], + }, + }, + { + name: "dryrun", + image: "plugins/docker:" + os + "-" + arch, + pull: "always", + settings: { + dry_run: true, + tags: os + "-" + arch, + dockerfile: "docker/Dockerfile." + os + "." + arch, + repo: "plugins/ansible", + username: { "from_secret": "docker_username" }, + password: { "from_secret": "docker_password" }, + }, + when: { + event: [ "pull_request" ], + }, + }, + { + name: "publish", + image: "plugins/docker:" + os + "-" + arch, + pull: "always", + settings: { + auto_tag: true, + auto_tag_suffix: os + "-" + arch, + dockerfile: "docker/Dockerfile." + os + "." + arch, + repo: "plugins/ansible", + username: { "from_secret": "docker_username" }, + password: { "from_secret": "docker_password" }, + }, + when: { + event: [ "push", "tag" ], + }, + }, + ], + depends_on: [ + "testing", + ], + trigger: { + branch: [ "master" ], + }, +}; + +local PipelineNotifications = { + kind: "pipeline", + name: "notifications", + platform: { + os: "linux", + arch: "amd64", + }, + steps: [ + { + name: "manifest", + image: "plugins/manifest:1", + pull: "always", + settings: { + username: { "from_secret": "docker_username" }, + password: { "from_secret": "docker_password" }, + spec: "docker/manifest.tmpl", + ignore_missing: true, + }, + }, + { + name: "microbadger", + image: "plugins/webhook:1", + pull: "always", + settings: { + url: { "from_secret": "microbadger_url" }, + }, + }, + ], + depends_on: [ + "linux-amd64", + "linux-arm64", + "linux-arm", + ], + trigger: { + branch: [ "master" ], + event: [ "push", "tag" ], + }, +}; + +[ + PipelineTesting, + PipelineBuild("linux", "amd64"), + PipelineBuild("linux", "arm64"), + PipelineBuild("linux", "arm"), + PipelineNotifications, +] diff --git a/.drone.windows.yml b/.drone.windows.yml new file mode 100644 index 0000000..55a2139 --- /dev/null +++ b/.drone.windows.yml @@ -0,0 +1,70 @@ +--- +kind: pipeline +name: linux-amd64 + +platform: + os: linux + arch: amd64 + +steps: +- name: build + pull: always + image: golang:1.11 + commands: + - "go build -v -ldflags \"-X main.build=${DRONE_BUILD_NUMBER}\" -a -o release/linux/amd64/drone-ansible" + environment: + CGO_ENABLED: 0 + GO111MODULE: on + when: + event: + - push + - pull_request + +- name: build + pull: always + image: golang:1.11 + commands: + - "go build -v -ldflags \"-X main.version=${DRONE_TAG##v} -X main.build=${DRONE_BUILD_NUMBER}\" -a -o release/linux/amd64/drone-ansible" + environment: + CGO_ENABLED: 0 + GO111MODULE: on + when: + event: + - tag + +- name: dryrun + pull: always + image: plugins/docker:linux-amd64 + settings: + dockerfile: docker/Dockerfile.linux.amd64 + dry_run: true + password: + from_secret: docker_password + repo: plugins/ansible + tags: linux-amd64 + username: + from_secret: docker_username + when: + event: + - pull_request + +- name: publish + pull: always + image: plugins/docker:linux-amd64 + settings: + auto_tag: true + auto_tag_suffix: linux-amd64 + dockerfile: docker/Dockerfile.linux.amd64 + password: + from_secret: docker_password + repo: plugins/ansible + username: + from_secret: docker_username + when: + event: + - push + - tag + +trigger: + branch: + - master diff --git a/.drone.yml b/.drone.yml index 3f2ac21..d0a07d9 100644 --- a/.drone.yml +++ b/.drone.yml @@ -1,147 +1,291 @@ -workspace: - base: /go - path: src/github.com/drone-plugins/drone-ansible +--- +kind: pipeline +name: testing -pipeline: - test: - image: golang:1.11 - pull: true - environment: - - GO111MODULE=on - commands: - - go vet ./... - - go test -cover ./... +platform: + os: linux + arch: amd64 - build_linux_amd64: - image: golang:1.11 - pull: true - group: build - environment: - - GOOS=linux - - GOARCH=amd64 - - CGO_ENABLED=0 - - GO111MODULE=on - commands: - - | - if test "${DRONE_TAG}" = ""; then - go build -v -ldflags "-X main.build=${DRONE_BUILD_NUMBER}" -a -o release/linux/amd64/drone-ansible - else - go build -v -ldflags "-X main.version=${DRONE_TAG##v} -X main.build=${DRONE_BUILD_NUMBER}" -a -o release/linux/amd64/drone-ansible - fi +steps: +- name: vet + pull: always + image: golang:1.11 + commands: + - go vet ./... + environment: + GO111MODULE: on - # build_linux_i386: - # image: golang:1.11 - # pull: true - # group: build - # environment: - # - GOOS=linux - # - GOARCH=386 - # - CGO_ENABLED=0 - # - GO111MODULE=on - # commands: - # - | - # if test "${DRONE_TAG}" = ""; then - # go build -v -ldflags "-X main.build=${DRONE_BUILD_NUMBER}" -a -o release/linux/i386/drone-ansible - # else - # go build -v -ldflags "-X main.version=${DRONE_TAG##v} -X main.build=${DRONE_BUILD_NUMBER}" -a -o release/linux/i386/drone-ansible - # fi +- name: test + pull: always + image: golang:1.11 + commands: + - go test -cover ./... + environment: + GO111MODULE: on - # build_linux_arm64: - # image: golang:1.11 - # pull: true - # group: build - # environment: - # - GOOS=linux - # - GOARCH=arm64 - # - CGO_ENABLED=0 - # - GO111MODULE=on - # commands: - # - | - # if test "${DRONE_TAG}" = ""; then - # go build -v -ldflags "-X main.build=${DRONE_BUILD_NUMBER}" -a -o release/linux/arm64/drone-ansible - # else - # go build -v -ldflags "-X main.version=${DRONE_TAG##v} -X main.build=${DRONE_BUILD_NUMBER}" -a -o release/linux/arm64/drone-ansible - # fi +trigger: + branch: + - master - # build_linux_arm: - # image: golang:1.11 - # pull: true - # group: build - # environment: - # - GOOS=linux - # - GOARCH=arm - # - CGO_ENABLED=0 - # - GOARM=7 - # - GO111MODULE=on - # commands: - # - | - # if test "${DRONE_TAG}" = ""; then - # go build -v -ldflags "-X main.build=${DRONE_BUILD_NUMBER}" -a -o release/linux/arm/drone-ansible - # else - # go build -v -ldflags "-X main.version=${DRONE_TAG##v} -X main.build=${DRONE_BUILD_NUMBER}" -a -o release/linux/arm/drone-ansible - # fi +--- +kind: pipeline +name: linux-amd64 - publish_linux_amd64: - image: plugins/docker:17.12 - pull: true - secrets: [ docker_username, docker_password ] - group: docker +platform: + os: linux + arch: amd64 + +steps: +- name: build + pull: always + image: golang:1.11 + commands: + - "go build -v -ldflags \"-X main.build=${DRONE_BUILD_NUMBER}\" -a -o release/linux/amd64/drone-ansible" + environment: + CGO_ENABLED: 0 + GO111MODULE: on + when: + event: + - push + - pull_request + +- name: build + pull: always + image: golang:1.11 + commands: + - "go build -v -ldflags \"-X main.version=${DRONE_TAG##v} -X main.build=${DRONE_BUILD_NUMBER}\" -a -o release/linux/amd64/drone-ansible" + environment: + CGO_ENABLED: 0 + GO111MODULE: on + when: + event: + - tag + +- name: dryrun + pull: always + image: plugins/docker:linux-amd64 + settings: + dockerfile: docker/Dockerfile.linux.amd64 + dry_run: true + password: + from_secret: docker_password repo: plugins/ansible + tags: linux-amd64 + username: + from_secret: docker_username + when: + event: + - pull_request + +- name: publish + pull: always + image: plugins/docker:linux-amd64 + settings: auto_tag: true auto_tag_suffix: linux-amd64 - dockerfile: Dockerfile - when: - event: [ push, tag ] + dockerfile: docker/Dockerfile.linux.amd64 + password: + from_secret: docker_password + repo: plugins/ansible + username: + from_secret: docker_username + when: + event: + - push + - tag - # publish_linux_i386: - # image: plugins/docker:17.12 - # pull: true - # secrets: [ docker_username, docker_password ] - # group: docker - # repo: plugins/ansible - # auto_tag: true - # auto_tag_suffix: linux-i386 - # dockerfile: Dockerfile.i386 - # when: - # event: [ push, tag ] +trigger: + branch: + - master - # publish_linux_arm64: - # image: plugins/docker:17.12 - # pull: true - # secrets: [ docker_username, docker_password ] - # group: docker - # repo: plugins/ansible - # auto_tag: true - # auto_tag_suffix: linux-arm64 - # dockerfile: Dockerfile.arm64 - # when: - # event: [ push, tag ] +depends_on: +- testing - # publish_linux_arm: - # image: plugins/docker:17.12 - # pull: true - # secrets: [ docker_username, docker_password ] - # group: docker - # repo: plugins/ansible - # auto_tag: true - # auto_tag_suffix: linux-arm - # dockerfile: Dockerfile.arm - # when: - # event: [ push, tag ] +--- +kind: pipeline +name: linux-arm64 - manifests: - image: plugins/manifest:1 - pull: true - secrets: [ docker_username, docker_password ] - spec: manifest.tmpl +platform: + os: linux + arch: arm64 + +steps: +- name: build + pull: always + image: golang:1.11 + commands: + - "go build -v -ldflags \"-X main.build=${DRONE_BUILD_NUMBER}\" -a -o release/linux/arm64/drone-ansible" + environment: + CGO_ENABLED: 0 + GO111MODULE: on + when: + event: + - push + - pull_request + +- name: build + pull: always + image: golang:1.11 + commands: + - "go build -v -ldflags \"-X main.version=${DRONE_TAG##v} -X main.build=${DRONE_BUILD_NUMBER}\" -a -o release/linux/arm64/drone-ansible" + environment: + CGO_ENABLED: 0 + GO111MODULE: on + when: + event: + - tag + +- name: dryrun + pull: always + image: plugins/docker:linux-arm64 + settings: + dockerfile: docker/Dockerfile.linux.arm64 + dry_run: true + password: + from_secret: docker_password + repo: plugins/ansible + tags: linux-arm64 + username: + from_secret: docker_username + when: + event: + - pull_request + +- name: publish + pull: always + image: plugins/docker:linux-arm64 + settings: auto_tag: true - ignore_missing: true - when: - event: [ push, tag ] + auto_tag_suffix: linux-arm64 + dockerfile: docker/Dockerfile.linux.arm64 + password: + from_secret: docker_password + repo: plugins/ansible + username: + from_secret: docker_username + when: + event: + - push + - tag - microbadger: - image: plugins/webhook:1 - pull: true - secrets: [ webhook_url ] - when: - status: [ success ] +trigger: + branch: + - master + +depends_on: +- testing + +--- +kind: pipeline +name: linux-arm + +platform: + os: linux + arch: arm + +steps: +- name: build + pull: always + image: golang:1.11 + commands: + - "go build -v -ldflags \"-X main.build=${DRONE_BUILD_NUMBER}\" -a -o release/linux/arm/drone-ansible" + environment: + CGO_ENABLED: 0 + GO111MODULE: on + when: + event: + - push + - pull_request + +- name: build + pull: always + image: golang:1.11 + commands: + - "go build -v -ldflags \"-X main.version=${DRONE_TAG##v} -X main.build=${DRONE_BUILD_NUMBER}\" -a -o release/linux/arm/drone-ansible" + environment: + CGO_ENABLED: 0 + GO111MODULE: on + when: + event: + - tag + +- name: dryrun + pull: always + image: plugins/docker:linux-arm + settings: + dockerfile: docker/Dockerfile.linux.arm + dry_run: true + password: + from_secret: docker_password + repo: plugins/ansible + tags: linux-arm + username: + from_secret: docker_username + when: + event: + - pull_request + +- name: publish + pull: always + image: plugins/docker:linux-arm + settings: + auto_tag: true + auto_tag_suffix: linux-arm + dockerfile: docker/Dockerfile.linux.arm + password: + from_secret: docker_password + repo: plugins/ansible + username: + from_secret: docker_username + when: + event: + - push + - tag + +trigger: + branch: + - master + +depends_on: +- testing + +--- +kind: pipeline +name: notifications + +platform: + os: linux + arch: amd64 + +steps: +- name: manifest + pull: always + image: plugins/manifest:1 + settings: + ignore_missing: true + password: + from_secret: docker_password + spec: docker/manifest.tmpl + username: + from_secret: docker_username + +- name: microbadger + pull: always + image: plugins/webhook:1 + settings: + url: + from_secret: microbadger_url + +trigger: + branch: + - master + event: + - push + - tag + +depends_on: +- linux-amd64 +- linux-arm64 +- linux-arm + +...