Skip to content

Commit

Permalink
Restructured multi arch and added auto tagging
Browse files Browse the repository at this point in the history
  • Loading branch information
tboerger committed Jan 23, 2018
1 parent 1c10f4c commit 28fa94f
Show file tree
Hide file tree
Showing 9 changed files with 176 additions and 77 deletions.
41 changes: 33 additions & 8 deletions .appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
version: '{build}'
image: 'Visual Studio 2017'
platform: x64

clone_folder: 'c:\go\src\github.com\drone-plugins\drone-webhook'
max_jobs: 1

environment:
DOCKER_USERNAME:
Expand All @@ -10,28 +12,51 @@ environment:
secure: 'VqO/G3Zfslu6zSLdwHKO+Q=='

install:
- cmd: |
- ps: |
docker version
go version
build_script:
- cmd: |
go build -v -ldflags "-X main.build=%APPVEYOR_BUILD_VERSION%"" -a -o drone-webhook.exe
- ps: |
if ( $env:APPVEYOR_REPO_TAG -eq 'false' ) {
go build -ldflags "-X main.build=$env:APPVEYOR_BUILD_VERSION" -a -o drone-webhook.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 drone-webhook.exe
}
docker pull microsoft/nanoserver:10.0.14393.1593
docker build -f Dockerfile.windows -t plugins/webhook:windows .
docker build -f Dockerfile.windows -t plugins/webhook:windows-amd64 .
test_script:
- cmd: |
docker run --rm plugins/webhook:windows --version
- ps: |
docker run --rm plugins/webhook:windows-amd64 --version
deploy_script:
- ps: |
$ErrorActionPreference = 'Stop';
if ( $env:APPVEYOR_PULL_REQUEST_NUMBER -Or ! $env:APPVEYOR_REPO_BRANCH.Equals("master")) {
if ( $env:APPVEYOR_PULL_REQUEST_NUMBER ) {
Write-Host Nothing to deploy.
} else {
docker login --username $env:DOCKER_USERNAME --password $env:DOCKER_PASSWORD
docker push plugins/webhook:windows
if ( $env:APPVEYOR_REPO_TAG -eq 'true' ) {
$major,$minor,$patch = $env:APPVEYOR_REPO_TAG_NAME.substring(1).split('.')
docker push plugins/webhook:windows
docker tag plugins/webhook:windows plugins/webhook:$major.$minor.$patch-windows
docker push plugins/webhook:$major.$minor.$patch-windows-amd64
docker tag plugins/webhook:windows plugins/webhook:$major.$minor-windows
docker push plugins/webhook:$major.$minor-windows-amd64
docker tag plugins/webhook:windows plugins/webhook:$major-windows
docker push plugins/webhook:$major-windows-amd64
} else {
if ( $env:APPVEYOR_REPO_BRANCH -eq 'master' ) {
docker push plugins/webhook:windows-amd64
}
}
}
113 changes: 74 additions & 39 deletions .drone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ pipeline:
pull: true
commands:
- go vet
- go test -cover -coverprofile=coverage.out
- |
for PKG in $(go list ./... | grep -v /vendor/); do
go test -cover -coverprofile $GOPATH/src/$PKG/coverage.out $PKG
done
build_linux_amd64:
image: golang:1.9
Expand All @@ -19,7 +22,28 @@ pipeline:
- GOARCH=amd64
- CGO_ENABLED=0
commands:
- go build -v -ldflags "-X main.build=${DRONE_BUILD_NUMBER}" -a -o release/linux/amd64/drone-webhook
- |
if test "${DRONE_TAG}" = ""; then
go build -v -ldflags "-X main.build=${DRONE_BUILD_NUMBER}" -a -o release/linux/amd64/drone-webhook
else
go build -v -ldflags "-X main.version=${DRONE_TAG##v} -X main.build=${DRONE_BUILD_NUMBER}" -a -o release/linux/amd64/drone-webhook
fi
build_linux_i386:
image: golang:1.9
pull: true
group: build
environment:
- GOOS=linux
- GOARCH=386
- CGO_ENABLED=0
commands:
- |
if test "${DRONE_TAG}" = ""; then
go build -v -ldflags "-X main.build=${DRONE_BUILD_NUMBER}" -a -o release/linux/i386/drone-webhook
else
go build -v -ldflags "-X main.version=${DRONE_TAG##v} -X main.build=${DRONE_BUILD_NUMBER}" -a -o release/linux/i386/drone-webhook
fi
build_linux_arm64:
image: golang:1.9
Expand All @@ -30,7 +54,12 @@ pipeline:
- GOARCH=arm64
- CGO_ENABLED=0
commands:
- go build -v -ldflags "-X main.build=${DRONE_BUILD_NUMBER}" -a -o release/linux/arm64/drone-webhook
- |
if test "${DRONE_TAG}" = ""; then
go build -v -ldflags "-X main.build=${DRONE_BUILD_NUMBER}" -a -o release/linux/arm64/drone-webhook
else
go build -v -ldflags "-X main.version=${DRONE_TAG##v} -X main.build=${DRONE_BUILD_NUMBER}" -a -o release/linux/arm64/drone-webhook
fi
build_linux_arm:
image: golang:1.9
Expand All @@ -42,68 +71,74 @@ pipeline:
- CGO_ENABLED=0
- GOARM=7
commands:
- go build -v -ldflags "-X main.build=${DRONE_BUILD_NUMBER}" -a -o release/linux/arm/drone-webhook

# build_windows_amd64:
# image: golang:1.9-nanoserver
# pull: true
# 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-webhook
else
go build -v -ldflags "-X main.version=${DRONE_TAG##v} -X main.build=${DRONE_BUILD_NUMBER}" -a -o release/linux/arm/drone-webhook
fi
publish_linux_amd64:
image: plugins/docker:17.05
pull: true
repo: plugins/webhook
tags: [ latest, 1.0.0, 1.0, 1 ]
secrets: [ docker_username, docker_password ]
group: docker
repo: plugins/webhook
auto_tag: true
auto_tag_suffix: linux-amd64
dockerfile: Dockerfile
when:
branch: master
event: push
event: [ push, tag ]

publish_linux_arm64:
publish_linux_i386:
image: plugins/docker:17.05
pull: true
secrets: [ docker_username, docker_password ]
group: docker
repo: plugins/webhook
tags: [ linux-arm64 ]
auto_tag: true
auto_tag_suffix: linux-i386
dockerfile: Dockerfile.i386
when:
event: [ push, tag ]

publish_linux_arm64:
image: plugins/docker:17.05
pull: true
secrets: [ docker_username, docker_password ]
group: docker
repo: plugins/webhook
auto_tag: true
auto_tag_suffix: linux-arm64
dockerfile: Dockerfile.arm64
when:
branch: master
event: push
event: [ push, tag ]

publish_linux_arm:
image: plugins/docker:17.05
pull: true
repo: plugins/webhook
tags: [ linux-arm ]
secrets: [ docker_username, docker_password ]
group: docker
repo: plugins/webhook
auto_tag: true
auto_tag_suffix: linux-arm
dockerfile: Dockerfile.arm
when:
branch: master
event: push
event: [ push, tag ]

# publish_windows_amd64:
# image: plugins/docker:17.05
# pull: true
# repo: plugins/webhook
# tags: [ windows-amd64 ]
# secrets: [ docker_username, docker_password ]
# dockerfile: Dockerfile.windows
# when:
# branch: master
# event: push
manifests:
image: plugins/manifest:1
pull: true
secrets: [ docker_username, docker_password ]
spec: manifest.tmpl
auto_tag: true
ignore_missing: true
when:
event: [ push, tag ]

microbadger:
image: plugins/webhook:1
pull: true
secrets: [ webhook_url ]
when:
branch: master
event: push
status: [ success ]
10 changes: 4 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
FROM plugins/base:multiarch
MAINTAINER Drone.IO Community <drone-dev@googlegroups.com>

LABEL org.label-schema.version=latest
LABEL org.label-schema.vcs-url="https://github.com/drone-plugins/drone-webhook.git"
LABEL org.label-schema.name="Drone Webhook"
LABEL org.label-schema.vendor="Drone.IO Community"
LABEL org.label-schema.schema-version="1.0"
LABEL maintainer="Drone.IO Community <drone-dev@googlegroups.com>" \
org.label-schema.name="Drone Webhook" \
org.label-schema.vendor="Drone.IO Community" \
org.label-schema.schema-version="1.0"

ADD release/linux/amd64/drone-webhook /bin/
ENTRYPOINT ["/bin/drone-webhook"]
10 changes: 4 additions & 6 deletions Dockerfile.arm
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
FROM plugins/base:multiarch
MAINTAINER Drone.IO Community <drone-dev@googlegroups.com>

LABEL org.label-schema.version=latest
LABEL org.label-schema.vcs-url="https://github.com/drone-plugins/drone-webhook.git"
LABEL org.label-schema.name="Drone Webhook"
LABEL org.label-schema.vendor="Drone.IO Community"
LABEL org.label-schema.schema-version="1.0"
LABEL maintainer="Drone.IO Community <drone-dev@googlegroups.com>" \
org.label-schema.name="Drone Webhook" \
org.label-schema.vendor="Drone.IO Community" \
org.label-schema.schema-version="1.0"

ADD release/linux/arm/drone-webhook /bin/
ENTRYPOINT ["/bin/drone-webhook"]
10 changes: 4 additions & 6 deletions Dockerfile.arm64
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
FROM plugins/base:multiarch
MAINTAINER Drone.IO Community <drone-dev@googlegroups.com>

LABEL org.label-schema.version=latest
LABEL org.label-schema.vcs-url="https://github.com/drone-plugins/drone-webhook.git"
LABEL org.label-schema.name="Drone Webhook"
LABEL org.label-schema.vendor="Drone.IO Community"
LABEL org.label-schema.schema-version="1.0"
LABEL maintainer="Drone.IO Community <drone-dev@googlegroups.com>" \
org.label-schema.name="Drone Webhook" \
org.label-schema.vendor="Drone.IO Community" \
org.label-schema.schema-version="1.0"

ADD release/linux/arm64/drone-webhook /bin/
ENTRYPOINT ["/bin/drone-webhook"]
9 changes: 9 additions & 0 deletions Dockerfile.i386
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM plugins/base:multiarch

LABEL maintainer="Drone.IO Community <drone-dev@googlegroups.com>" \
org.label-schema.name="Drone Webhook" \
org.label-schema.vendor="Drone.IO Community" \
org.label-schema.schema-version="1.0"

ADD release/linux/i386/drone-webhook /bin/
ENTRYPOINT ["/bin/drone-webhook"]
15 changes: 7 additions & 8 deletions Dockerfile.windows
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
# escape=`
FROM microsoft/nanoserver:10.0.14393.1593
MAINTAINER Drone.IO Community <drone-dev@googlegroups.com>

LABEL org.label-schema.version=latest
LABEL org.label-schema.vcs-url="https://github.com/drone-plugins/drone-webhook.git"
LABEL org.label-schema.name="Drone Webhook"
LABEL org.label-schema.vendor="Drone.IO Community"
LABEL org.label-schema.schema-version="1.0"
LABEL maintainer="Drone.IO Community <drone-dev@googlegroups.com>" `
org.label-schema.name="Drone Webhook" `
org.label-schema.vendor="Drone.IO Community" `
org.label-schema.schema-version="1.0"

ADD drone-webhook.exe /drone-webhook.exe
ENTRYPOINT [ "\\drone-webhook.exe" ]
ADD drone-webhook.exe c:\drone-webhook.exe
ENTRYPOINT [ "c:\\drone-webhook.exe" ]
12 changes: 8 additions & 4 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,23 @@ package main

import (
"fmt"
"github.com/urfave/cli"
"log"
"os"

"github.com/urfave/cli"
)

var build = "0" // build number set at compile-time
var (
version = "0.0.0"
build = "0"
)

func main() {
app := cli.NewApp()
app.Name = "webhook plugin"
app.Usage = "webhook plugin"
app.Action = run
app.Version = fmt.Sprintf("1.0.0+%s", build)
app.Version = fmt.Sprintf("%s+%s", version, build)
app.Flags = []cli.Flag{
cli.StringFlag{
Name: "method",
Expand Down Expand Up @@ -51,7 +55,7 @@ func main() {
cli.StringSliceFlag{
Name: "urls",
Usage: "list of urls to perform the action on",
EnvVar: "PLUGIN_URLS",
EnvVar: "PLUGIN_URLS,WEBHOOK_URLS",
},
cli.BoolFlag{
Name: "debug",
Expand Down
33 changes: 33 additions & 0 deletions manifest.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
image: plugins/webhook:{{#if build.tag}}{{trimPrefix build.tag "v"}}{{else}}latest{{/if}}
{{#if build.tags}}
tags:
{{#each build.tags}}
- {{this}}
{{/each}}
{{/if}}
manifests:
-
image: plugins/webhook:{{#if build.tag}}{{trimPrefix build.tag "v"}}-{{/if}}linux-amd64
platform:
architecture: amd64
os: linux
-
image: plugins/webhook:{{#if build.tag}}{{trimPrefix build.tag "v"}}-{{/if}}linux-i386
platform:
architecture: 386
os: linux
-
image: plugins/webhook:{{#if build.tag}}{{trimPrefix build.tag "v"}}-{{/if}}linux-arm64
platform:
architecture: arm64
os: linux
-
image: plugins/webhook:{{#if build.tag}}{{trimPrefix build.tag "v"}}-{{/if}}linux-arm
platform:
architecture: arm
os: linux
-
image: plugins/webhook:{{#if build.tag}}{{trimPrefix build.tag "v"}}-{{/if}}windows-amd64
platform:
architecture: amd64
os: windows

0 comments on commit 28fa94f

Please sign in to comment.