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 e7cafae..28ae9ff 100644 --- a/.drone.yml +++ b/.drone.yml @@ -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 ] diff --git a/.drone.yml.sig b/.drone.yml.sig deleted file mode 100644 index 13ab701..0000000 --- a/.drone.yml.sig +++ /dev/null @@ -1 +0,0 @@ -eyJhbGciOiJIUzI1NiJ9.d29ya3NwYWNlOgogIGJhc2U6IC9nbwoKcGlwZWxpbmU6CiAgdGVzdDoKICAgIGltYWdlOiBnb2xhbmc6MS42CiAgICBlbnZpcm9ubWVudDoKICAgICAgLSBDR09fRU5BQkxFRD0wCiAgICBjb21tYW5kczoKICAgICAgLSBnbyB2ZXQKICAgICAgLSBnbyB0ZXN0IC1jb3ZlciAtY292ZXJwcm9maWxlPWNvdmVyYWdlLm91dAogICAgICAtIGdvIGJ1aWxkIC1sZGZsYWdzICItcyAtdyAtWCBtYWluLmJ1aWxkPSREUk9ORV9CVUlMRF9OVU1CRVIiIC1hIC10YWdzIG5ldGdvCgogIGxhdGVzdDoKICAgIGltYWdlOiBkb2NrZXIKICAgIHJlcG86IHBsdWdpbnMvbnBtCiAgICB0YWdzOiBbICJsYXRlc3QiLCAiMS4wIiwgIjEiIF0KICAgIHdoZW46CiAgICAgIGJyYW5jaDogbWFzdGVyCiAgICAgIGV2ZW50OiBwdXNoCgpwbHVnaW46CiAgbmFtZTogTlBNCiAgZGVzYzogUHVibGlzaCBmaWxlcyBhbmQgYXJ0aWZhY3RzIHRvIGEgTlBNIHJlZ2lzdHJ5CiAgdHlwZTogcHVibGlzaAogIGltYWdlOiBwbHVnaW5zL25wbQogIGxhYmVsczoKICAgIC0gcHVibGlzaAogICAgLSBub2RlCg.lQBXEB9Ckk1Y81XlBUkW1IJiylHhub-d3Giwd-Ss6TA \ No newline at end of file diff --git a/.gitignore b/.gitignore index 75d0287..6e784d4 100644 --- a/.gitignore +++ b/.gitignore @@ -24,5 +24,6 @@ _testmain.go *.prof .env +release/* coverage.out drone-npm diff --git a/DOCS.md b/DOCS.md deleted file mode 100644 index 4043772..0000000 --- a/DOCS.md +++ /dev/null @@ -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" -``` diff --git a/Dockerfile b/Dockerfile index d123e43..8a370e8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,11 +1,15 @@ -FROM alpine:3.4 +FROM plugins/base:amd64 +MAINTAINER Drone.IO Community -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" ] diff --git a/Dockerfile.arm b/Dockerfile.arm new file mode 100644 index 0000000..6b1b975 --- /dev/null +++ b/Dockerfile.arm @@ -0,0 +1,15 @@ +FROM plugins/base:arm +MAINTAINER Drone.IO Community + +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" ] diff --git a/Dockerfile.arm64 b/Dockerfile.arm64 new file mode 100644 index 0000000..b5ef95e --- /dev/null +++ b/Dockerfile.arm64 @@ -0,0 +1,15 @@ +FROM plugins/base:arm64 +MAINTAINER Drone.IO Community + +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" ] diff --git a/Dockerfile.armhf b/Dockerfile.armhf deleted file mode 100644 index 4680ce7..0000000 --- a/Dockerfile.armhf +++ /dev/null @@ -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"] diff --git a/Dockerfile.windows b/Dockerfile.windows new file mode 100644 index 0000000..67d132f --- /dev/null +++ b/Dockerfile.windows @@ -0,0 +1,15 @@ +FROM microsoft/nanoserver:latest +MAINTAINER Drone.IO Community + +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" ] 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 30b1666..6983cb4 100644 --- a/README.md +++ b/README.md @@ -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 ``` diff --git a/logo.svg b/logo.svg deleted file mode 100644 index aedea2b..0000000 --- a/logo.svg +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - diff --git a/main.go b/main.go index 7f95539..45f45ee 100644 --- a/main.go +++ b/main.go @@ -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",