From 56a5d640b07609b44ec3864109378ae94783d8a3 Mon Sep 17 00:00:00 2001 From: Thomas Boerger Date: Sat, 2 Sep 2017 15:40:25 +0200 Subject: [PATCH] Restructuring of build process --- .dockerignore | 2 + .drone.yml | 102 +++++++++++++++++++++++++++++++++++++++++---- .drone.yml.sig | 1 - .gitignore | 1 + DOCS.md | 72 -------------------------------- Dockerfile | 16 +++---- Dockerfile.arm | 11 +++++ Dockerfile.arm64 | 11 +++++ Dockerfile.armhf | 9 ---- Dockerfile.windows | 11 +++++ MAINTAINERS | 46 -------------------- README.md | 20 +++------ logo.svg | 6 --- main.go | 2 +- 14 files changed, 145 insertions(+), 165 deletions(-) create mode 100644 .dockerignore delete mode 100644 .drone.yml.sig delete mode 100644 DOCS.md create mode 100644 Dockerfile.arm create mode 100644 Dockerfile.arm64 delete mode 100644 Dockerfile.armhf create mode 100644 Dockerfile.windows delete mode 100644 MAINTAINERS delete mode 100644 logo.svg diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..c13ca3f --- /dev/null +++ b/.dockerignore @@ -0,0 +1,2 @@ +* +!release/ diff --git a/.drone.yml b/.drone.yml index 4ff918f..7959661 100644 --- a/.drone.yml +++ b/.drone.yml @@ -4,19 +4,105 @@ workspace: pipeline: test: - image: golang:1.6 - environment: - - CGO_ENABLED=0 + image: golang:1.9 + pull: true commands: - go vet - go test -cover -coverprofile=coverage.out - - go build -ldflags "-s -w -X main.build=$DRONE_BUILD_NUMBER" -a -tags netgo - publish: - image: plugins/docker + build_linux_amd64: + image: golang:1.9 + pull: true + group: build + environment: + - GOOS=linux + - GOARCH=amd64 + - CGO_ENABLED=0 + commands: + - go build -v -ldflags "-X main.build=${DRONE_BUILD_NUMBER}" -a -o release/linux/amd64/drone-github-release + + build_linux_arm64: + image: golang:1.9 + pull: true + group: build + environment: + - GOOS=linux + - GOARCH=arm64 + - CGO_ENABLED=0 + commands: + - go build -v -ldflags "-X main.build=${DRONE_BUILD_NUMBER}" -a -o release/linux/arm64/drone-github-release + + build_linux_arm: + image: golang:1.9 + pull: true + group: build + environment: + - 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-github-release + + # 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-github-release + + publish_linux_amd64: + image: plugins/docker:17.05 + pull: true repo: plugins/github-release - tags: [ "latest", "1.0", "1" ] - secrets: [docker_username, docker_password] + tags: [ latest, 1.0.0, 1.0, 1 ] + secrets: [ docker_username, docker_password ] when: branch: master event: push + + publish_linux_arm64: + image: plugins/docker:17.05 + pull: true + repo: plugins/github-release + tags: [ linux-arm64 ] + secrets: [ docker_username, docker_password ] + dockerfile: Dockerfile.arm64 + when: + branch: master + event: push + + publish_linux_arm: + image: plugins/docker:17.05 + pull: true + repo: plugins/github-release + tags: [ linux-arm ] + secrets: [ docker_username, docker_password ] + dockerfile: Dockerfile.arm + when: + branch: master + event: push + + # publish_windows_amd64: + # image: plugins/docker:17.05 + # pull: true + # repo: plugins/github-release + # tags: [ windows-amd64 ] + # secrets: [ docker_username, docker_password ] + # dockerfile: Dockerfile.windows + # when: + # branch: master + # event: push + + microbadger: + image: plugins/webhook:1 + pull: true + secrets: [ webhook_url ] + when: + branch: master + event: push + status: [ success ] diff --git a/.drone.yml.sig b/.drone.yml.sig deleted file mode 100644 index 57a6885..0000000 --- a/.drone.yml.sig +++ /dev/null @@ -1 +0,0 @@ -eyJhbGciOiJIUzI1NiJ9.d29ya3NwYWNlOgogIGJhc2U6IC9nbwoKcGlwZWxpbmU6CiAgdGVzdDoKICAgIGltYWdlOiBnb2xhbmc6MS42CiAgICBlbnZpcm9ubWVudDoKICAgICAgLSBDR09fRU5BQkxFRD0wCiAgICBjb21tYW5kczoKICAgICAgLSBnbyB2ZXQKICAgICAgLSBnbyB0ZXN0IC1jb3ZlciAtY292ZXJwcm9maWxlPWNvdmVyYWdlLm91dAogICAgICAtIGdvIGJ1aWxkIC1sZGZsYWdzICItcyAtdyAtWCBtYWluLmJ1aWxkPSREUk9ORV9CVUlMRF9OVU1CRVIiIC1hIC10YWdzIG5ldGdvCgogIGxhdGVzdDoKICAgIGltYWdlOiBkb2NrZXIKICAgIHJlcG86IHBsdWdpbnMvZ2l0aHViLXJlbGVhc2UKICAgIHRhZ3M6IFsgImxhdGVzdCIsICIxLjAiLCAiMSIgXQogICAgd2hlbjoKICAgICAgYnJhbmNoOiBtYXN0ZXIKICAgICAgZXZlbnQ6IHB1c2gKCnBsdWdpbjoKICBuYW1lOiBHaXRIdWIgUmVsZWFzZQogIGRlc2M6IFB1Ymxpc2ggZmlsZXMgYW5kIGFydGlmYWN0cyB0byBHaXRIdWIgUmVsZWFzZXMKICB0eXBlOiBwdWJsaXNoCiAgaW1hZ2U6IHBsdWdpbnMvZ2l0aHViLXJlbGVhc2UKICBsYWJlbHM6CiAgICAtIGdpdGh1YgogICAgLSByZWxlYXNlCg.5FZW1Auk18CljY9LW5P82r9RM_spPCYMYg82PFj2irM \ No newline at end of file diff --git a/.gitignore b/.gitignore index fb49cd0..c90bde1 100644 --- a/.gitignore +++ b/.gitignore @@ -24,5 +24,6 @@ _testmain.go *.prof .env +release/* coverage.out drone-github-release diff --git a/DOCS.md b/DOCS.md deleted file mode 100644 index d26ef62..0000000 --- a/DOCS.md +++ /dev/null @@ -1,72 +0,0 @@ -Use this plugin for publishing files and artifacts to GitHub releases. Be aware -that you can use this plugin only for tags, GitHub doesn't support the release -of branches. - -## Config - -The following parameters are used to configure the plugin: - -* **api_key** - GitHub oauth token with public_repo or repo permission -* **files** - files to upload to GitHub Release, globs are allowed -* **file_exists** - what to do if an file asset already exists, supported values: **overwrite** (default), **skip** and **fail** -* **checksum** - checksum takes hash methods to include in your GitHub release for the files specified. Supported hash methods include md5, sha1, sha256, sha512, adler32, and crc32. -* **draft** - create a draft release if set to true -* **prerelease** - set the release as prerelease if set to true -* **base_url** - GitHub base URL, only required for GHE -* **upload_url** - GitHub upload URL, only required for GHE - -The following secret values can be set to configure the plugin. - -* **GITHUB_RELEASE_API_KEY** - corresponds to **api_key** -* **GITHUB_RELEASE_BASE_URL** - corresponds to **base_url** -* **GITHUB_RELEASE_UPLOAD_URL** - corresponds to **upload_url** - -It is highly recommended to put the **GITHUB_RELEASE_API_KEY** into a secret so -it is not exposed to users. This can be done using the drone-cli. - -```bash -drone secret add --image=plugins/github-release \ - octocat/hello-world GITHUB_RELEASE_API_KEY my_github_api_key -``` - -Then sign the YAML file after all secrets are added. - -```bash -drone sign octocat/hello-world -``` - -See [secrets](http://readme.drone.io/0.5/usage/secrets/) for additional -information on secrets - -## Examples - -The following is a sample configuration in your .drone.yml file: - -```yaml -pipeline: - github_release: - image: plugins/github-release - files: dist/* - when: - event: tag -``` - -An example for generating checksums and upload additional files: - -```yaml -pipeline: - github_release: - image: plugins/github-release - files: - - dist/* - - bin/binary.exe - checksum: - - md5 - - sha1 - - sha256 - - sha512 - - adler32 - - crc32 - when: - event: tag -``` diff --git a/Dockerfile b/Dockerfile index aa86bb2..8f6d268 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,9 +1,11 @@ -FROM alpine:3.4 +FROM plugins/base:multiarch +MAINTAINER Drone.IO Community -RUN apk update && \ - apk add \ - ca-certificates && \ - rm -rf /var/cache/apk/* +LABEL org.label-schema.version=latest +LABEL org.label-schema.vcs-url="https://github.com/drone-plugins/drone-github-release.git" +LABEL org.label-schema.name="Drone GitHub Release" +LABEL org.label-schema.vendor="Drone.IO Community" +LABEL org.label-schema.schema-version="1.0" -ADD drone-github-release /bin/ -ENTRYPOINT ["/bin/drone-github-release"] +ADD release/linux/amd64/drone-github-release /bin/ +ENTRYPOINT [ "/bin/drone-github-release" ] diff --git a/Dockerfile.arm b/Dockerfile.arm new file mode 100644 index 0000000..af52148 --- /dev/null +++ b/Dockerfile.arm @@ -0,0 +1,11 @@ +FROM plugins/base:multiarch +MAINTAINER Drone.IO Community + +LABEL org.label-schema.version=latest +LABEL org.label-schema.vcs-url="https://github.com/drone-plugins/drone-github-release.git" +LABEL org.label-schema.name="Drone GitHub Release" +LABEL org.label-schema.vendor="Drone.IO Community" +LABEL org.label-schema.schema-version="1.0" + +ADD release/linux/arm/drone-github-release /bin/ +ENTRYPOINT [ "/bin/drone-github-release" ] diff --git a/Dockerfile.arm64 b/Dockerfile.arm64 new file mode 100644 index 0000000..451eca4 --- /dev/null +++ b/Dockerfile.arm64 @@ -0,0 +1,11 @@ +FROM plugins/base:multiarch +MAINTAINER Drone.IO Community + +LABEL org.label-schema.version=latest +LABEL org.label-schema.vcs-url="https://github.com/drone-plugins/drone-github-release.git" +LABEL org.label-schema.name="Drone GitHub Release" +LABEL org.label-schema.vendor="Drone.IO Community" +LABEL org.label-schema.schema-version="1.0" + +ADD release/linux/arm64/drone-github-release /bin/ +ENTRYPOINT [ "/bin/drone-github-release" ] diff --git a/Dockerfile.armhf b/Dockerfile.armhf deleted file mode 100644 index 7eeb9a5..0000000 --- a/Dockerfile.armhf +++ /dev/null @@ -1,9 +0,0 @@ -FROM armhfbuild/alpine:3.4 - -RUN apk update && \ - apk add \ - ca-certificates && \ - rm -rf /var/cache/apk/* - -ADD drone-github-release /bin/ -ENTRYPOINT ["/bin/drone-github-release"] diff --git a/Dockerfile.windows b/Dockerfile.windows new file mode 100644 index 0000000..c0ceac9 --- /dev/null +++ b/Dockerfile.windows @@ -0,0 +1,11 @@ +FROM microsoft/nanoserver:latest +MAINTAINER Drone.IO Community + +LABEL org.label-schema.version=latest +LABEL org.label-schema.vcs-url="https://github.com/drone-plugins/drone-github-release.git" +LABEL org.label-schema.name="Drone GitHub Release" +LABEL org.label-schema.vendor="Drone.IO Community" +LABEL org.label-schema.schema-version="1.0" + +ADD release/windows/amd64/drone-github-release /bin/ +ENTRYPOINT [ "/bin/drone-github-release" ] diff --git a/MAINTAINERS b/MAINTAINERS deleted file mode 100644 index 0ecaf19..0000000 --- a/MAINTAINERS +++ /dev/null @@ -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" - ] diff --git a/README.md b/README.md index e65de69..3bb1fa5 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,12 @@ # drone-github-release [![Build Status](http://beta.drone.io/api/badges/drone-plugins/drone-github-release/status.svg)](http://beta.drone.io/drone-plugins/drone-github-release) +[![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-github-release?status.svg)](http://godoc.org/github.com/drone-plugins/drone-github-release) [![Go Report](https://goreportcard.com/badge/github.com/drone-plugins/drone-github-release)](https://goreportcard.com/report/github.com/drone-plugins/drone-github-release) -[![Join the chat at https://gitter.im/drone/drone](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/drone/drone) +[![](https://images.microbadger.com/badges/image/plugins/github-release.svg)](https://microbadger.com/images/plugins/github-release "Get your own image badge on microbadger.com") -Drone plugin to publish files and artifacts to GitHub Release. For the usage -information and a listing of the available options please take a look at -[the docs](DOCS.md). +Drone plugin to publish files and artifacts to GitHub Release. 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-github-release/). ## Build @@ -15,7 +14,6 @@ Build the binary with the following commands: ``` go build -go test ``` ## Docker @@ -23,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/github-release . -``` - -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-github-release' not found or does not exist.. +GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -a -tags netgo -o release/linux/amd64/drone-github-release +docker build --rm -t plugins/github-release . ``` ## Usage diff --git a/logo.svg b/logo.svg deleted file mode 100644 index bf0cf26..0000000 --- a/logo.svg +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/main.go b/main.go index ea0509b..4e94bbb 100644 --- a/main.go +++ b/main.go @@ -16,7 +16,7 @@ func main() { app.Name = "github-release plugin" app.Usage = "github-release plugin" app.Action = run - app.Version = fmt.Sprintf("1.0.%s", build) + app.Version = fmt.Sprintf("1.0.0+%s", build) app.Flags = []cli.Flag{ cli.StringFlag{ Name: "api-key",