Restructuring of build process

This commit is contained in:
Thomas Boerger 2017-08-28 23:31:49 +02:00
parent 7f3e6154e8
commit cb0080349d
No known key found for this signature in database
GPG Key ID: 5A388F55283960B6
15 changed files with 164 additions and 236 deletions

2
.dockerignore Normal file
View File

@ -0,0 +1,2 @@
*
!release/

View File

@ -1,33 +1,96 @@
workspace:
path: src/github.com/drone-plugins/drone-s3-sync
base: /go
path: src/github.com/drone-plugins/drone-s3-sync
pipeline:
test:
image: golang:1.6
environment:
- CGO_ENABLED=0
image: golang:1.9
commands:
- go vet
- go test -cover -coverprofile=coverage.out
- go build -ldflags "-s -w -X main.build=$DRONE_BUILD_NUMBER" -a -tags netgo
publish:
build_linux_amd64:
image: golang:1.9
group: build
environment:
- GOOS=linux
- GOARCH=amd64
- CGO_ENABLED=0
commands:
- go build -v -ldflags "-X main.build=${DRONE_BUILD_NUMBER}" -a -tags netgo -o release/linux/amd64/drone-s3-sync
build_linux_arm64:
image: golang:1.9
group: build
environment:
- GOOS=linux
- GOARCH=arm64
- CGO_ENABLED=0
commands:
- go build -v -ldflags "-X main.build=${DRONE_BUILD_NUMBER}" -a -tags netgo -o release/linux/arm64/drone-s3-sync
build_linux_arm:
image: golang:1.9
group: build
environment:
- GOOS=linux
- GOARCH=arm
- CGO_ENABLED=0
- GOARM=7
commands:
- go build -v -ldflags "-X main.build=${DRONE_BUILD_NUMBER}" -a -tags netgo -o release/linux/arm/drone-s3-sync
# 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 -tags netgo -o release/windows/amd64/drone-s3-sync
publish_linux_amd64:
image: plugins/docker
repo: plugins/s3-sync
tags: [ "latest", "1.1", "1" ]
tags: [ latest, 1.1.0, 1.1, 1 ]
secrets: [ docker_username, docker_password ]
when:
branch: master
event: push
plugin:
name: S3 Sync
desc: Sync a directory with an Amazon S3 Bucket
type: publish
image: plugins/s3-sync
labels:
- publish
- artifacts
- amazon
- aws
- s3
publish_linux_arm64:
image: plugins/docker
repo: plugins/s3-sync
tags: [ linux-arm64 ]
secrets: [ docker_username, docker_password ]
dockerfile: Dockerfile.arm64
when:
branch: master
event: push
publish_linux_arm:
image: plugins/docker
repo: plugins/s3-sync
tags: [ linux-arm ]
secrets: [ docker_username, docker_password ]
dockerfile: Dockerfile.arm
when:
branch: master
event: push
# publish_windows_amd64:
# image: plugins/docker
# repo: plugins/s3-sync
# tags: [ windows-amd64 ]
# secrets: [ docker_username, docker_password ]
# dockerfile: Dockerfile.windows
# when:
# branch: master
# event: push
# microbadger:
# image: plugins/webhook
# secrets: [ webhook_url ]
# when:
# status: [ success ]

View File

