feat(drone): Upgrade and switch to Drone 1.0.0 (#14)

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
This commit is contained in:
Bo-Yi Wu
2019-01-21 11:34:24 +08:00
committed by GitHub
parent 17511f0979
commit 10e83daa59
11 changed files with 541 additions and 242 deletions
-65
View File
@@ -1,65 +0,0 @@
version: '{build}'
image: 'Visual Studio 2017'
platform: x64
clone_folder: 'c:\go\src\github.com\appleboy\drone-discord'
max_jobs: 1
environment:
GOPATH: c:\go
docker_username:
secure: em/TNLUXxG19O/HvbvfJuQ==
docker_password:
secure: Yo9FJJqihaNz5q8T4Jz8tQ==
branches:
only:
- master
install:
- ps: |
docker version
go version
- ps: |
$env:Path = "c:\go\bin;$env:Path"
build_script:
- ps: |
if ( $env:APPVEYOR_REPO_TAG -eq 'false' ) {
go build -ldflags "-X main.Version=$env:APPVEYOR_REPO_COMMIT -X main.BuildNum=$env:APPVEYOR_BUILD_VERSION" -a -o release/drone-discord.exe
} else {
$version = $env:APPVEYOR_REPO_TAG_NAME
go build -ldflags "-X main.Version=$version -X main.BuildNum=$env:APPVEYOR_BUILD_VERSION" -a -o release/drone-discord.exe
}
docker pull microsoft/nanoserver:10.0.14393.1884
docker build -f Dockerfile.windows -t appleboy/drone-discord:windows-amd64 .
test_script:
- ps: |
docker run --rm appleboy/drone-discord: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.split('.')
docker push appleboy/drone-discord:windows-amd64
docker tag appleboy/drone-discord:windows-amd64 appleboy/drone-discord:$major.$minor.$patch-windows-amd64
docker push appleboy/drone-discord:$major.$minor.$patch-windows-amd64
docker tag appleboy/drone-discord:windows-amd64 appleboy/drone-discord:$major.$minor-windows-amd64
docker push appleboy/drone-discord:$major.$minor-windows-amd64
docker tag appleboy/drone-discord:windows-amd64 appleboy/drone-discord:$major-windows-amd64
docker push appleboy/drone-discord:$major-windows-amd64
} else {
if ( $env:APPVEYOR_REPO_BRANCH -eq 'master' ) {
docker push appleboy/drone-discord:windows-amd64
}
}
}
+183
View File
@@ -0,0 +1,183 @@
local PipelineTesting = {
kind: "pipeline",
name: "testing",
platform: {
os: "linux",
arch: "amd64",
},
steps: [
{
name: "vet",
image: "golang:1.11",
pull: "always",
environment: {
GO111MODULE: "on",
},
commands: [
"make vet",
],
},
{
name: "lint",
image: "golang:1.11",
pull: "always",
environment: {
GO111MODULE: "on",
},
commands: [
"make lint",
],
},
{
name: "misspell",
image: "golang:1.11",
pull: "always",
environment: {
GO111MODULE: "on",
},
commands: [
"make misspell-check",
],
},
{
name: "test",
image: "golang:1.11",
pull: "always",
environment: {
GO111MODULE: "on",
WEBHOOK_ID: { "from_secret": "webhook_id" },
WEBHOOK_TOKEN: { "from_secret": "webhook_token" },
},
commands: [
"make test",
"make coverage",
],
},
{
name: "codecov",
image: "robertstettner/drone-codecov",
pull: "always",
settings: {
token: { "from_secret": "codecov_token" },
},
},
],
trigger: {
branch: [ "master" ],
},
};
local PipelineBuild(os="linux", arch="amd64") = {
kind: "pipeline",
name: os + "-" + arch,
platform: {
os: os,
arch: arch,
},
steps: [
{
name: "build-push",
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-discord",
],
when: {
event: [ "push", "pull_request" ],
},
},
{
name: "build-tag",
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-discord",
],
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: "appleboy/drone-discord",
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: "appleboy/drone-discord",
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: "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,
]
+70
View File
@@ -0,0 +1,70 @@
---
kind: pipeline
name: windows-amd64
platform:
os: windows
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/windows/amd64/drone-webhook'
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/windows/amd64/drone-webhook'
environment:
CGO_ENABLED: 0
GO111MODULE: on
when:
event:
- tag
- name: dryrun
pull: always
image: plugins/docker:windows-amd64
settings:
dockerfile: docker/Dockerfile.windows.amd64
dry_run: true
password:
from_secret: docker_password
repo: appleboy/drone-discord
tags: windows-amd64
username:
from_secret: docker_username
when:
event:
- pull_request
- name: publish
pull: always
image: plugins/docker:windows-amd64
settings:
auto_tag: true
auto_tag_suffix: windows-amd64
dockerfile: docker/Dockerfile.windows.amd64
password:
from_secret: docker_password
repo: appleboy/drone-discord
username:
from_secret: docker_username
when:
event:
- push
- tag
trigger:
branch:
- master
+286 -152
View File
@@ -1,174 +1,308 @@
workspace:
base: /go/src
path: github.com/appleboy/drone-discord
---
kind: pipeline
name: testing
clone:
git:
image: plugins/git
depth: 50
tags: true
platform:
os: linux
arch: amd64
pipeline:
lint:
image: golang:1.11
pull: true
group: golang
environment:
- GO111MODULE=on
commands:
- make vet
- make lint
- make misspell-check
steps:
- name: vet
pull: always
image: golang:1.11
commands:
- make vet
environment:
GO111MODULE: on
test:
image: golang:1.11
pull: true
group: golang
secrets: [ webhook_id, webhook_token ]
environment:
- GO111MODULE=on
commands:
- make test
- make coverage
- name: lint
pull: always
image: golang:1.11
commands:
- make lint
environment:
GO111MODULE: on
build_linux_amd64:
image: golang:1.11
pull: true
group: build
environment:
- GO111MODULE=on
commands:
- make build_linux_amd64
- name: misspell
pull: always
image: golang:1.11
commands:
- make misspell-check
environment:
GO111MODULE: on
build_linux_i386:
image: golang:1.11
pull: true
group: build
environment:
- GO111MODULE=on
commands:
- make build_linux_i386
- name: test
pull: always
image: golang:1.11
commands:
- make test
- make coverage
environment:
GO111MODULE: on
WEBHOOK_ID:
from_secret: webhook_id
WEBHOOK_TOKEN:
from_secret: webhook_token
build_linux_arm64:
image: golang:1.11
pull: true
group: build
environment:
- GO111MODULE=on
commands:
- make build_linux_arm64
- name: codecov
pull: always
image: robertstettner/drone-codecov
settings:
token:
from_secret: codecov_token
build_linux_arm:
image: golang:1.11
pull: true
group: build
environment:
- GO111MODULE=on
commands:
- make build_linux_arm
trigger:
branch:
- master
codecov:
image: robertstettner/drone-codecov
secrets: [ codecov_token ]
when:
event: [ push, pull_request ]
status: [ success ]
---
kind: pipeline
name: linux-amd64
release:
image: golang:1.11
pull: true
commands:
- make release
when:
event: [ tag ]
branch: [ refs/tags/* ]
platform:
os: linux
arch: amd64
publish_linux_amd64:
image: plugins/docker:17.12
group: release
pull: true
repo: ${DRONE_REPO}
secrets: [ docker_username, docker_password ]
steps:
- name: build-push
pull: always
image: golang:1.11
commands:
- "go build -v -ldflags \"-X main.build=${DRONE_BUILD_NUMBER}\" -a -o release/linux/amd64/drone-discord"
environment:
CGO_ENABLED: 0
GO111MODULE: on
when:
event:
- push
- pull_request
- name: build-tag
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-discord"
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: appleboy/drone-discord
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
when:
event: [ push, tag ]
local: false
dockerfile: docker/Dockerfile.linux.amd64
password:
from_secret: docker_password
repo: appleboy/drone-discord
username:
from_secret: docker_username
when:
event:
- push
- tag
publish_alpine:
image: plugins/docker:17.12
group: release
pull: true
dockerfile: Dockerfile.alpine
secrets: [ docker_username, docker_password ]
auto_tag: true
auto_tag_suffix: linux-alpine
repo: ${DRONE_REPO}
when:
event: [ push, tag ]
local: false
trigger:
branch:
- master
publish_linux_i386:
image: plugins/docker:17.12
pull: true
secrets: [ docker_username, docker_password ]
group: release
repo: ${DRONE_REPO}
auto_tag: true
auto_tag_suffix: linux-i386
dockerfile: Dockerfile.i386
when:
event: [ push, tag ]
local: false
depends_on:
- testing
publish_linux_arm64:
image: plugins/docker:17.12
pull: true
secrets: [ docker_username, docker_password ]
group: release
repo: ${DRONE_REPO}
---
kind: pipeline
name: linux-arm64
platform:
os: linux
arch: arm64
steps:
- name: build-push
pull: always
image: golang:1.11
commands:
- "go build -v -ldflags \"-X main.build=${DRONE_BUILD_NUMBER}\" -a -o release/linux/arm64/drone-discord"
environment:
CGO_ENABLED: 0
GO111MODULE: on
when:
event:
- push
- pull_request
- name: build-tag
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-discord"
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: appleboy/drone-discord
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
auto_tag_suffix: linux-arm64
dockerfile: Dockerfile.arm64
when:
event: [ push, tag ]
local: false
dockerfile: docker/Dockerfile.linux.arm64
password:
from_secret: docker_password
repo: appleboy/drone-discord
username:
from_secret: docker_username
when:
event:
- push
- tag
publish_linux_arm:
image: plugins/docker:17.12
pull: true
secrets: [ docker_username, docker_password ]
group: release
repo: ${DRONE_REPO}
trigger:
branch:
- master
depends_on:
- testing
---
kind: pipeline
name: linux-arm
platform:
os: linux
arch: arm
steps:
- name: build-push
pull: always
image: golang:1.11
commands:
- "go build -v -ldflags \"-X main.build=${DRONE_BUILD_NUMBER}\" -a -o release/linux/arm/drone-discord"
environment:
CGO_ENABLED: 0
GO111MODULE: on
when:
event:
- push
- pull_request
- name: build-tag
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-discord"
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: appleboy/drone-discord
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: Dockerfile.arm
when:
event: [ push, tag ]
local: false
dockerfile: docker/Dockerfile.linux.arm
password:
from_secret: docker_password
repo: appleboy/drone-discord
username:
from_secret: docker_username
when:
event:
- push
- tag
github:
image: plugins/github-release
secrets: [ github_release_api_key ]
files:
- dist/release/*
when:
event: [ tag ]
branch: [ refs/tags/* ]
trigger:
branch:
- master
discord:
image: appleboy/drone-discord
pull: true
secrets:
- source: webhook_prod_id
target: webhook_id
- source: webhook_prod_token
target: webhook_token
message: >
{{#success build.status}}
build {{build.number}} succeeded. Good job.
{{else}}
build {{build.number}} failed. Fix me please.
{{/success}}
when:
status: [ success, failure ]
depends_on:
- testing
---
kind: pipeline
name: notifications
platform:
os: linux
arch: amd64
steps:
- 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
...
-13
View File
@@ -1,13 +0,0 @@
FROM alpine:3.8
LABEL maintainer="Bo-Yi Wu <appleboy.tw@gmail.com>" \
org.label-schema.name="Drone Discord" \
org.label-schema.vendor="Bo-Yi Wu" \
org.label-schema.schema-version="1.0"
RUN apk add -U --no-cache ca-certificates && \
rm -rf /var/cache/apk/*
ADD release/linux/amd64/drone-discord /bin/
ENTRYPOINT ["/bin/drone-discord"]
-10
View File
@@ -1,10 +0,0 @@
FROM plugins/base:multiarch
LABEL maintainer="Bo-Yi Wu <appleboy.tw@gmail.com>" \
org.label-schema.name="Drone Discord" \
org.label-schema.vendor="Bo-Yi Wu" \
org.label-schema.schema-version="1.0"
ADD release/linux/i386/drone-discord /bin/
ENTRYPOINT ["/bin/drone-discord"]
+1 -1
View File
@@ -77,7 +77,7 @@ fmt-check:
fi;
test: fmt-check
for PKG in $(PACKAGES); do $(GO) test -v -cover -coverprofile $$GOPATH/src/$$PKG/coverage.txt $$PKG || exit 1; done;
$(GO) test -v -cover -coverprofile coverage.txt ./... || exit 1
html:
$(GO) tool cover -html=coverage.txt
@@ -1,4 +1,4 @@
FROM microsoft/nanoserver:10.0.14393.1884
FROM plugins/base:windows-amd64
LABEL maintainer="Bo-Yi Wu <appleboy.tw@gmail.com>" \
org.label-schema.name="Drone Discord" \