mirror of
https://github.com/drone-plugins/drone-download.git
synced 2026-06-04 10:15:28 +08:00
Merge pull request #33 from tphoney/harness_move
(maint) move to harness.drone.io
This commit is contained in:
@@ -1,2 +0,0 @@
|
||||
*
|
||||
!release/
|
||||
-350
@@ -1,350 +0,0 @@
|
||||
def main(ctx):
|
||||
before = testing(ctx)
|
||||
|
||||
stages = [
|
||||
linux(ctx, 'amd64'),
|
||||
linux(ctx, 'arm64'),
|
||||
linux(ctx, 'arm'),
|
||||
windows(ctx, '1909'),
|
||||
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.18',
|
||||
'pull': 'always',
|
||||
'commands': [
|
||||
'go get honnef.co/go/tools/cmd/staticcheck',
|
||||
'go run honnef.co/go/tools/cmd/staticcheck ./...',
|
||||
],
|
||||
'volumes': [
|
||||
{
|
||||
'name': 'gopath',
|
||||
'path': '/go',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
'name': 'lint',
|
||||
'image': 'golang:1.18',
|
||||
'pull': 'always',
|
||||
'commands': [
|
||||
'go get golang.org/x/lint/golint',
|
||||
'go run golang.org/x/lint/golint -set_exit_status ./...',
|
||||
],
|
||||
'volumes': [
|
||||
{
|
||||
'name': 'gopath',
|
||||
'path': '/go',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
'name': 'vet',
|
||||
'image': 'golang:1.18',
|
||||
'pull': 'always',
|
||||
'commands': [
|
||||
'go vet ./...',
|
||||
],
|
||||
'volumes': [
|
||||
{
|
||||
'name': 'gopath',
|
||||
'path': '/go',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
'name': 'test',
|
||||
'image': 'golang:1.18',
|
||||
'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/download',
|
||||
'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-download ./cmd/drone-download' % (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-download ./cmd/drone-download' % (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.18',
|
||||
'pull': 'always',
|
||||
'environment': {
|
||||
'CGO_ENABLED': '0',
|
||||
},
|
||||
'commands': [
|
||||
'go version',
|
||||
'go env',
|
||||
],
|
||||
},
|
||||
{
|
||||
'name': 'build',
|
||||
'image': 'golang:1.18',
|
||||
'pull': 'always',
|
||||
'environment': {
|
||||
'CGO_ENABLED': '0',
|
||||
},
|
||||
'commands': build,
|
||||
},
|
||||
{
|
||||
'name': 'executable',
|
||||
'image': 'golang:1.18',
|
||||
'pull': 'always',
|
||||
'commands': [
|
||||
'./release/linux/%s/drone-download --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-download.exe ./cmd/drone-download' % (ctx.build.ref.replace("refs/tags/v", "")),
|
||||
]
|
||||
|
||||
docker = docker + [
|
||||
'docker build --pull -f docker/Dockerfile.windows.%s -t plugins/download:%s-windows-%s-amd64 .' % (version, ctx.build.ref.replace("refs/tags/v", ""), version),
|
||||
'docker run --rm plugins/download:%s-windows-%s-amd64 --help' % (ctx.build.ref.replace("refs/tags/v", ""), version),
|
||||
'docker push plugins/download:%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-download.exe ./cmd/drone-download' % (ctx.build.commit[0:8]),
|
||||
]
|
||||
|
||||
docker = docker + [
|
||||
'docker build --pull -f docker/Dockerfile.windows.%s -t plugins/download:windows-%s-amd64 .' % (version, version),
|
||||
'docker run --rm plugins/download:windows-%s-amd64 --help' % (version),
|
||||
'docker push plugins/download: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-download.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',
|
||||
},
|
||||
},
|
||||
],
|
||||
'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',
|
||||
],
|
||||
},
|
||||
}]
|
||||
@@ -1,9 +0,0 @@
|
||||
FROM plugins/base:multiarch
|
||||
|
||||
LABEL maintainer="Drone.IO Community <drone-dev@googlegroups.com>" \
|
||||
org.label-schema.name="Drone Download" \
|
||||
org.label-schema.vendor="Drone.IO Community" \
|
||||
org.label-schema.schema-version="1.0"
|
||||
|
||||
ADD release/linux/arm/drone-download /bin/
|
||||
ENTRYPOINT [ "/bin/drone-download" ]
|
||||
@@ -1,10 +0,0 @@
|
||||
# escape=`
|
||||
FROM plugins/base:windows-1803
|
||||
|
||||
LABEL maintainer="Drone.IO Community <drone-dev@googlegroups.com>" `
|
||||
org.label-schema.name="Drone Download" `
|
||||
org.label-schema.vendor="Drone.IO Community" `
|
||||
org.label-schema.schema-version="1.0"
|
||||
|
||||
ADD release\drone-download.exe c:\drone-download.exe
|
||||
ENTRYPOINT [ "c:\\drone-download.exe" ]
|
||||
@@ -1,5 +1,5 @@
|
||||
# escape=`
|
||||
FROM plugins/base:windows-1809-amd64
|
||||
FROM plugins/base:windows-1809-amd64@sha256:61095306fa56d51adc841f2b0f93f511efb5792d12f2549bb2eb1cbce02c1f05
|
||||
|
||||
LABEL maintainer="Drone.IO Community <drone-dev@googlegroups.com>" `
|
||||
org.label-schema.name="Drone Download" `
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
# escape=`
|
||||
FROM plugins/base:windows-1909-amd64
|
||||
|
||||
LABEL maintainer="Drone.IO Community <drone-dev@googlegroups.com>" `
|
||||
org.label-schema.name="Drone Download" `
|
||||
org.label-schema.vendor="Drone.IO Community" `
|
||||
org.label-schema.schema-version="1.0"
|
||||
|
||||
ADD release/windows/amd64/drone-download.exe C:/bin/drone-download.exe
|
||||
ENTRYPOINT [ "C:\\bin\\drone-download.exe" ]
|
||||
@@ -1,10 +0,0 @@
|
||||
# escape=`
|
||||
FROM plugins/base:windows-2004-amd64
|
||||
|
||||
LABEL maintainer="Drone.IO Community <drone-dev@googlegroups.com>" `
|
||||
org.label-schema.name="Drone Download" `
|
||||
org.label-schema.vendor="Drone.IO Community" `
|
||||
org.label-schema.schema-version="1.0"
|
||||
|
||||
ADD release/windows/amd64/drone-download.exe C:/bin/drone-download.exe
|
||||
ENTRYPOINT [ "C:\\bin\\drone-download.exe" ]
|
||||
@@ -1,5 +1,5 @@
|
||||
# escape=`
|
||||
FROM plugins/base:windows-1903-amd64
|
||||
FROM plugins/base:windows-ltsc2022-amd64@sha256:0f90d5bceb432f1ee6f93cf44eed6a38c322834edd55df8a6648c9e6f15131f4
|
||||
|
||||
LABEL maintainer="Drone.IO Community <drone-dev@googlegroups.com>" `
|
||||
org.label-schema.name="Drone Download" `
|
||||
+5
-20
@@ -17,28 +17,13 @@ manifests:
|
||||
architecture: arm64
|
||||
os: linux
|
||||
variant: v8
|
||||
- image: plugins/download:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}linux-arm
|
||||
platform:
|
||||
architecture: arm
|
||||
os: linux
|
||||
variant: v7
|
||||
- image: plugins/download:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}windows-2004-amd64
|
||||
platform:
|
||||
architecture: amd64
|
||||
os: windows
|
||||
version: 2004
|
||||
- image: plugins/download:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}windows-1909-amd64
|
||||
platform:
|
||||
architecture: amd64
|
||||
os: windows
|
||||
version: 1909
|
||||
- image: plugins/download:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}windows-1903-amd64
|
||||
platform:
|
||||
architecture: amd64
|
||||
os: windows
|
||||
version: 1903
|
||||
- image: plugins/download:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}windows-1809-amd64
|
||||
platform:
|
||||
architecture: amd64
|
||||
os: windows
|
||||
version: 1809
|
||||
- image: plugins/download:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}ltsc2022-amd64
|
||||
platform:
|
||||
architecture: amd64
|
||||
os: windows
|
||||
version: 1809
|
||||
|
||||
@@ -1,205 +0,0 @@
|
||||
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,
|
||||
auto_tag: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'microbadger',
|
||||
image: 'plugins/webhook',
|
||||
pull: 'always',
|
||||
settings: {
|
||||
urls: { from_secret: 'microbadger_url' },
|
||||
},
|
||||
},
|
||||
],
|
||||
trigger: {
|
||||
ref: [
|
||||
'refs/heads/master',
|
||||
'refs/tags/**',
|
||||
],
|
||||
},
|
||||
depends_on: depends_on,
|
||||
},
|
||||
}
|
||||
Reference in New Issue
Block a user