@ -1 +0,0 @@
eyJhbGciOiJIUzI1NiJ9.d29ya3NwYWNlOgogIHBhdGg6IHNyYy9naXRodWIuY29tL2Ryb25lLXBsdWdpbnMvZHJvbmUtczMtc3luYwogIGJhc2U6IC9nbwoKcGlwZWxpbmU6CiAgdGVzdDoKICAgIGltYWdlOiBnb2xhbmc6MS42CiAgICBlbnZpcm9ubWVudDoKICAgICAgLSBDR09fRU5BQkxFRD0wCiAgICBjb21tYW5kczoKICAgICAgLSBnbyB2ZXQKICAgICAgLSBnbyB0ZXN0IC1jb3ZlciAtY292ZXJwcm9maWxlPWNvdmVyYWdlLm91dAogICAgICAtIGdvIGJ1aWxkIC1sZGZsYWdzICItcyAtdyAtWCBtYWluLmJ1aWxkPSREUk9ORV9CVUlMRF9OVU1CRVIiIC1hIC10YWdzIG5ldGdvCgogIHB1Ymxpc2g6CiAgICBpbWFnZTogcGx1Z2lucy9kb2NrZXIKICAgIHJlcG86IHBsdWdpbnMvczMtc3luYwogICAgdGFnczogWyAibGF0ZXN0IiwgIjEuMSIsICIxIiBdCiAgICB3aGVuOgogICAgICBicmFuY2g6IG1hc3RlcgogICAgICBldmVudDogcHVzaAoKcGx1Z2luOgogIG5hbWU6IFMzIFN5bmMKICBkZXNjOiBTeW5jIGEgZGlyZWN0b3J5IHdpdGggYW4gQW1hem9uIFMzIEJ1Y2tldAogIHR5cGU6IHB1Ymxpc2gKICBpbWFnZTogcGx1Z2lucy9zMy1zeW5jCiAgbGFiZWxzOgogICAgLSBwdWJsaXNoCiAgICAtIGFydGlmYWN0cwogICAgLSBhbWF6b24KICAgIC0gYXdzCiAgICAtIHMzCg.qiRFZIEl1LP7LkwrOqCFdIG4-NZ4QQt9ivotWUCxxiQ

3
.gitignore vendored
View File

