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.sec b/.drone.sec deleted file mode 100644 index 3d9ec90..0000000 --- a/.drone.sec +++ /dev/null @@ -1 +0,0 @@ -eyJhbGciOiJSU0EtT0FFUCIsImVuYyI6IkExMjhHQ00ifQ.NgmTjpX8KTXg8d46V6rGUUYHhs-VKWUtBzWXcT2z8erxS4lPzi4kvM1KxDP_ZV1WOlXXZRnHyE-qBNr9tyt2SDbLqUi4tAjievKarihQ6ECXDX_Kpdow1_Zo96P9X5s8g9N0bxaev2v17_i0zvk14eL72I8PLQY_9sZLuqDI-862zqFv_LvMaGbKWawhCj4EYpm8qXY6WkVounc8akQOCe2LfYlpSFSKK6O9mOP1IuaUuLNSRama0oAFFkZo8xZWB6vYM39hHtvps1LBdKi21hwWOpKER8U7i1YMxhTBoDSn357_-smyITPPhB4B0CL3TQp117CkFBg1LrNpYhuYPA.Fy281xlLnP6AqOgd.FLEy00qJShp8F2gNEFlhUFz_WAy3bUizhE9Gwf0OFnXmepwUgmFGtTusp9BXlBqbT-ufToJkqmezD0cyGRtvhD1b1WeRUWCIyWi7JJI2XSZNi7JeGztezb-5kFLZ82b0nmZs8F3-1jsDPmrzS9nUOjEme2qxhIrILodSKazrT1J4lKAyVbpfwbl1JYFz1neF6RXOEelXIxjTRb_Y1sCXKFWwXx9009K8SwXdizpF.Gv_srOzRrGYgLajQf-sG3g \ No newline at end of file diff --git a/.drone.star b/.drone.star new file mode 100644 index 0000000..952d69a --- /dev/null +++ b/.drone.star @@ -0,0 +1,357 @@ +def main(ctx): + before = testing(ctx) + + stages = [ + linux(ctx, 'amd64'), + linux(ctx, 'arm64'), + linux(ctx, 'arm'), + windows(ctx, '1903'), + windows(ctx, '1809'), + ] + + after = manifest(ctx) + gitter(ctx) + + for b in before: + for s in stages: + s['depends_on'].append(b['name']) + + for s in stages: + for a in after: + a['depends_on'].append(s['name']) + + return before + stages + after + +def testing(ctx): + return [{ + 'kind': 'pipeline', + 'type': 'docker', + 'name': 'testing', + 'platform': { + 'os': 'linux', + 'arch': 'amd64', + }, + 'steps': [ + { + 'name': 'staticcheck', + 'image': 'golang:1.14', + 'pull': 'always', + 'commands': [ + 'go run honnef.co/go/tools/cmd/staticcheck ./...', + ], + 'volumes': [ + { + 'name': 'gopath', + 'path': '/go', + }, + ], + }, + { + 'name': 'lint', + 'image': 'golang:1.14', + 'pull': 'always', + 'commands': [ + 'go run golang.org/x/lint/golint -set_exit_status ./...', + ], + 'volumes': [ + { + 'name': 'gopath', + 'path': '/go', + }, + ], + }, + { + 'name': 'vet', + 'image': 'golang:1.14', + 'pull': 'always', + 'commands': [ + 'go vet ./...', + ], + 'volumes': [ + { + 'name': 'gopath', + 'path': '/go', + }, + ], + }, + { + 'name': 'test', + 'image': 'golang:1.14', + 'pull': 'always', + 'commands': [ + 'go test -cover ./...', + ], + 'volumes': [ + { + 'name': 'gopath', + 'path': '/go', + }, + ], + }, + ], + 'volumes': [ + { + 'name': 'gopath', + 'temp': {}, + }, + ], + 'trigger': { + 'ref': [ + 'refs/heads/master', + 'refs/tags/**', + 'refs/pull/**', + ], + }, + }] + +def linux(ctx, arch): + docker = { + 'dockerfile': 'docker/Dockerfile.linux.%s' % (arch), + 'repo': 'plugins/nuget', + 'username': { + 'from_secret': 'docker_username', + }, + 'password': { + 'from_secret': 'docker_password', + }, + } + + if ctx.build.event == 'pull_request': + docker.update({ + 'dry_run': True, + 'tags': 'linux-%s' % (arch), + }) + else: + docker.update({ + 'auto_tag': True, + 'auto_tag_suffix': 'linux-%s' % (arch), + }) + + if ctx.build.event == 'tag': + build = [ + 'go build -v -ldflags "-X main.version=%s" -a -tags netgo -o release/linux/%s/drone-nuget ./cmd/drone-nuget' % (ctx.build.ref.replace("refs/tags/v", ""), arch), + ] + else: + build = [ + 'go build -v -ldflags "-X main.version=%s" -a -tags netgo -o release/linux/%s/drone-nuget ./cmd/drone-nuget' % (ctx.build.commit[0:8], arch), + ] + + return { + 'kind': 'pipeline', + 'type': 'docker', + 'name': 'linux-%s' % (arch), + 'platform': { + 'os': 'linux', + 'arch': arch, + }, + 'steps': [ + { + 'name': 'environment', + 'image': 'golang:1.14', + 'pull': 'always', + 'environment': { + 'CGO_ENABLED': '0', + }, + 'commands': [ + 'go version', + 'go env', + ], + }, + { + 'name': 'build', + 'image': 'golang:1.14', + 'pull': 'always', + 'environment': { + 'CGO_ENABLED': '0', + }, + 'commands': build, + }, + { + 'name': 'executable', + 'image': 'golang:1.14', + 'pull': 'always', + 'commands': [ + './release/linux/%s/drone-nuget --help' % (arch), + ], + }, + { + 'name': 'docker', + 'image': 'plugins/docker', + 'pull': 'always', + 'settings': docker, + }, + ], + 'depends_on': [], + 'trigger': { + 'ref': [ + 'refs/heads/master', + 'refs/tags/**', + 'refs/pull/**', + ], + }, + } + +def windows(ctx, version): + docker = [ + 'echo $env:PASSWORD | docker login --username $env:USERNAME --password-stdin', + ] + + if ctx.build.event == 'tag': + build = [ + 'go build -v -ldflags "-X main.version=%s" -a -tags netgo -o release/windows/amd64/drone-nuget.exe ./cmd/drone-nuget' % (ctx.build.ref.replace("refs/tags/v", "")), + ] + + docker = docker + [ + 'docker build --pull -f docker/Dockerfile.windows.%s -t plugins/nuget:%s-windows-%s-amd64 .' % (version, ctx.build.ref.replace("refs/tags/v", ""), version), + 'docker run --rm plugins/nuget:%s-windows-%s-amd64 --help' % (ctx.build.ref.replace("refs/tags/v", ""), version), + 'docker push plugins/nuget:%s-windows-%s-amd64' % (ctx.build.ref.replace("refs/tags/v", ""), version), + ] + else: + build = [ + 'go build -v -ldflags "-X main.version=%s" -a -tags netgo -o release/windows/amd64/drone-nuget.exe ./cmd/drone-nuget' % (ctx.build.commit[0:8]), + ] + + docker = docker + [ + 'docker build --pull -f docker/Dockerfile.windows.%s -t plugins/nuget:windows-%s-amd64 .' % (version, version), + 'docker run --rm plugins/nuget:windows-%s-amd64 --help' % (version), + 'docker push plugins/nuget:windows-%s-amd64' % (version), + ] + + return { + 'kind': 'pipeline', + 'type': 'ssh', + 'name': 'windows-%s' % (version), + 'platform': { + 'os': 'windows', + }, + 'server': { + 'host': { + 'from_secret': 'windows_server_%s' % (version), + }, + 'user': { + 'from_secret': 'windows_username', + }, + 'password': { + 'from_secret': 'windows_password', + }, + }, + 'steps': [ + { + 'name': 'environment', + 'environment': { + 'CGO_ENABLED': '0', + }, + 'commands': [ + 'go version', + 'go env', + ], + }, + { + 'name': 'build', + 'environment': { + 'CGO_ENABLED': '0', + }, + 'commands': build, + }, + { + 'name': 'executable', + 'commands': [ + './release/windows/amd64/drone-nuget.exe --help', + ], + }, + { + 'name': 'docker', + 'environment': { + 'USERNAME': { + 'from_secret': 'docker_username', + }, + 'PASSWORD': { + 'from_secret': 'docker_password', + }, + }, + 'commands': docker, + }, + ], + 'depends_on': [], + 'trigger': { + 'ref': [ + 'refs/heads/master', + 'refs/tags/**', + ], + }, + } + +def manifest(ctx): + return [{ + 'kind': 'pipeline', + 'type': 'docker', + 'name': 'manifest', + 'steps': [ + { + 'name': 'manifest', + 'image': 'plugins/manifest', + 'pull': 'always', + 'settings': { + 'auto_tag': 'true', + 'username': { + 'from_secret': 'docker_username', + }, + 'password': { + 'from_secret': 'docker_password', + }, + 'spec': 'docker/manifest.tmpl', + 'ignore_missing': 'true', + }, + }, + { + 'name': 'microbadger', + 'image': 'plugins/webhook', + 'pull': 'always', + 'settings': { + 'urls': { + 'from_secret': 'microbadger_url', + }, + }, + }, + ], + 'depends_on': [], + 'trigger': { + 'ref': [ + 'refs/heads/master', + 'refs/tags/**', + ], + }, + }] + +def gitter(ctx): + return [{ + 'kind': 'pipeline', + 'type': 'docker', + 'name': 'gitter', + 'clone': { + 'disable': True, + }, + 'steps': [ + { + 'name': 'gitter', + 'image': 'plugins/gitter', + 'pull': 'always', + 'settings': { + 'webhook': { + 'from_secret': 'gitter_webhook', + } + }, + }, + ], + 'depends_on': [ + 'manifest', + ], + 'trigger': { + 'ref': [ + 'refs/heads/master', + 'refs/tags/**', + ], + 'status': [ + 'failure', + ], + }, + }] diff --git a/.drone.yml b/.drone.yml deleted file mode 100644 index 4b05258..0000000 --- a/.drone.yml +++ /dev/null @@ -1,36 +0,0 @@ -build: - image: node:4.2 - commands: - - make install - - make test - -publish: - coverage: - # Must match parts of the absolute path - include: drone-nuget/coverage/lcov.info - when: - branch: master - docker: - username: $$DOCKER_USER - password: $$DOCKER_PASS - email: $$DOCKER_EMAIL - repo: plugins/drone-nuget - tag: latest - when: - branch: master - docker: - username: $$DOCKER_USER - password: $$DOCKER_PASS - email: $$DOCKER_EMAIL - repo: plugins/drone-nuget - tag: develop - when: - branch: develop - -plugin: - name: NuGet - desc: Publish files and artifacts to NuGet repository - type: publish - image: plugins/drone-nuget - labels: - - nuget diff --git a/.gitignore b/.gitignore index 25fbf5a..cd50026 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,5 @@ -node_modules/ -coverage/ +/release/ +/drone-nuget* + +coverage.out +.drone.yml diff --git a/DOCS.md b/DOCS.md deleted file mode 100644 index b26eff8..0000000 --- a/DOCS.md +++ /dev/null @@ -1,28 +0,0 @@ -Use this plugin to publish artifacts from the build to a NuGet Repository -You can override the default configuration with the following parameters: - -* `source` - NuGet Repository URL -* `api_key` - Api Key used for authentication -* `verbosity` - NuGet output verbosity, default to 'quiet'. Accept: normal, quiet or detailed -* `files` - List of files to upload - -All file paths must be relative to current project sources - -## Example - -The following is a sample configuration in your .drone.yml file: - -```yaml -publish: - nuget: - source: http://nuget.company.com - api_key: - files: - - *.nupkg -``` - -## .nuspec / .nupkg - -If a file to upload does have ```.nuspec``` extension, the __nuget pack__ command is called before a push - -If a file to upload does have ```.nupkg``` extension, it is pushed directly diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index 877db12..0000000 --- a/Dockerfile +++ /dev/null @@ -1,23 +0,0 @@ -FROM alpine:3.3 - -RUN echo "@testing http://dl-4.alpinelinux.org/alpine/edge/testing" | tee -a /etc/apk/repositories - -RUN apk update && \ - apk add \ - ca-certificates \ - nodejs \ - mono@testing && \ - rm -rf \ - /var/cache/apk/* - -RUN mkdir -p /usr/lib/nuget && \ - wget \ - https://dist.nuget.org/win-x86-commandline/v2.8.6/nuget.exe \ - -O /usr/lib/nuget/NuGet.exe - -WORKDIR /node -ADD package.json /node/ -ADD index.js /node/ -RUN npm install --production - -ENTRYPOINT ["node", "index.js"] 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/Makefile b/Makefile deleted file mode 100644 index 39840a2..0000000 --- a/Makefile +++ /dev/null @@ -1,14 +0,0 @@ -.PHONY: all install test docker - -IMAGE ?= plugins/drone-nuget - -all: install test - -install: - npm install --quiet - -test: - @echo "Currently we don't provide test cases!" - -docker: - docker build --rm -t $(IMAGE) . diff --git a/README.md b/README.md index d504f02..8c42b7d 100644 --- a/README.md +++ b/README.md @@ -1,107 +1,47 @@ # drone-nuget -[![Build Status](http://beta.drone.io/api/badges/drone-plugins/drone-nuget/status.svg)](http://beta.drone.io/drone-plugins/drone-nuget) -[![Coverage Status](https://aircover.co/badges/drone-plugins/drone-nuget/coverage.svg)](https://aircover.co/drone-plugins/drone-nuget) -[![](https://badge.imagelayers.io/plugins/drone-nuget:latest.svg)](https://imagelayers.io/?images=plugins/drone-nuget:latest 'Get your own badge on imagelayers.io') +[![Build Status](http://cloud.drone.io/api/badges/drone-plugins/drone-nuget/status.svg)](http://cloud.drone.io/drone-plugins/drone-nuget) +[![Gitter chat](https://badges.gitter.im/drone/drone.png)](https://gitter.im/drone/drone) +[![Join the discussion at https://discourse.drone.io](https://img.shields.io/badge/discourse-forum-orange.svg)](https://discourse.drone.io) +[![Drone questions at https://stackoverflow.com](https://img.shields.io/badge/drone-stackoverflow-orange.svg)](https://stackoverflow.com/questions/tagged/drone.io) +[![](https://images.microbadger.com/badges/image/plugins/nuget.svg)](https://microbadger.com/images/plugins/nuget "Get your own image badge on microbadger.com") +[![Go Doc](https://godoc.org/github.com/drone-plugins/drone-nuget?status.svg)](http://godoc.org/github.com/drone-plugins/drone-nuget) +[![Go Report](https://goreportcard.com/badge/github.com/drone-plugins/drone-nuget)](https://goreportcard.com/report/github.com/drone-plugins/drone-nuget) -Drone plugin to publish files and artifacts to NuGet repository. 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 NuGet repository. For the usage information and a listing of the available options please take a look at [the docs](DOCS.md). -## Execute +## Build -Install the deps using `make`: +Build the binary with the following command: -``` -make install -``` +```console +export GOOS=linux +export GOARCH=amd64 +export CGO_ENABLED=0 +export GO111MODULE=on -### Example - -```sh -npm start < { return shelljs.ls(workspace.path + '/' + f); })); - resolved_files.forEach((file) => { - - if (path.extname(file) === '.nuspec') { - do_pack_then_push(nuget, workspace, vargs, file); - } else { - do_push(nuget, workspace, vargs, file); - } - }); - } else { - console.log("Parameter missing: NuGet source URL"); - process.exit(1) - } -} - -plugin.parse().then((params) => { - - // gets build and repository information for - // the current running build - const build = params.build; - const repo = params.repo; - const workspace = params.workspace; - - // gets plugin-specific parameters defined in - // the .drone.yml file - const vargs = params.vargs; - - vargs.verbosity || (vargs.verbosity = 'quiet'); - vargs.files || (vargs.files = []); - - do_upload(workspace, vargs); -}); diff --git a/logo.svg b/logo.svg deleted file mode 100644 index f9f735a..0000000 --- a/logo.svg +++ /dev/null @@ -1,144 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - NuGet logo - - - - - - - - - - - - - - diff --git a/package.json b/package.json deleted file mode 100644 index 0d555f0..0000000 --- a/package.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "name": "drone-nuget", - "version": "1.0.0", - "description": "Drone plugin to publish files and artifacts to NuGet repository", - "main": "index.js", - "repository": { - "type": "git", - "url": "https://github.com/drone-plugins/drone-nuget.git" - }, - "keywords": [ - "drone", - "nuget" - ], - "author": "Aurélien Thieriot", - "license": "Apache-2.0", - "bugs": { - "url": "https://github.com/drone-plugins/drone-nuget/issues" - }, - "homepage": "https://github.com/drone-plugins/drone-nuget#README.md", - "dependencies": { - "drone-node": "^1.0.1", - "nuget-runner": "^0.1.7", - "shelljs": "^0.5.3" - } -} diff --git a/plugin/impl.go b/plugin/impl.go new file mode 100644 index 0000000..28e682b --- /dev/null +++ b/plugin/impl.go @@ -0,0 +1,226 @@ +// Copyright (c) 2020, the Drone Plugins project authors. +// Please see the AUTHORS file for details. All rights reserved. +// Use of this source code is governed by an Apache 2.0 license that can be +// found in the LICENSE file. + +package plugin + +import ( + "encoding/xml" + "fmt" + "io/ioutil" + "net/url" + "os" + "os/exec" + "path" + "path/filepath" + "strings" + + "github.com/sirupsen/logrus" +) + +type ( + // Settings for the plugin. + Settings struct { + APIKey string + Source string + Name string + File string + + nupkg string + } +) + +const ( + nugetOrgName = "nuget.org" + nugetOrgSource = "https://api.nuget.org/v3/index.json" +) + +// Validate handles the settings validation of the plugin. +func (p *Plugin) Validate() error { + if p.settings.APIKey == "" { + return fmt.Errorf("no api key provided") + } + + file := p.settings.File + if file == "" { + return fmt.Errorf("no package specified") + } + + // Convert to / separators from os specific ones and then use path + // Windows works fine with / but unix does not work with \ + file = filepath.ToSlash(file) + + // Clean the path + file = path.Clean(file) + + // Find .nupkg file + switch path.Ext(file) { + case ".nuspec": + nuspec := file + logrus.WithField("file", nuspec).Info("Loading .nuspec file") + + var err error + file, err = nupkgFromNuspec(nuspec) + if err != nil { + return fmt.Errorf("could not determine nupkg file from %s: %w", nuspec, err) + } + case ".nupkg": + // Do nothing + default: + return fmt.Errorf("file %s isn't a nuspec or a nupkg", file) + } + + if !fileExists(file) { + return fmt.Errorf(".nupkg file does not exist at %s", file) + } + + logrus.WithField("file", file).Info("Publishing .nupkg file") + + // Store nupkg file and convert to os specific path + p.settings.nupkg = filepath.FromSlash(file) + + // Set defaults for source and name + if p.settings.Source == "" { + p.settings.Source = nugetOrgSource + } + if p.settings.Name == "" { + if p.settings.Source == nugetOrgSource { + p.settings.Name = nugetOrgName + } else { + p.settings.Name = "drone-nuget" + } + } + + // Validate the source and name + if p.settings.Name == nugetOrgName && p.settings.Source != nugetOrgSource { + return fmt.Errorf("repository named %s must use %s as its source", nugetOrgName, nugetOrgSource) + } + if p.settings.Name != nugetOrgName && p.settings.Source == nugetOrgSource { + return fmt.Errorf("source %s must use %s as its repository name", nugetOrgSource, nugetOrgName) + } + if _, err := url.Parse(p.settings.Source); err != nil { + return fmt.Errorf("could not parse source url %s: %w", p.settings.Source, err) + } + + logrus.WithFields(logrus.Fields{ + "name": p.settings.Name, + "source": p.settings.Source, + }).Info("Using NuGet repository") + + return nil +} + +// Execute provides the implementation of the plugin. +func (p *Plugin) Execute() error { + cmds := []*exec.Cmd{ + versionCmd(), + } + + if p.settings.Name != nugetOrgName { + cmds = append(cmds, addSourceCmd(p.settings.Source, p.settings.Name)) + } + + cmds = append(cmds, listSourcesCmd()) + cmds = append(cmds, pushPackageCmd(p.settings.nupkg, p.settings.Name, p.settings.APIKey)) + + return runCommands(cmds, "") +} + +// nupkgFromNuspec reads the nuspec file and determines the filename. +func nupkgFromNuspec(file string) (string, error) { + if !fileExists(file) { + return "", fmt.Errorf(".nuspec file not found at %s", file) + } + + // Read the file + nuspec, err := os.Open(file) + if err != nil { + return "", fmt.Errorf("unable to open .nuspec file %s: %w", file, err) + } + + bytes, err := ioutil.ReadAll(nuspec) + if err != nil { + return "", fmt.Errorf("unable to read .nuspec file %s: %w", file, err) + } + + // Unmarshal the file + var doc struct { + XMLName xml.Name `xml:"package"` + Metadata struct { + Name string `xml:"id"` + Version string `xml:"version"` + } `xml:"metadata"` + } + if err := xml.Unmarshal(bytes, &doc); err != nil { + return "", fmt.Errorf("unable to parse .nuspec file %s: %w", file, err) + } + + logrus.WithFields(logrus.Fields{ + "name": doc.Metadata.Name, + "version": doc.Metadata.Version, + }).Info("Found .nupsec file") + + nupkgName := fmt.Sprintf("%s.%s.nupkg", doc.Metadata.Name, doc.Metadata.Version) + + return path.Join(path.Dir(file), nupkgName), nil +} + +// fileExists determines if the file is present. +func fileExists(file string) bool { + info, err := os.Stat(file) + if os.IsNotExist(err) { + return false + } + + return !info.IsDir() +} + +// versionCmd gets the nuget version. +func versionCmd() *exec.Cmd { + return exec.Command("dotnet", "nuget", "--version") +} + +// listSourcesCmd lists the nuget repositories. +func listSourcesCmd() *exec.Cmd { + return exec.Command("dotnet", "nuget", "list", "source") +} + +// addSourceCmd creates a new nuget repository source. +func addSourceCmd(source, name string) *exec.Cmd { + return exec.Command("dotnet", "nuget", "add", "source", source, "--name", name) +} + +// pushPackageCmd pushes a package to the nuget repository. +func pushPackageCmd(path, name, key string) *exec.Cmd { + return exec.Command("dotnet", "nuget", "push", path, "--source", name, "--api-key", key) +} + +// trace writes each command to standard error (preceded by a ‘$ ’) before it +// is executed. Used for debugging your build. +func trace(cmd *exec.Cmd) { + fmt.Fprintf(os.Stdout, "+ %s\n", strings.Join(cmd.Args, " ")) +} + +// runCommands executes the list of cmds in the given directory. +func runCommands(cmds []*exec.Cmd, dir string) error { + for _, cmd := range cmds { + err := runCommand(cmd, dir) + + if err != nil { + return err + } + } + + return nil +} + +// runCommand executes a cmd in the given directory. +func runCommand(cmd *exec.Cmd, dir string) error { + cmd.Stdout = os.Stdout + cmd.Stderr = os.Stderr + cmd.Dir = dir + trace(cmd) + + return cmd.Run() +} diff --git a/plugin/impl_test.go b/plugin/impl_test.go new file mode 100644 index 0000000..badfaa0 --- /dev/null +++ b/plugin/impl_test.go @@ -0,0 +1,18 @@ +// Copyright (c) 2020, the Drone Plugins project authors. +// Please see the AUTHORS file for details. All rights reserved. +// Use of this source code is governed by an Apache 2.0 license that can be +// found in the LICENSE file. + +package plugin + +import ( + "testing" +) + +func TestValidate(t *testing.T) { + t.Skip() +} + +func TestExecute(t *testing.T) { + t.Skip() +} diff --git a/plugin/plugin.go b/plugin/plugin.go new file mode 100644 index 0000000..bb8248b --- /dev/null +++ b/plugin/plugin.go @@ -0,0 +1,26 @@ +// Copyright (c) 2020, the Drone Plugins project authors. +// Please see the AUTHORS file for details. All rights reserved. +// Use of this source code is governed by an Apache 2.0 license that can be +// found in the LICENSE file. + +package plugin + +import ( + "github.com/drone-plugins/drone-plugin-lib/drone" +) + +// Plugin implements drone.Plugin to provide the plugin implementation. +type Plugin struct { + settings Settings + pipeline drone.Pipeline + network drone.Network +} + +// New initializes a plugin from the given Settings, Pipeline, and Network. +func New(settings Settings, pipeline drone.Pipeline, network drone.Network) drone.Plugin { + return &Plugin{ + settings: settings, + pipeline: pipeline, + network: network, + } +} diff --git a/plugin/plugin_test.go b/plugin/plugin_test.go new file mode 100644 index 0000000..3cb461f --- /dev/null +++ b/plugin/plugin_test.go @@ -0,0 +1,14 @@ +// Copyright (c) 2020, the Drone Plugins project authors. +// Please see the AUTHORS file for details. All rights reserved. +// Use of this source code is governed by an Apache 2.0 license that can be +// found in the LICENSE file. + +package plugin + +import ( + "testing" +) + +func TestPlugin(t *testing.T) { + t.Skip() +} diff --git a/renovate.json b/renovate.json deleted file mode 100644 index 9980624..0000000 --- a/renovate.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "extends": [ - "config:base" - ], - "docker": { - "fileMatch": [ - "/docker/Dockerfile" - ] - }, - "labels": [ - "renovate" - ] -}