From 41ecb137d0a4c7323d44b904071b601ce2e36a79 Mon Sep 17 00:00:00 2001 From: Thomas Boerger Date: Thu, 14 Feb 2019 20:14:11 +0100 Subject: [PATCH 1/7] Drop renovate config, it is simply too noisy --- renovate.json | 13 ------------- 1 file changed, 13 deletions(-) delete mode 100644 renovate.json 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" - ] -} From fb94247a080c2bcb9ad7a1bffb9ae4deb337df07 Mon Sep 17 00:00:00 2001 From: Thomas Boerger Date: Fri, 15 Feb 2019 10:25:53 +0100 Subject: [PATCH 2/7] Add a reliable version and integrate libsonnet definition --- .drone.jsonnet | 177 +------------ .drone.windows.jsonnet | 9 + .drone.windows.yml | 234 ++++++++++++++++-- .drone.yml | 88 ++++--- ....windows.amd64 => Dockerfile.windows.1803} | 6 +- docker/Dockerfile.windows.1809 | 10 + docker/manifest.tmpl | 10 +- main.go | 5 +- pipeline.libsonnet | 204 +++++++++++++++ 9 files changed, 517 insertions(+), 226 deletions(-) create mode 100644 .drone.windows.jsonnet rename docker/{Dockerfile.windows.amd64 => Dockerfile.windows.1803} (57%) create mode 100644 docker/Dockerfile.windows.1809 create mode 100644 pipeline.libsonnet diff --git a/.drone.jsonnet b/.drone.jsonnet index ff4d422..b2cbfe4 100644 --- a/.drone.jsonnet +++ b/.drone.jsonnet @@ -1,169 +1,14 @@ -local PipelineTesting = { - kind: "pipeline", - name: "testing", - platform: { - os: "linux", - arch: "amd64", - }, - steps: [ - { - name: "vet", - image: "golang:1.11", - pull: "always", - environment: { - GO111MODULE: "on", - }, - commands: [ - "go vet ./...", - ], - }, - { - name: "test", - image: "golang:1.11", - pull: "always", - environment: { - GO111MODULE: "on", - }, - commands: [ - "go test -cover ./...", - ], - }, - ], - trigger: { - branch: [ "master" ], - }, -}; - -local PipelineBuild(os="linux", arch="amd64") = { - kind: "pipeline", - name: os + "-" + arch, - platform: { - os: os, - arch: arch, - }, - steps: [ - { - name: "build-push", - image: "golang:1.11", - pull: "always", - environment: { - CGO_ENABLED: "0", - GO111MODULE: "on", - }, - commands: [ - "go build -v -ldflags \"-X main.build=${DRONE_BUILD_NUMBER}\" -a -o release/" + os + "/" + arch + "/drone-gitea-release", - ], - when: { - event: [ "push", "pull_request" ], - }, - }, - { - name: "build-tag", - image: "golang:1.11", - pull: "always", - environment: { - CGO_ENABLED: "0", - GO111MODULE: "on", - }, - commands: [ - "go build -v -ldflags \"-X main.version=${DRONE_TAG##v} -X main.build=${DRONE_BUILD_NUMBER}\" -a -o release/" + os + "/" + arch + "/drone-gitea-release", - ], - when: { - event: [ "tag" ], - }, - }, - { - name: "executable", - image: "golang:1.11", - pull: "always", - commands: [ - "./release/" + os + "/" + arch + "/drone-gitea-release --help", - ], - }, - { - name: "dryrun", - image: "plugins/docker:" + os + "-" + arch, - pull: "always", - settings: { - dry_run: true, - tags: os + "-" + arch, - dockerfile: "docker/Dockerfile." + os + "." + arch, - repo: "plugins/gitea-release", - username: { "from_secret": "docker_username" }, - password: { "from_secret": "docker_password" }, - }, - when: { - event: [ "pull_request" ], - }, - }, - { - name: "publish", - image: "plugins/docker:" + os + "-" + arch, - pull: "always", - settings: { - auto_tag: true, - auto_tag_suffix: os + "-" + arch, - dockerfile: "docker/Dockerfile." + os + "." + arch, - repo: "plugins/gitea-release", - username: { "from_secret": "docker_username" }, - password: { "from_secret": "docker_password" }, - }, - when: { - event: [ "push", "tag" ], - }, - }, - ], - depends_on: [ - "testing", - ], - trigger: { - branch: [ "master" ], - }, -}; - -local PipelineNotifications = { - kind: "pipeline", - name: "notifications", - platform: { - os: "linux", - arch: "amd64", - }, - steps: [ - { - name: "manifest", - image: "plugins/manifest:1", - pull: "always", - settings: { - username: { "from_secret": "docker_username" }, - password: { "from_secret": "docker_password" }, - spec: "docker/manifest.tmpl", - ignore_missing: true, - }, - }, - { - name: "microbadger", - image: "plugins/webhook:1", - pull: "always", - settings: { - url: { "from_secret": "microbadger_url" }, - }, - }, - ], - depends_on: [ - "linux-amd64", - "linux-arm64", - "linux-arm", - ], - trigger: { - branch: [ "master" ], - event: [ "push", "tag" ], - }, -}; +local pipeline = import 'pipeline.libsonnet'; +local name = 'drone-gitea-release'; [ - PipelineTesting, - PipelineBuild("linux", "amd64"), - PipelineBuild("linux", "arm64"), - PipelineBuild("linux", "arm"), - PipelineNotifications, + pipeline.test('linux', 'amd64'), + pipeline.build(name, 'linux', 'amd64'), + pipeline.build(name, 'linux', 'arm64'), + pipeline.build(name, 'linux', 'arm'), + pipeline.notifications(depends_on=[ + 'linux-amd64', + 'linux-arm64', + 'linux-arm', + ]), ] diff --git a/.drone.windows.jsonnet b/.drone.windows.jsonnet new file mode 100644 index 0000000..7e2bdfe --- /dev/null +++ b/.drone.windows.jsonnet @@ -0,0 +1,9 @@ +local pipeline = import 'pipeline.libsonnet'; +local name = 'drone-gitea-release'; + +[ + pipeline.test('windows', 'amd64', '1803'), + pipeline.build(name, 'windows', 'amd64', '1803'), + pipeline.build(name, 'windows', 'amd64', '1809'), + pipeline.notifications('windows', 'amd64', '1809', ['windows-1803', 'windows-1809']), +] diff --git a/.drone.windows.yml b/.drone.windows.yml index 2b0d462..0999bbb 100644 --- a/.drone.windows.yml +++ b/.drone.windows.yml @@ -1,30 +1,73 @@ --- kind: pipeline -name: windows-amd64 +name: testing platform: os: windows arch: amd64 + version: 1803 + +steps: +- name: vet + pull: always + image: golang:1.11-windowsservercore-1803 + commands: + - go vet ./... + environment: + GO111MODULE: on + volumes: + - name: gopath + path: C:\\gopath + +- name: test + pull: always + image: golang:1.11-windowsservercore-1803 + commands: + - go test -cover ./... + environment: + GO111MODULE: on + volumes: + - name: gopath + path: C:\\gopath + +volumes: +- name: gopath + temp: {} + +trigger: + ref: + - refs/heads/master + - "refs/tags/**" + - "refs/pull/**" + +--- +kind: pipeline +name: windows-1803 + +platform: + os: windows + arch: amd64 + version: 1803 steps: - name: build-push pull: always - image: golang:1.11 + image: golang:1.11-windowsservercore-1803 commands: - - "go build -v -ldflags \"-X main.build=${DRONE_BUILD_NUMBER}\" -a -o release/windows/amd64/drone-gitea-release" + - "go build -v -ldflags \"-X main.version=${DRONE_COMMIT_SHA:0:8}\" -a -tags netgo -o release/windows/amd64/drone-gitea-release.exe" environment: CGO_ENABLED: 0 GO111MODULE: on when: event: - - push - - pull_request + exclude: + - tag - name: build-tag pull: always - image: golang:1.11 + image: golang:1.11-windowsservercore-1803 commands: - - "go build -v -ldflags \"-X main.version=${DRONE_TAG##v} -X main.build=${DRONE_BUILD_NUMBER}\" -a -o release/windows/amd64/drone-gitea-release" + - "go build -v -ldflags \"-X main.version=${DRONE_TAG##v}\" -a -tags netgo -o release/windows/amd64/drone-gitea-release.exe" environment: CGO_ENABLED: 0 GO111MODULE: on @@ -34,43 +77,196 @@ steps: - name: executable pull: always - image: golang:1.11 + image: golang:1.11-windowsservercore-1803 commands: - - ./release/windows/amd64/drone-gitea-release --help + - ./release/windows/amd64/drone-gitea-release.exe --help - name: dryrun pull: always - image: plugins/docker:windows-amd64 + image: plugins/docker:windows-1803 settings: - dockerfile: docker/Dockerfile.windows.amd64 + daemon_off: true + dockerfile: docker/Dockerfile.windows.1803 dry_run: true password: from_secret: docker_password repo: plugins/gitea-release - tags: windows-amd64 + tags: windows-1803 username: from_secret: docker_username + volumes: + - name: docker_pipe + path: \\\\.\\pipe\\docker_engine when: event: - pull_request - name: publish pull: always - image: plugins/docker:windows-amd64 + image: plugins/docker:windows-1803 settings: auto_tag: true - auto_tag_suffix: windows-amd64 - dockerfile: docker/Dockerfile.windows.amd64 + auto_tag_suffix: windows-1803 + daemon_off: true + dockerfile: docker/Dockerfile.windows.1803 password: from_secret: docker_password repo: plugins/gitea-release username: from_secret: docker_username + volumes: + - name: docker_pipe + path: \\\\.\\pipe\\docker_engine when: event: - - push - - tag + exclude: + - pull_request + +volumes: +- name: docker_pipe + host: + path: \\\\.\\pipe\\docker_engine trigger: - branch: - - master + ref: + - refs/heads/master + - "refs/tags/**" + - "refs/pull/**" + +depends_on: +- testing + +--- +kind: pipeline +name: windows-1809 + +platform: + os: windows + arch: amd64 + version: 1809 + +steps: +- name: build-push + pull: always + image: golang:1.11-windowsservercore-1809 + commands: + - "go build -v -ldflags \"-X main.version=${DRONE_COMMIT_SHA:0:8}\" -a -tags netgo -o release/windows/amd64/drone-gitea-release.exe" + environment: + CGO_ENABLED: 0 + GO111MODULE: on + when: + event: + exclude: + - tag + +- name: build-tag + pull: always + image: golang:1.11-windowsservercore-1809 + commands: + - "go build -v -ldflags \"-X main.version=${DRONE_TAG##v}\" -a -tags netgo -o release/windows/amd64/drone-gitea-release.exe" + environment: + CGO_ENABLED: 0 + GO111MODULE: on + when: + event: + - tag + +- name: executable + pull: always + image: golang:1.11-windowsservercore-1809 + commands: + - ./release/windows/amd64/drone-gitea-release.exe --help + +- name: dryrun + pull: always + image: plugins/docker:windows-1809 + settings: + daemon_off: true + dockerfile: docker/Dockerfile.windows.1809 + dry_run: true + password: + from_secret: docker_password + repo: plugins/gitea-release + tags: windows-1809 + username: + from_secret: docker_username + volumes: + - name: docker_pipe + path: \\\\.\\pipe\\docker_engine + when: + event: + - pull_request + +- name: publish + pull: always + image: plugins/docker:windows-1809 + settings: + auto_tag: true + auto_tag_suffix: windows-1809 + daemon_off: true + dockerfile: docker/Dockerfile.windows.1809 + password: + from_secret: docker_password + repo: plugins/gitea-release + username: + from_secret: docker_username + volumes: + - name: docker_pipe + path: \\\\.\\pipe\\docker_engine + when: + event: + exclude: + - pull_request + +volumes: +- name: docker_pipe + host: + path: \\\\.\\pipe\\docker_engine + +trigger: + ref: + - refs/heads/master + - "refs/tags/**" + - "refs/pull/**" + +depends_on: +- testing + +--- +kind: pipeline +name: notifications + +platform: + os: windows + arch: amd64 + version: 1809 + +steps: +- name: manifest + pull: always + image: plugins/manifest + settings: + ignore_missing: true + password: + from_secret: docker_password + spec: docker/manifest.tmpl + username: + from_secret: docker_username + +- name: microbadger + pull: always + image: plugins/webhook + settings: + url: + from_secret: microbadger_url + +trigger: + ref: + - refs/heads/master + - "refs/tags/**" + +depends_on: +- windows-1803 +- windows-1809 + +... diff --git a/.drone.yml b/.drone.yml index 16e8c2c..919617b 100644 --- a/.drone.yml +++ b/.drone.yml @@ -14,6 +14,9 @@ steps: - go vet ./... environment: GO111MODULE: on + volumes: + - name: gopath + path: /go - name: test pull: always @@ -22,10 +25,19 @@ steps: - go test -cover ./... environment: GO111MODULE: on + volumes: + - name: gopath + path: /go + +volumes: +- name: gopath + temp: {} trigger: - branch: - - master + ref: + - refs/heads/master + - "refs/tags/**" + - "refs/pull/**" --- kind: pipeline @@ -40,20 +52,20 @@ steps: pull: always image: golang:1.11 commands: - - "go build -v -ldflags \"-X main.build=${DRONE_BUILD_NUMBER}\" -a -o release/linux/amd64/drone-gitea-release" + - "go build -v -ldflags \"-X main.version=${DRONE_COMMIT_SHA:0:8}\" -a -tags netgo -o release/linux/amd64/drone-gitea-release" environment: CGO_ENABLED: 0 GO111MODULE: on when: event: - - push - - pull_request + exclude: + - tag - name: build-tag pull: always image: golang:1.11 commands: - - "go build -v -ldflags \"-X main.version=${DRONE_TAG##v} -X main.build=${DRONE_BUILD_NUMBER}\" -a -o release/linux/amd64/drone-gitea-release" + - "go build -v -ldflags \"-X main.version=${DRONE_TAG##v}\" -a -tags netgo -o release/linux/amd64/drone-gitea-release" environment: CGO_ENABLED: 0 GO111MODULE: on @@ -71,6 +83,7 @@ steps: pull: always image: plugins/docker:linux-amd64 settings: + daemon_off: false dockerfile: docker/Dockerfile.linux.amd64 dry_run: true password: @@ -89,6 +102,7 @@ steps: settings: auto_tag: true auto_tag_suffix: linux-amd64 + daemon_off: false dockerfile: docker/Dockerfile.linux.amd64 password: from_secret: docker_password @@ -97,12 +111,14 @@ steps: from_secret: docker_username when: event: - - push - - tag + exclude: + - pull_request trigger: - branch: - - master + ref: + - refs/heads/master + - "refs/tags/**" + - "refs/pull/**" depends_on: - testing @@ -120,20 +136,20 @@ steps: pull: always image: golang:1.11 commands: - - "go build -v -ldflags \"-X main.build=${DRONE_BUILD_NUMBER}\" -a -o release/linux/arm64/drone-gitea-release" + - "go build -v -ldflags \"-X main.version=${DRONE_COMMIT_SHA:0:8}\" -a -tags netgo -o release/linux/arm64/drone-gitea-release" environment: CGO_ENABLED: 0 GO111MODULE: on when: event: - - push - - pull_request + exclude: + - tag - name: build-tag pull: always image: golang:1.11 commands: - - "go build -v -ldflags \"-X main.version=${DRONE_TAG##v} -X main.build=${DRONE_BUILD_NUMBER}\" -a -o release/linux/arm64/drone-gitea-release" + - "go build -v -ldflags \"-X main.version=${DRONE_TAG##v}\" -a -tags netgo -o release/linux/arm64/drone-gitea-release" environment: CGO_ENABLED: 0 GO111MODULE: on @@ -151,6 +167,7 @@ steps: pull: always image: plugins/docker:linux-arm64 settings: + daemon_off: false dockerfile: docker/Dockerfile.linux.arm64 dry_run: true password: @@ -169,6 +186,7 @@ steps: settings: auto_tag: true auto_tag_suffix: linux-arm64 + daemon_off: false dockerfile: docker/Dockerfile.linux.arm64 password: from_secret: docker_password @@ -177,12 +195,14 @@ steps: from_secret: docker_username when: event: - - push - - tag + exclude: + - pull_request trigger: - branch: - - master + ref: + - refs/heads/master + - "refs/tags/**" + - "refs/pull/**" depends_on: - testing @@ -200,20 +220,20 @@ steps: pull: always image: golang:1.11 commands: - - "go build -v -ldflags \"-X main.build=${DRONE_BUILD_NUMBER}\" -a -o release/linux/arm/drone-gitea-release" + - "go build -v -ldflags \"-X main.version=${DRONE_COMMIT_SHA:0:8}\" -a -tags netgo -o release/linux/arm/drone-gitea-release" environment: CGO_ENABLED: 0 GO111MODULE: on when: event: - - push - - pull_request + exclude: + - tag - name: build-tag pull: always image: golang:1.11 commands: - - "go build -v -ldflags \"-X main.version=${DRONE_TAG##v} -X main.build=${DRONE_BUILD_NUMBER}\" -a -o release/linux/arm/drone-gitea-release" + - "go build -v -ldflags \"-X main.version=${DRONE_TAG##v}\" -a -tags netgo -o release/linux/arm/drone-gitea-release" environment: CGO_ENABLED: 0 GO111MODULE: on @@ -231,6 +251,7 @@ steps: pull: always image: plugins/docker:linux-arm settings: + daemon_off: false dockerfile: docker/Dockerfile.linux.arm dry_run: true password: @@ -249,6 +270,7 @@ steps: settings: auto_tag: true auto_tag_suffix: linux-arm + daemon_off: false dockerfile: docker/Dockerfile.linux.arm password: from_secret: docker_password @@ -257,12 +279,14 @@ steps: from_secret: docker_username when: event: - - push - - tag + exclude: + - pull_request trigger: - branch: - - master + ref: + - refs/heads/master + - "refs/tags/**" + - "refs/pull/**" depends_on: - testing @@ -278,7 +302,7 @@ platform: steps: - name: manifest pull: always - image: plugins/manifest:1 + image: plugins/manifest settings: ignore_missing: true password: @@ -289,17 +313,15 @@ steps: - name: microbadger pull: always - image: plugins/webhook:1 + image: plugins/webhook settings: url: from_secret: microbadger_url trigger: - branch: - - master - event: - - push - - tag + ref: + - refs/heads/master + - "refs/tags/**" depends_on: - linux-amd64 diff --git a/docker/Dockerfile.windows.amd64 b/docker/Dockerfile.windows.1803 similarity index 57% rename from docker/Dockerfile.windows.amd64 rename to docker/Dockerfile.windows.1803 index b7b5f71..c0dca72 100644 --- a/docker/Dockerfile.windows.amd64 +++ b/docker/Dockerfile.windows.1803 @@ -1,10 +1,10 @@ # escape=` -FROM plugins/base:windows-amd64 +FROM plugins/base:windows-1803 LABEL maintainer="Drone.IO Community " ` org.label-schema.name="Drone Gitea Release" ` org.label-schema.vendor="Drone.IO Community" ` org.label-schema.schema-version="1.0" -ADD release\drone-gitea-release.exe c:\drone-gitea-release.exe -ENTRYPOINT [ "c:\\drone-gitea-release.exe" ] +ADD release/windows/amd64/drone-gitea-release.exe C:/bin/drone-gitea-release.exe +ENTRYPOINT [ "C:\\bin\\drone-gitea-release.exe" ] diff --git a/docker/Dockerfile.windows.1809 b/docker/Dockerfile.windows.1809 new file mode 100644 index 0000000..7afe6fb --- /dev/null +++ b/docker/Dockerfile.windows.1809 @@ -0,0 +1,10 @@ +# escape=` +FROM plugins/base:windows-1809 + +LABEL maintainer="Drone.IO Community " ` + org.label-schema.name="Drone Gitea Release" ` + org.label-schema.vendor="Drone.IO Community" ` + org.label-schema.schema-version="1.0" + +ADD release/windows/amd64/drone-gitea-release.exe C:/bin/drone-gitea-release.exe +ENTRYPOINT [ "C:\\bin\\drone-gitea-release.exe" ] diff --git a/docker/manifest.tmpl b/docker/manifest.tmpl index 5523b26..9a0b6e0 100644 --- a/docker/manifest.tmpl +++ b/docker/manifest.tmpl @@ -24,8 +24,14 @@ manifests: os: linux variant: v7 - - image: plugins/gitea-release:{{#if build.tag}}{{trimPrefix build.tag "v"}}-{{/if}}windows-amd64 + image: plugins/gitea-release:{{#if build.tag}}{{trimPrefix build.tag "v"}}-{{/if}}windows-1803 platform: architecture: amd64 os: windows - variant: 1809 + version: 1803 + - + image: plugins/gitea-release:{{#if build.tag}}{{trimPrefix build.tag "v"}}-{{/if}}windows-1809 + platform: + architecture: amd64 + os: windows + version: 1809 diff --git a/main.go b/main.go index 6205395..31ccc3e 100644 --- a/main.go +++ b/main.go @@ -10,16 +10,15 @@ import ( ) var ( - version = "0.0.0" - build = "0" + version = "unknown" ) func main() { app := cli.NewApp() app.Name = "gitea-release plugin" app.Usage = "gitea-release plugin" - app.Version = fmt.Sprintf("%s+%s", version, build) app.Action = run + app.Version = version app.Flags = []cli.Flag{ cli.StringFlag{ Name: "api-key", diff --git a/pipeline.libsonnet b/pipeline.libsonnet new file mode 100644 index 0000000..aab20bd --- /dev/null +++ b/pipeline.libsonnet @@ -0,0 +1,204 @@ +local windows_pipe = '\\\\\\\\.\\\\pipe\\\\docker_engine'; +local windows_pipe_volume = 'docker_pipe'; +local test_pipeline_name = 'testing'; + +local windows(os) = os == 'windows'; + +local golang_image(os, version) = + 'golang:' + '1.11' + if windows(os) then '-windowsservercore-' + version else ''; + +{ + test(os='linux', arch='amd64', version=''):: + local is_windows = windows(os); + local golang = golang_image(os, version); + local volumes = if is_windows then [{name: 'gopath', path: 'C:\\\\gopath'}] else [{name: 'gopath', path: '/go',}]; + { + kind: 'pipeline', + name: test_pipeline_name, + platform: { + os: os, + arch: arch, + version: if std.length(version) > 0 then version, + }, + steps: [ + { + name: 'vet', + image: golang, + pull: 'always', + environment: { + GO111MODULE: 'on', + }, + commands: [ + 'go vet ./...', + ], + volumes: volumes, + }, + { + name: 'test', + image: golang, + pull: 'always', + environment: { + GO111MODULE: 'on', + }, + commands: [ + 'go test -cover ./...', + ], + volumes: volumes, + }, + ], + trigger: { + ref: [ + 'refs/heads/master', + 'refs/tags/**', + 'refs/pull/**', + ], + }, + volumes: [{name: 'gopath', temp: {}}] + }, + + build(name, os='linux', arch='amd64', version=''):: + local is_windows = windows(os); + local tag = if is_windows then os + '-' + version else os + '-' + arch; + local file_suffix = std.strReplace(tag, '-', '.'); + local volumes = if is_windows then [{ name: windows_pipe_volume, path: windows_pipe }] else []; + local golang = golang_image(os, version); + local plugin_repo = 'plugins/' + std.splitLimit(name, '-', 1)[1]; + local extension = if is_windows then '.exe' else ''; + { + kind: 'pipeline', + name: tag, + platform: { + os: os, + arch: arch, + version: if std.length(version) > 0 then version, + }, + steps: [ + { + name: 'build-push', + image: golang, + pull: 'always', + environment: { + CGO_ENABLED: '0', + GO111MODULE: 'on', + }, + commands: [ + 'go build -v -ldflags "-X main.version=${DRONE_COMMIT_SHA:0:8}" -a -tags netgo -o release/' + os + '/' + arch + '/' + name + extension, + ], + when: { + event: { + exclude: ['tag'], + }, + }, + }, + { + name: 'build-tag', + image: golang, + pull: 'always', + environment: { + CGO_ENABLED: '0', + GO111MODULE: 'on', + }, + commands: [ + 'go build -v -ldflags "-X main.version=${DRONE_TAG##v}" -a -tags netgo -o release/' + os + '/' + arch + '/' + name + extension, + ], + when: { + event: ['tag'], + }, + }, + { + name: 'executable', + image: golang, + pull: 'always', + commands: [ + './release/' + os + '/' + arch + '/' + name + extension + ' --help', + ], + }, + { + name: 'dryrun', + image: 'plugins/docker:' + tag, + pull: 'always', + settings: { + dry_run: true, + tags: tag, + dockerfile: 'docker/Dockerfile.' + file_suffix, + daemon_off: if is_windows then 'true' else 'false', + repo: plugin_repo, + username: { from_secret: 'docker_username' }, + password: { from_secret: 'docker_password' }, + }, + volumes: if std.length(volumes) > 0 then volumes, + when: { + event: ['pull_request'], + }, + }, + { + name: 'publish', + image: 'plugins/docker:' + tag, + pull: 'always', + settings: { + auto_tag: true, + auto_tag_suffix: tag, + daemon_off: if is_windows then 'true' else 'false', + dockerfile: 'docker/Dockerfile.' + file_suffix, + repo: plugin_repo, + username: { from_secret: 'docker_username' }, + password: { from_secret: 'docker_password' }, + }, + volumes: if std.length(volumes) > 0 then volumes, + when: { + event: { + exclude: ['pull_request'], + }, + }, + }, + ], + trigger: { + ref: [ + 'refs/heads/master', + 'refs/tags/**', + 'refs/pull/**', + ], + }, + depends_on: [test_pipeline_name], + volumes: if is_windows then [{ name: windows_pipe_volume, host: { path: windows_pipe } }], + }, + + notifications(os='linux', arch='amd64', version='', depends_on=[]):: + { + kind: 'pipeline', + name: 'notifications', + platform: { + os: os, + arch: arch, + version: if std.length(version) > 0 then version, + }, + steps: [ + { + name: 'manifest', + image: 'plugins/manifest', + pull: 'always', + settings: { + 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: { + url: { from_secret: 'microbadger_url' }, + }, + }, + ], + trigger: { + ref: [ + 'refs/heads/master', + 'refs/tags/**', + ], + }, + depends_on: depends_on, + }, +} From f67c35dbc3b112c755d4c7c523aee28d4080ec36 Mon Sep 17 00:00:00 2001 From: Thomas Boerger Date: Fri, 15 Feb 2019 11:58:33 +0100 Subject: [PATCH 3/7] Unified documentation and readme --- README.md | 40 ++++++++++++++++++++++++++++++++++------ 1 file changed, 34 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 1945677..ba351ff 100644 --- a/README.md +++ b/README.md @@ -8,15 +8,43 @@ [![Go Doc](https://godoc.org/github.com/drone-plugins/drone-gitea-release?status.svg)](http://godoc.org/github.com/drone-plugins/drone-gitea-release) [![Go Report](https://goreportcard.com/badge/github.com/drone-plugins/drone-gitea-release)](https://goreportcard.com/report/github.com/drone-plugins/drone-gitea-release) -Drone plugin to publish files and artifacts to Gitea Release. - -**Note: This plugin requires Gitea 1.5 or newer.** +Drone plugin to publish files and artifacts to Gitea 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-gitea-release/). ## Build -Build the binary with the following commands: +Build the binary with the following command: +```console +export GOOS=linux +export GOARCH=amd64 +export CGO_ENABLED=0 +export GO111MODULE=on + +go build -v -a -tags netgo -o release/linux/amd64/drone-gitea-release ``` -GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -a -tags netgo -o release/linux/amd64/drone-gitea-release -docker build --rm -t plugins/gitea-release . + +## Docker + +Build the Docker image with the following command: + +```console +docker build \ + --label org.label-schema.build-date=$(date -u +"%Y-%m-%dT%H:%M:%SZ") \ + --label org.label-schema.vcs-ref=$(git rev-parse --short HEAD) \ + --file docker/Dockerfile.linux.amd64 --tag plugins/gitea-release . +``` + +## Usage + +```console +docker run --rm \ + -e PLUGIN_BASE_URL=https://try.gitea.io \ + -e PLUGIN_API_KEY=your-api-key \ + -e PLUGIN_FILES=build/* \ + -e DRONE_REPO_OWNER=gitea \ + -e DRONE_REPO_NAME=test \ + -e DRONE_BUILD_EVENT=tag \ + -v $(pwd):$(pwd) \ + -w $(pwd) \ + plugins/gitea-release ``` From 4a158980a4f7b06fc5031ece60c3cb81f0b97e05 Mon Sep 17 00:00:00 2001 From: Thomas Boerger Date: Mon, 18 Feb 2019 23:14:31 +0100 Subject: [PATCH 4/7] Replace godep with gomod --- Gopkg.lock | 48 ------------------------------------------------ Gopkg.toml | 19 ------------------- go.mod | 10 ++++++++++ go.sum | 12 ++++++++++++ 4 files changed, 22 insertions(+), 67 deletions(-) delete mode 100644 Gopkg.lock delete mode 100644 Gopkg.toml create mode 100644 go.mod create mode 100644 go.sum diff --git a/Gopkg.lock b/Gopkg.lock deleted file mode 100644 index cf197c8..0000000 --- a/Gopkg.lock +++ /dev/null @@ -1,48 +0,0 @@ -# This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'. - - -[[projects]] - branch = "master" - name = "code.gitea.io/sdk" - packages = ["gitea"] - revision = "fa91af7569e6ba34bfa382109847cbc79c3fdad8" - -[[projects]] - name = "github.com/Sirupsen/logrus" - packages = ["."] - revision = "c155da19408a8799da419ed3eeb0cb5db0ad5dbc" - version = "v1.0.5" - -[[projects]] - name = "github.com/joho/godotenv" - packages = ["."] - revision = "a79fa1e548e2c689c241d10173efd51e5d689d5b" - version = "v1.2.0" - -[[projects]] - name = "github.com/urfave/cli" - packages = ["."] - revision = "cfb38830724cc34fedffe9a2a29fb54fa9169cd1" - version = "v1.20.0" - -[[projects]] - branch = "master" - name = "golang.org/x/crypto" - packages = ["ssh/terminal"] - revision = "21652f85b0fdddb6c2b6b77a5beca5c5a908174a" - -[[projects]] - branch = "master" - name = "golang.org/x/sys" - packages = [ - "unix", - "windows" - ] - revision = "cc7307a45468e49eaf2997c890f14aa03a26917b" - -[solve-meta] - analyzer-name = "dep" - analyzer-version = 1 - inputs-digest = "7cb00c5086c5910b3f5a952158b3c99e8a3c41acb235f0591f74545909a00d34" - solver-name = "gps-cdcl" - solver-version = 1 diff --git a/Gopkg.toml b/Gopkg.toml deleted file mode 100644 index 609d659..0000000 --- a/Gopkg.toml +++ /dev/null @@ -1,19 +0,0 @@ -[[constraint]] - branch = "master" - name = "code.gitea.io/sdk" - -[[constraint]] - name = "github.com/Sirupsen/logrus" - version = "1.0.5" - -[[constraint]] - name = "github.com/joho/godotenv" - version = "1.2.0" - -[[constraint]] - name = "github.com/urfave/cli" - version = "1.20.0" - -[prune] - go-tests = true - unused-packages = true diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..ad5a655 --- /dev/null +++ b/go.mod @@ -0,0 +1,10 @@ +module github.com/drone-plugins/drone-gitea-release + +require ( + code.gitea.io/sdk v0.0.0-20180306012245-fa91af7569e6 + github.com/Sirupsen/logrus v1.0.5 + github.com/joho/godotenv v1.2.0 + github.com/urfave/cli v1.20.0 + golang.org/x/crypto v0.0.0-20180314180259-21652f85b0fd + golang.org/x/sys v0.0.0-20180315095008-cc7307a45468 +) diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..680c9ea --- /dev/null +++ b/go.sum @@ -0,0 +1,12 @@ +code.gitea.io/sdk v0.0.0-20180306012245-fa91af7569e6 h1:+7v/mFO/rvSm3V7eTMuO7ZovUE9fGDHdZPOGrGHg6G0= +code.gitea.io/sdk v0.0.0-20180306012245-fa91af7569e6/go.mod h1:5bZt0dRznpn2JysytQnV0yCru3FwDv9O5G91jo+lDAk= +github.com/Sirupsen/logrus v1.0.5 h1:447dy9LxSj+Iaa2uN3yoFHOzU9yJcJYiQPtNz8OXtv0= +github.com/Sirupsen/logrus v1.0.5/go.mod h1:rmk17hk6i8ZSAJkSDa7nOxamrG+SP4P0mm+DAvExv4U= +github.com/joho/godotenv v1.2.0 h1:vGTvz69FzUFp+X4/bAkb0j5BoLC+9bpqTWY8mjhA9pc= +github.com/joho/godotenv v1.2.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqxOKXbg= +github.com/urfave/cli v1.20.0 h1:fDqGv3UG/4jbVl/QkFwEdddtEDjh/5Ov6X+0B/3bPaw= +github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA= +golang.org/x/crypto v0.0.0-20180314180259-21652f85b0fd h1:cC/2DaX1wcQTuG22GhVYD0kedx0WJnOgKmrxsb3yS+4= +golang.org/x/crypto v0.0.0-20180314180259-21652f85b0fd/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= +golang.org/x/sys v0.0.0-20180315095008-cc7307a45468 h1:gA/WTjA7p666MDp8dc2JZcAaprujwHmc/1rj+E64iBA= +golang.org/x/sys v0.0.0-20180315095008-cc7307a45468/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= From ad43516f458a12dac79c925c67f494850ce5f985 Mon Sep 17 00:00:00 2001 From: Thomas Boerger Date: Mon, 18 Feb 2019 23:47:39 +0100 Subject: [PATCH 5/7] Drop import of unused fmt package --- main.go | 1 - 1 file changed, 1 deletion(-) diff --git a/main.go b/main.go index 31ccc3e..be98125 100644 --- a/main.go +++ b/main.go @@ -1,7 +1,6 @@ package main import ( - "fmt" "os" "github.com/Sirupsen/logrus" From 39b569dc522db612d64431c27c3eab0b06b700bd Mon Sep 17 00:00:00 2001 From: Thomas Boerger Date: Mon, 25 Feb 2019 22:20:12 +0100 Subject: [PATCH 6/7] Fix manifest template helper --- docker/manifest.tmpl | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/docker/manifest.tmpl b/docker/manifest.tmpl index 9a0b6e0..2ae94ea 100644 --- a/docker/manifest.tmpl +++ b/docker/manifest.tmpl @@ -1,4 +1,4 @@ -image: plugins/gitea-release:{{#if build.tag}}{{trimPrefix build.tag "v"}}{{else}}latest{{/if}} +image: plugins/gitea-release:{{#if build.tag}}{{trimPrefix "v" build.tag}}{{else}}latest{{/if}} {{#if build.tags}} tags: {{#each build.tags}} @@ -7,30 +7,30 @@ tags: {{/if}} manifests: - - image: plugins/gitea-release:{{#if build.tag}}{{trimPrefix build.tag "v"}}-{{/if}}linux-amd64 + image: plugins/gitea-release:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}linux-amd64 platform: architecture: amd64 os: linux - - image: plugins/gitea-release:{{#if build.tag}}{{trimPrefix build.tag "v"}}-{{/if}}linux-arm64 + image: plugins/gitea-release:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}linux-arm64 platform: architecture: arm64 os: linux variant: v8 - - image: plugins/gitea-release:{{#if build.tag}}{{trimPrefix build.tag "v"}}-{{/if}}linux-arm + image: plugins/gitea-release:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}linux-arm platform: architecture: arm os: linux variant: v7 - - image: plugins/gitea-release:{{#if build.tag}}{{trimPrefix build.tag "v"}}-{{/if}}windows-1803 + image: plugins/gitea-release:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}windows-1803 platform: architecture: amd64 os: windows version: 1803 - - image: plugins/gitea-release:{{#if build.tag}}{{trimPrefix build.tag "v"}}-{{/if}}windows-1809 + image: plugins/gitea-release:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}windows-1809 platform: architecture: amd64 os: windows From 1def48823c25d88ef631927912aeafad357501df Mon Sep 17 00:00:00 2001 From: Thomas Boerger Date: Thu, 28 Mar 2019 09:31:56 +0100 Subject: [PATCH 7/7] Fix microbadger settings and enable auto_tag for manifest --- .drone.windows.yml | 3 ++- .drone.yml | 3 ++- pipeline.libsonnet | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/.drone.windows.yml b/.drone.windows.yml index 0999bbb..785cacc 100644 --- a/.drone.windows.yml +++ b/.drone.windows.yml @@ -246,6 +246,7 @@ steps: pull: always image: plugins/manifest settings: + auto_tag: true ignore_missing: true password: from_secret: docker_password @@ -257,7 +258,7 @@ steps: pull: always image: plugins/webhook settings: - url: + urls: from_secret: microbadger_url trigger: diff --git a/.drone.yml b/.drone.yml index 919617b..fa4413d 100644 --- a/.drone.yml +++ b/.drone.yml @@ -304,6 +304,7 @@ steps: pull: always image: plugins/manifest settings: + auto_tag: true ignore_missing: true password: from_secret: docker_password @@ -315,7 +316,7 @@ steps: pull: always image: plugins/webhook settings: - url: + urls: from_secret: microbadger_url trigger: diff --git a/pipeline.libsonnet b/pipeline.libsonnet index aab20bd..54a07b2 100644 --- a/pipeline.libsonnet +++ b/pipeline.libsonnet @@ -182,6 +182,7 @@ local golang_image(os, version) = password: { from_secret: 'docker_password' }, spec: 'docker/manifest.tmpl', ignore_missing: true, + auto_tag: true, }, }, { @@ -189,7 +190,7 @@ local golang_image(os, version) = image: 'plugins/webhook', pull: 'always', settings: { - url: { from_secret: 'microbadger_url' }, + urls: { from_secret: 'microbadger_url' }, }, }, ],