@ -24,5 +24,6 @@ _testmain.go
*.prof
.env
release/*
coverage.out
drone-s3-sync
drone-s3-sync

119
DOCS.md
View File

@ -1,119 +0,0 @@
Use the S3 sync plugin to synchronize files and folders with an Amazon S3 bucket. The following parameters are used to configure this plugin:
* `access_key` - amazon key
* `secret_key` - amazon secret key
* `bucket` - bucket name
* `region` - bucket region (`us-east-1`, `eu-west-1`, etc)
* `acl` - access to files that are uploaded (`private`, `public-read`, etc)
* `source` - location of folder to sync
* `target` - target folder in your S3 bucket
* `delete` - deletes files in the target not found in the source
* `content_type` - override default mime-types to use this value
* `content_encoding` - override default content encoding header for files
* `cache_control` - override default cache control header for files
* `metadata` - set custom metadata
* `redirects` - targets that should redirect elsewhere
* `cloudfront_distribution_id` - (optional) the cloudfront distribution id to invalidate after syncing
The following is a sample S3 configuration in your .drone.yml file:
```yaml
publish:
s3_sync:
acl: public-read
region: "us-east-1"
bucket: "my-bucket.s3-website-us-east-1.amazonaws.com"
access_key: "970d28f4dd477bc184fbd10b376de753"
secret_key: "9c5785d3ece6a9cdefa42eb99b58986f9095ff1c"
source: folder/to/archive
target: /target/location
delete: true
cloudfront_distribution_id: "9c5785d3ece6a9cdefa4"
```
The `acl`, `content_type`, `cache_control`, and `content_encoding` parameters can be passed as a string value to apply to all files, or as a map to apply to a subset of files.
For example:
```yaml
publish:
s3_sync:
acl:
"public/*": public-read
"private/*": private
content_type:
".svg": image/svg+xml
content_encoding:
".js": gzip
".css": gzip
cache_control: "public, max-age: 31536000"
region: "us-east-1"
bucket: "my-bucket.s3-website-us-east-1.amazonaws.com"
access_key: "970d28f4dd477bc184fbd10b376de753"
secret_key: "9c5785d3ece6a9cdefa42eb99b58986f9095ff1c"
source: folder/to/archive
target: /target/location
delete: true
```
In the case of `acl` the key of the map is a glob. If there are no matches in your settings for a given file, the default is `"private"`.
The `content_type` field the key is an extension including the leading dot `.`. If you want to set a content type for files with no extension, set the key to the empty string `""`. If there are no matches for the `content_type` of any file, one will automatically be determined for you.
In the `content_encoding` field the key is an extension including the leading dot `.`. If you want to set a encoding type for files with no extension, set the key
to th empty string `""`. If there are no matches for the `content_encoding` of a file, no content-encoding header will be added.
In the `cache_control` field the key is an extension including the leading dot `.`. If you want to set cache control for files with no extension, set the key
to the empty string `""`. If there are no matches for the `cache_control` of a file, no cache-control header will be added.
The `metadata` field can be set as either an object where the keys are the metadata headers:
```yaml
publish:
s3_sync:
acl: public-read
region: "us-east-1"
bucket: "my-bucket.s3-website-us-east-1.amazonaws.com"
access_key: "970d28f4dd477bc184fbd10b376de753"
secret_key: "9c5785d3ece6a9cdefa42eb99b58986f9095ff1c"
source: folder/to/archive
target: /target/location
delete: true
metadata:
custom-meta: "abc123"
```
Or you can specify metadata for file patterns by using a glob:
```yaml
publish:
s3_sync:
acl: public-read
region: "us-east-1"
bucket: "my-bucket.s3-website-us-east-1.amazonaws.com"
access_key: "970d28f4dd477bc184fbd10b376de753"
secret_key: "9c5785d3ece6a9cdefa42eb99b58986f9095ff1c"
source: folder/to/archive
target: /target/location
delete: true
metadata:
"*.png":
CustomMeta: "abc123"
```
Additionally, you can specify redirect targets for files that don't exist by using the `redirects` key:
```yaml
publish:
s3_sync:
acl: public-read
region: "us-east-1"
bucket: "my-bucket.s3-website-us-east-1.amazonaws.com"
access_key: "970d28f4dd477bc184fbd10b376de753"
secret_key: "9c5785d3ece6a9cdefa42eb99b58986f9095ff1c"
source: folder/to/archive
target: /target/location
delete: true
redirects:
some/missing/file: /somewhere/that/actually/exists
```

View File

@ -1,10 +1,19 @@
FROM alpine:3.4
FROM alpine:3.6 as alpine
RUN apk add -U --no-cache ca-certificates mailcap
RUN apk update && \
apk add \
ca-certificates \
mailcap && \
rm -rf /var/cache/apk/*
FROM scratch
MAINTAINER Drone.IO Community <drone-dev@googlegroups.com>
ADD drone-s3-sync /bin/
ENTRYPOINT ["/bin/drone-s3-sync"]
ENV GODEBUG=netdns=go
COPY --from=alpine /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
COPY --from=alpine /etc/mime.types /etc/
LABEL org.label-schema.version=latest
LABEL org.label-schema.vcs-url="https://github.com/drone-plugins/drone-s3-sync.git"
LABEL org.label-schema.name="Drone S3 Sync"
LABEL org.label-schema.vendor="Drone.IO Community"
LABEL org.label-schema.schema-version="1.0"
ADD release/linux/amd64/drone-s3-sync /bin/
ENTRYPOINT [ "/bin/drone-s3-sync" ]

19
Dockerfile.arm Normal file
View File

@ -0,0 +1,19 @@
FROM alpine:3.6 as alpine
RUN apk add -U --no-cache ca-certificates mailcap
FROM scratch
MAINTAINER Drone.IO Community <drone-dev@googlegroups.com>
ENV GODEBUG=netdns=go
COPY --from=alpine /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
COPY --from=alpine /etc/mime.types /etc/
LABEL org.label-schema.version=latest
LABEL org.label-schema.vcs-url="https://github.com/drone-plugins/drone-s3-sync.git"
LABEL org.label-schema.name="Drone S3 Sync"
LABEL org.label-schema.vendor="Drone.IO Community"
LABEL org.label-schema.schema-version="1.0"
ADD release/linux/arm/drone-s3-sync /bin/
ENTRYPOINT [ "/bin/drone-s3-sync" ]

19
Dockerfile.arm64 Normal file
View File

@ -0,0 +1,19 @@
FROM alpine:3.6 as alpine
RUN apk add -U --no-cache ca-certificates mailcap
FROM scratch
MAINTAINER Drone.IO Community <drone-dev@googlegroups.com>
ENV GODEBUG=netdns=go
COPY --from=alpine /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
COPY --from=alpine /etc/mime.types /etc/
LABEL org.label-schema.version=latest
LABEL org.label-schema.vcs-url="https://github.com/drone-plugins/drone-s3-sync.git"
LABEL org.label-schema.name="Drone S3 Sync"
LABEL org.label-schema.vendor="Drone.IO Community"
LABEL org.label-schema.schema-version="1.0"
ADD release/linux/arm64/drone-s3-sync /bin/
ENTRYPOINT [ "/bin/drone-s3-sync" ]

View File

@ -1,10 +0,0 @@
FROM armhfbuild/alpine:3.4
RUN apk update && \
apk add \
ca-certificates \
mailcap && \
rm -rf /var/cache/apk/*
ADD drone-s3-sync /bin/
ENTRYPOINT ["/bin/drone-s3-sync"]

13
Dockerfile.windows Normal file
View File

@ -0,0 +1,13 @@
FROM microsoft/nanoserver:latest
MAINTAINER Drone.IO Community <drone-dev@googlegroups.com>
ENV GODEBUG=netdns=go
LABEL org.label-schema.version=latest
LABEL org.label-schema.vcs-url="https://github.com/drone-plugins/drone-s3-sync.git"
LABEL org.label-schema.name="Drone S3 Sync"
LABEL org.label-schema.vendor="Drone.IO Community"
LABEL org.label-schema.schema-version="1.0"
ADD release/windows/amd64/drone-s3-sync /bin/
ENTRYPOINT [ "/bin/drone-s3-sync" ]

View File

@ -1,46 +0,0 @@
[people]
[people.bradrydzewski]
name = "Brad Rydzewski"
email = "brad@drone.io"
login = "bradrydzewski"
[people.Bugagazavr]
name = "Kirill"
email = ""
login = "Bugagazavr"
[people.donny-dont]
name = "Don Olmstead"
email = "donny-dont@gmail.com"
login = "donny-dont"
[people.jackspirou]
name = "Jack Spirou"
email = ""
login = "jackspirou"
[people.msteinert]
name = "Mike Steinert"
email = ""
login = "msteinert"
[people.nlf]
name = "Nathan LaFreniere"
email = ""
login = "nlf"
[people.tboerger]
name = "Thomas Boerger"
email = "thomas@webhippie.de"
login = "tboerger"
[people.athieriot]
name = "Aurélien Thieriot"
email = "a.thieriot@gmail.com"
login = "athieriot"
[org]
[org.core]
people = [
"bradrydzewski",
"Bugagazavr",
"donny-dont",
"jackspirou",
"msteinert",
"nlf",
"tboerger",
"athieriot"
]

View File

@ -1,10 +1,12 @@
# drone-s3-sync
[![Build Status](http://beta.drone.io/api/badges/drone-plugins/drone-s3-sync/status.svg)](http://beta.drone.io/drone-plugins/drone-s3-sync)
[![Join the chat at https://gitter.im/drone/drone](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/drone/drone)
[![Go Doc](https://godoc.org/github.com/drone-plugins/drone-s3-sync?status.svg)](http://godoc.org/github.com/drone-plugins/drone-s3-sync)
[![Go Report](https://goreportcard.com/badge/github.com/drone-plugins/drone-s3-sync)](https://goreportcard.com/report/github.com/drone-plugins/drone-s3-sync)
[![](https://images.microbadger.com/badges/image/plugins/s3-sync.svg)](https://microbadger.com/images/plugins/s3-sync "Get your own image badge on microbadger.com")
Drone plugin to synchronize a directory with an Amazon S3 Bucket. For the
usage information and a listing of the available options please take a look at
[the docs](DOCS.md).
Drone plugin to synchronize a directory with an Amazon S3 Bucket. For the usage information and a listing of the available options please take a look at [the docs](http://plugins.drone.io/drone-plugins/drone-s3-sync/).
## Build
@ -12,7 +14,6 @@ Build the binary with the following commands:
```
go build
go test
```
## Docker
@ -20,16 +21,8 @@ go test
Build the Docker image with the following commands:
```
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -tags netgo
docker build --rm=true -t plugins/s3-sync .
```
Please note incorrectly building the image for the correct x64 linux and with
CGO disabled will result in an error when running the Docker image:
```
docker: Error response from daemon: Container command
'/bin/drone-s3-sync' not found or does not exist..
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -a -tags netgo -o release/linux/amd64/drone-s3-sync
docker build --rm -t plugins/s3-sync .
```
## Usage

View File

@ -1,17 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg width="256px" height="310px" viewBox="0 0 256 310" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" preserveAspectRatio="xMidYMid">
<g>
<path d="M20.624,53.686 L0,64 L0,245.02 L20.624,255.274 L20.748,255.125 L20.748,53.828 L20.624,53.686" fill="#8C3123"></path>
<path d="M131,229 L20.624,255.274 L20.624,53.686 L131,79.387 L131,229" fill="#E05243"></path>
<path d="M81.178,187.866 L127.996,193.826 L128.29,193.148 L128.553,116.378 L127.996,115.778 L81.178,121.652 L81.178,187.866" fill="#8C3123"></path>
<path d="M127.996,229.295 L235.367,255.33 L235.536,255.061 L235.533,53.866 L235.363,53.686 L127.996,79.682 L127.996,229.295" fill="#8C3123"></path>
<path d="M174.827,187.866 L127.996,193.826 L127.996,115.778 L174.827,121.652 L174.827,187.866" fill="#E05243"></path>
<path d="M174.827,89.631 L127.996,98.166 L81.178,89.631 L127.937,77.375 L174.827,89.631" fill="#5E1F18"></path>
<path d="M174.827,219.801 L127.996,211.21 L81.178,219.801 L127.939,232.854 L174.827,219.801" fill="#F2B0A9"></path>
<path d="M81.178,89.631 L127.996,78.045 L128.375,77.928 L128.375,0.313 L127.996,0 L81.178,23.413 L81.178,89.631" fill="#8C3123"></path>
<path d="M174.827,89.631 L127.996,78.045 L127.996,0 L174.827,23.413 L174.827,89.631" fill="#E05243"></path>
<path d="M127.996,309.428 L81.173,286.023 L81.173,219.806 L127.996,231.388 L128.685,232.171 L128.498,308.077 L127.996,309.428" fill="#8C3123"></path>
<path d="M127.996,309.428 L174.823,286.023 L174.823,219.806 L127.996,231.388 L127.996,309.428" fill="#E05243"></path>
<path d="M235.367,53.686 L256,64 L256,245.02 L235.367,255.33 L235.367,53.686" fill="#E05243"></path>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 1.7 KiB

View File

@ -16,7 +16,7 @@ func main() {
app.Name = "s3 sync plugin"
app.Usage = "s3 sync plugin"
app.Action = run
app.Version = fmt.Sprintf("1.0.%s", build)
app.Version = fmt.Sprintf("1.1.0+%s", build)
app.Flags = []cli.Flag{
cli.StringFlag{
Name: "access-key",

View File

@ -1,6 +1,8 @@
package main
import "encoding/json"
import (
"encoding/json"
)
type DeepStringMapFlag struct {
parts map[string]map[string]string