Restructuring of build process

This commit is contained in:
Thomas Boerger
2017-08-30 00:38:28 +02:00
parent ecd891f762
commit 47acbbc425
14 changed files with 152 additions and 198 deletions
+2
View File
@@ -0,0 +1,2 @@
*
!release/
+83 -16
View File
@@ -1,29 +1,96 @@
workspace:
base: /go
path: src/github.com/drone-plugins/drone-npm
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
latest:
image: docker
repo: plugins/npm
tags: [ "latest", "1.0", "1" ]
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 -o release/linux/amd64/drone-npm
# 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 -o release/linux/arm64/drone-npm
# 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 -o release/linux/arm/drone-npm
# 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 -o release/windows/amd64/drone-npm
publish_linux_amd64:
image: plugins/docker
repo: plugins/s3
tags: [ latest, 1.0.0, 1.0, 1 ]
secrets: [ docker_username, docker_password ]
when:
branch: master
event: push
plugin:
name: NPM
desc: Publish files and artifacts to a NPM registry
type: publish
image: plugins/npm
labels:
- publish
- node
# publish_linux_arm64:
# image: plugins/docker
# repo: plugins/s3
# 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
# 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
# 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 ]
-1
View File
@@ -1 +0,0 @@
eyJhbGciOiJIUzI1NiJ9.d29ya3NwYWNlOgogIGJhc2U6IC9nbwoKcGlwZWxpbmU6CiAgdGVzdDoKICAgIGltYWdlOiBnb2xhbmc6MS42CiAgICBlbnZpcm9ubWVudDoKICAgICAgLSBDR09fRU5BQkxFRD0wCiAgICBjb21tYW5kczoKICAgICAgLSBnbyB2ZXQKICAgICAgLSBnbyB0ZXN0IC1jb3ZlciAtY292ZXJwcm9maWxlPWNvdmVyYWdlLm91dAogICAgICAtIGdvIGJ1aWxkIC1sZGZsYWdzICItcyAtdyAtWCBtYWluLmJ1aWxkPSREUk9ORV9CVUlMRF9OVU1CRVIiIC1hIC10YWdzIG5ldGdvCgogIGxhdGVzdDoKICAgIGltYWdlOiBkb2NrZXIKICAgIHJlcG86IHBsdWdpbnMvbnBtCiAgICB0YWdzOiBbICJsYXRlc3QiLCAiMS4wIiwgIjEiIF0KICAgIHdoZW46CiAgICAgIGJyYW5jaDogbWFzdGVyCiAgICAgIGV2ZW50OiBwdXNoCgpwbHVnaW46CiAgbmFtZTogTlBNCiAgZGVzYzogUHVibGlzaCBmaWxlcyBhbmQgYXJ0aWZhY3RzIHRvIGEgTlBNIHJlZ2lzdHJ5CiAgdHlwZTogcHVibGlzaAogIGltYWdlOiBwbHVnaW5zL25wbQogIGxhYmVsczoKICAgIC0gcHVibGlzaAogICAgLSBub2RlCg.lQBXEB9Ckk1Y81XlBUkW1IJiylHhub-d3Giwd-Ss6TA
+1
View File
@@ -24,5 +24,6 @@ _testmain.go
*.prof
.env
release/*
coverage.out
drone-npm
-88
View File
@@ -1,88 +0,0 @@
Use this plugin for publishing libraries to public or private NPM registries.
## Config
The following parameters are used to configure the plugin:
* **username** - the username for the account to publish with
* **password** - the password for the account to publish with
* **token** - the deploy token to publish with
* **email** - the email address associated with the account to publish with.
* **registry** - the registry URL to use (https://registry.npmjs.org by default)
* **folder** - the folder, relative to the workspace, containing the library
(uses the workspace directory, by default)
* **tag** - the tag to use when publishing the package (does not set
one by default)
* **access* - the access level to use for scoped packages (does not set
one by default)
The following secret values can be set to configure the plugin.
* **NPM_USERNAME** - corresponds to **username**
* **NPM_PASSWORD** - corresponds to **password**
* **NPM_TOKEN** - corresponds to **token**
* **NPM_EMAIL** - corresponds to **email**
* **NPM_REGISTRY** - corresponds to **registry**
It is highly recommended to put the **NPM_PASSWORD** or **NPM_TOKEN** into
secrets so it is not exposed to users. This can be done using the drone-cli.
```bash
drone secret add --image=plugins/npm \
octocat/hello-world NPM_PASSWORD pa55word
drone secret add --image=plugins/npm \
octocat/hello-world NPM_TOKEN pa55word
```
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
## Authentication method
NPM registries typically authenticate based on a username password pair.
However NPM Enterprise users can also authenticate through
[tokens](http://blog.npmjs.org/post/106559223730/npm-enterprise-with-github-2fa).
If a token value is encountered the plugin will use that. If it is not present
then the plugin will default to username/password.
## Example
Global NPM with **NPM_PASSWORD** as a secret:
```yaml
pipeline:
npm:
image: plugins/npm
username: bob
email: bob@bob.me
```
A private NPM registry, such as [Sinopia](https://github.com/rlidwka/sinopia)
with **NPM_PASSWORD** as a secret:
```yaml
pipeline:
npm:
image: plugins/npm
username: drone
email: drone@drone.io
registry: "http://myregistry:4873"
```
[NPM Enterprise registry](https://www.npmjs.com/enterprise) with **NPM_TOKEN**
as a secret:
```yaml
pipeline:
npm:
image: plugins/npm
registry: "http://myregistry:8081"
```
+13 -9
View File
@@ -1,11 +1,15 @@
FROM alpine:3.4
FROM plugins/base:amd64
MAINTAINER Drone.IO Community <drone-dev@googlegroups.com>
RUN apk update && \
apk add \
ca-certificates \
git \
nodejs && \
rm -rf /var/cache/apk/*
ENV GODEBUG=netdns=go
ADD drone-npm /bin/
ENTRYPOINT ["/bin/drone-npm"]
RUN apk add -U --no-cache git nodejs
LABEL org.label-schema.version=latest
LABEL org.label-schema.vcs-url="https://github.com/drone-plugins/drone-npm.git"
LABEL org.label-schema.name="Drone NPM"
LABEL org.label-schema.vendor="Drone.IO Community"
LABEL org.label-schema.schema-version="1.0"
ADD release/linux/amd64/drone-npm /bin/
ENTRYPOINT [ "/bin/drone-npm" ]
+15
View File
@@ -0,0 +1,15 @@
FROM plugins/base:arm
MAINTAINER Drone.IO Community <drone-dev@googlegroups.com>
ENV GODEBUG=netdns=go
RUN apk add -U --no-cache git nodejs
LABEL org.label-schema.version=latest
LABEL org.label-schema.vcs-url="https://github.com/drone-plugins/drone-npm.git"
LABEL org.label-schema.name="Drone NPM"
LABEL org.label-schema.vendor="Drone.IO Community"
LABEL org.label-schema.schema-version="1.0"
ADD release/linux/arm/drone-npm /bin/
ENTRYPOINT [ "/bin/drone-npm" ]
+15
View File
@@ -0,0 +1,15 @@
FROM plugins/base:arm64
MAINTAINER Drone.IO Community <drone-dev@googlegroups.com>
ENV GODEBUG=netdns=go
RUN apk add -U --no-cache git nodejs
LABEL org.label-schema.version=latest
LABEL org.label-schema.vcs-url="https://github.com/drone-plugins/drone-npm.git"
LABEL org.label-schema.name="Drone NPM"
LABEL org.label-schema.vendor="Drone.IO Community"
LABEL org.label-schema.schema-version="1.0"
ADD release/linux/arm64/drone-npm /bin/
ENTRYPOINT [ "/bin/drone-npm" ]
-11
View File
@@ -1,11 +0,0 @@
FROM armhfbuild/alpine:3.4
RUN apk update && \
apk add \
ca-certificates \
git \
nodejs && \
rm -rf /var/cache/apk/*
ADD drone-npm /bin/
ENTRYPOINT ["/bin/drone-npm"]
+15
View File
@@ -0,0 +1,15 @@
FROM microsoft/nanoserver:latest
MAINTAINER Drone.IO Community <drone-dev@googlegroups.com>
ENV GODEBUG=netdns=go
# TODO: install nodejs and git
LABEL org.label-schema.version=latest
LABEL org.label-schema.vcs-url="https://github.com/drone-plugins/drone-npm.git"
LABEL org.label-schema.name="Drone NPM"
LABEL org.label-schema.vendor="Drone.IO Community"
LABEL org.label-schema.schema-version="1.0"
ADD release/windows/amd64/drone-npm /bin/
ENTRYPOINT [ "/bin/drone-npm" ]
-46
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"
]
+7 -17
View File
@@ -1,13 +1,12 @@
# drone-npm
[![Build Status](http://beta.drone.io/api/badges/drone-plugins/drone-npm/status.svg)](http://beta.drone.io/drone-plugins/drone-npm)
[![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-npm?status.svg)](http://godoc.org/github.com/drone-plugins/drone-npm)
[![Go Report](https://goreportcard.com/badge/github.com/drone-plugins/drone-npm)](https://goreportcard.com/report/github.com/drone-plugins/drone-npm)
[![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/npm.svg)](https://microbadger.com/images/plugins/npm "Get your own image badge on microbadger.com")
Drone plugin to publish files and artifacts to a private or public NPM
registry. 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 a private or public NPM registry. 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-npm/).
## 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/npm .
```
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-npm' not found or does not exist..
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -a -tags netgo -o release/linux/amd64/drone-npm
docker build --rm -t plugins/npm .
```
## Usage
@@ -45,7 +35,7 @@ docker run --rm \
-e NPM_PASSWORD=password \
-e NPM_EMAIL=drone@drone.io \
-v $(pwd):$(pwd) \
-w $(pwd) \
-w $(pwd) \
plugins/npm
```
@@ -59,6 +49,6 @@ docker run --rm \
-e NPM_REGISTRY=http://myregistry.com \
-e NPM_ALWAYS_AUTH=true \
-v $(pwd):$(pwd) \
-w $(pwd) \
-w $(pwd) \
plugins/npm
```
-9
View File
@@ -1,9 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<svg width="256px" height="100px" viewBox="0 0 256 100" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" preserveAspectRatio="xMidYMid">
<g>
<path d="M0,0 L0,85.4980695 L71.1660232,85.4980695 L71.1660232,99.8301158 L128,99.8301158 L128,85.4980695 L256,85.4980695 L256,0 L0,0 L0,0 Z" fill="#CB3837"></path>
<path d="M42.5019305,14.3320463 L14.3320463,14.3320463 L14.3320463,28.6640927 L14.3320463,71.1660232 L42.5019305,71.1660232 L42.5019305,28.6640927 L56.8339768,28.6640927 L56.8339768,71.1660232 L71.1660232,71.1660232 L71.1660232,28.6640927 L71.1660232,14.3320463 L42.5019305,14.3320463 L42.5019305,14.3320463 Z" fill="#FFFFFF"></path>
<path d="M85.4980695,14.3320463 L85.4980695,68.2007722 L85.4980695,71.1660232 L85.4980695,85.4980695 L114.162162,85.4980695 L114.162162,71.1660232 L142.332046,71.1660232 L142.332046,14.3320463 L85.4980695,14.3320463 L85.4980695,14.3320463 Z M128,56.8339768 L114.162162,56.8339768 L114.162162,28.6640927 L128,28.6640927 L128,56.8339768 L128,56.8339768 Z" fill="#FFFFFF"></path>
<path d="M184.833977,14.3320463 L156.664093,14.3320463 L156.664093,28.6640927 L156.664093,71.1660232 L184.833977,71.1660232 L184.833977,28.6640927 L199.166023,28.6640927 L199.166023,71.1660232 L213.498069,71.1660232 L213.498069,28.6640927 L227.830116,28.6640927 L227.830116,71.1660232 L242.162162,71.1660232 L242.162162,28.6640927 L242.162162,15.3204633 L242.162162,14.3320463 L184.833977,14.3320463 L184.833977,14.3320463 Z" fill="#FFFFFF"></path>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 1.6 KiB

+1 -1
View File
@@ -16,7 +16,7 @@ func main() {
app.Name = "npm plugin"
app.Usage = "npm 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: "username",