mirror of
https://github.com/drone-plugins/drone-manifest.git
synced 2026-06-16 14:49:38 +08:00
Compare commits
71 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| fbcb0e4798 | |||
| 2e6d2280b4 | |||
| cf7ba4606c | |||
| 416c6f2cba | |||
| 2a9bc706ac | |||
| ec2669aa2d | |||
| 79f39c58d3 | |||
| 8eeefa8592 | |||
| c7afa18a9f | |||
| c51e841585 | |||
| 92722b712a | |||
| b3f7912112 | |||
| 2fe5f563a3 | |||
| 53c0cbbcef | |||
| 2b1f33534d | |||
| 82ade6b5aa | |||
| fe8c467e70 | |||
| b2ea804f53 | |||
| 4bae79aec2 | |||
| 4a15a55224 | |||
| fbe23cbcec | |||
| 3f387227b5 | |||
| bd53675813 | |||
| 3091c4a002 | |||
| 35d6bee743 | |||
| f92bc07dad | |||
| 5b15413fc2 | |||
| af2017d35c | |||
| 5e8ab59d01 | |||
| 18cf775bd3 | |||
| aaa402cdff | |||
| bed8b9a1b2 | |||
| e957ab3e04 | |||
| b548a9c07b | |||
| a9899d8548 | |||
| 3c0ccca611 | |||
| 8ed1b321f5 | |||
| f976bb1992 | |||
| 99d6654f37 | |||
| 0a2a640285 | |||
| 597acafbf7 | |||
| c2ba435fb8 | |||
| 7210ab5c16 | |||
| 8b07050495 | |||
| 120230dbd9 | |||
| 3b67f54e06 | |||
| 14a12e1a63 | |||
| 74fe6c5c18 | |||
| c9b38a9b94 | |||
| d6a5823d13 | |||
| 01a15fc1d3 | |||
| 936bc709d6 | |||
| 10252045dc | |||
| 3490c0600d | |||
| 7e39103352 | |||
| 0474975306 | |||
| 6c39a668da | |||
| f311aa4112 | |||
| 1375e1d81a | |||
| 9db5d7d3b3 | |||
| 5e6f1d304f | |||
| ce1bc302b6 | |||
| c557b76905 | |||
| ce5f88637a | |||
| 8cd76befa0 | |||
| f58ce02997 | |||
| 0659f84908 | |||
| 98a19daff5 | |||
| 09b2a0b327 | |||
| 46a67c3a0c | |||
| d5e2e58801 |
@@ -1,68 +0,0 @@
|
||||
version: '{build}'
|
||||
image: 'Visual Studio 2017'
|
||||
platform: 'x64'
|
||||
|
||||
clone_folder: 'c:\gopath\src\github.com\drone-plugins\drone-manifest'
|
||||
max_jobs: 1
|
||||
|
||||
environment:
|
||||
GOPATH: c:\gopath
|
||||
DOCKER_USERNAME:
|
||||
secure: '4YzzahbEiMZQJpOCOd1LAw=='
|
||||
DOCKER_PASSWORD:
|
||||
secure: 'VqO/G3Zfslu6zSLdwHKO+Q=='
|
||||
|
||||
install:
|
||||
- ps: |
|
||||
docker version
|
||||
go version
|
||||
- ps: |
|
||||
$env:Path = "c:\gopath\bin;$env:Path"
|
||||
|
||||
build_script:
|
||||
- ps: |
|
||||
go get -u github.com/golang/dep/cmd/dep
|
||||
dep ensure
|
||||
|
||||
if ( $env:APPVEYOR_REPO_TAG -eq 'false' ) {
|
||||
go build -ldflags "-X main.build=$env:APPVEYOR_BUILD_VERSION" -a -o release/drone-manifest.exe
|
||||
} else {
|
||||
$version = $env:APPVEYOR_REPO_TAG_NAME.substring(1)
|
||||
go build -ldflags "-X main.version=$version -X main.build=$env:APPVEYOR_BUILD_VERSION" -a -o release/drone-manifest.exe
|
||||
}
|
||||
|
||||
docker pull microsoft/nanoserver:10.0.14393.1593
|
||||
docker build -f Dockerfile.windows -t plugins/manifest:windows-amd64 .
|
||||
|
||||
test_script:
|
||||
- ps: |
|
||||
docker run --rm plugins/manifest:windows-amd64 --version
|
||||
|
||||
deploy_script:
|
||||
- ps: |
|
||||
$ErrorActionPreference = 'Stop';
|
||||
|
||||
if ( $env:APPVEYOR_PULL_REQUEST_NUMBER ) {
|
||||
Write-Host Nothing to deploy.
|
||||
} else {
|
||||
docker login --username $env:DOCKER_USERNAME --password $env:DOCKER_PASSWORD
|
||||
|
||||
if ( $env:APPVEYOR_REPO_TAG -eq 'true' ) {
|
||||
$major,$minor,$patch = $env:APPVEYOR_REPO_TAG_NAME.substring(1).split('.')
|
||||
|
||||
docker push plugins/manifest:windows-amd64
|
||||
|
||||
docker tag plugins/manifest:windows-amd64 plugins/manifest:$major.$minor.$patch-windows-amd64
|
||||
docker push plugins/manifest:$major.$minor.$patch-windows-amd64
|
||||
|
||||
docker tag plugins/manifest:windows-amd64 plugins/manifest:$major.$minor-windows-amd64
|
||||
docker push plugins/manifest:$major.$minor-windows-amd64
|
||||
|
||||
docker tag plugins/manifest:windows-amd64 plugins/manifest:$major-windows-amd64
|
||||
docker push plugins/manifest:$major-windows-amd64
|
||||
} else {
|
||||
if ( $env:APPVEYOR_REPO_BRANCH -eq 'master' ) {
|
||||
docker push plugins/manifest:windows-amd64
|
||||
}
|
||||
}
|
||||
}
|
||||
+232
-126
@@ -1,148 +1,254 @@
|
||||
workspace:
|
||||
base: /go
|
||||
path: src/github.com/drone-plugins/drone-manifest
|
||||
kind: pipeline
|
||||
type: vm
|
||||
name: testing
|
||||
platform:
|
||||
os: linux
|
||||
arch: amd64
|
||||
pool:
|
||||
use: ubuntu
|
||||
|
||||
pipeline:
|
||||
deps:
|
||||
image: golang:1.10
|
||||
pull: true
|
||||
steps:
|
||||
- name: lint
|
||||
image: golang:1.19
|
||||
pull: always
|
||||
commands:
|
||||
- go get -u github.com/golang/dep/cmd/dep
|
||||
- dep ensure
|
||||
|
||||
test:
|
||||
image: golang:1.10
|
||||
pull: true
|
||||
- go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
|
||||
- golangci-lint version
|
||||
- golangci-lint run
|
||||
volumes:
|
||||
- name: gopath
|
||||
path: "/go"
|
||||
- name: test
|
||||
image: golang:1.19
|
||||
commands:
|
||||
- go vet ./...
|
||||
- go test -cover ./...
|
||||
volumes:
|
||||
- name: gopath
|
||||
path: "/go"
|
||||
volumes:
|
||||
- name: gopath
|
||||
temp: {}
|
||||
trigger:
|
||||
ref:
|
||||
- refs/heads/master
|
||||
- refs/tags/**
|
||||
- refs/pull/**
|
||||
|
||||
build_linux_amd64:
|
||||
image: golang:1.10
|
||||
pull: true
|
||||
group: build
|
||||
---
|
||||
kind: pipeline
|
||||
type: vm
|
||||
name: linux-amd64
|
||||
platform:
|
||||
os: linux
|
||||
arch: amd64
|
||||
pool:
|
||||
use: ubuntu
|
||||
|
||||
steps:
|
||||
- name: environment
|
||||
image: golang:1.19
|
||||
pull: always
|
||||
environment:
|
||||
- GOOS=linux
|
||||
- GOARCH=amd64
|
||||
- CGO_ENABLED=0
|
||||
CGO_ENABLED: "0"
|
||||
commands:
|
||||
- |
|
||||
if test "${DRONE_TAG}" = ""; then
|
||||
go build -v -ldflags "-X main.build=${DRONE_BUILD_NUMBER}" -a -o release/linux/amd64/drone-manifest
|
||||
else
|
||||
go build -v -ldflags "-X main.version=${DRONE_TAG##v} -X main.build=${DRONE_BUILD_NUMBER}" -a -o release/linux/amd64/drone-manifest
|
||||
fi
|
||||
|
||||
build_linux_i386:
|
||||
image: golang:1.10
|
||||
pull: true
|
||||
group: build
|
||||
- go version
|
||||
- go env
|
||||
- name: build
|
||||
image: golang:1.19
|
||||
environment:
|
||||
- GOOS=linux
|
||||
- GOARCH=386
|
||||
- CGO_ENABLED=0
|
||||
CGO_ENABLED: "0"
|
||||
commands:
|
||||
- |
|
||||
if test "${DRONE_TAG}" = ""; then
|
||||
go build -v -ldflags "-X main.build=${DRONE_BUILD_NUMBER}" -a -o release/linux/i386/drone-manifest
|
||||
else
|
||||
go build -v -ldflags "-X main.version=${DRONE_TAG##v} -X main.build=${DRONE_BUILD_NUMBER}" -a -o release/linux/i386/drone-manifest
|
||||
fi
|
||||
- go build -v -ldflags "-X main.version=" -a -tags netgo -o release/linux/amd64/drone-manifest .
|
||||
- name: docker
|
||||
image: plugins/docker
|
||||
settings:
|
||||
dockerfile: docker/Dockerfile.linux.amd64
|
||||
repo: plugins/manifest
|
||||
username:
|
||||
from_secret: docker_username
|
||||
password:
|
||||
from_secret: docker_password
|
||||
auto_tag: true
|
||||
auto_tag_suffix: linux-amd64
|
||||
depends_on:
|
||||
- testing
|
||||
trigger:
|
||||
ref:
|
||||
- refs/heads/master
|
||||
- refs/tags/**
|
||||
- refs/pull/**
|
||||
|
||||
build_linux_arm64:
|
||||
image: golang:1.10
|
||||
pull: true
|
||||
group: build
|
||||
---
|
||||
kind: pipeline
|
||||
type: vm
|
||||
name: linux-arm64
|
||||
platform:
|
||||
os: linux
|
||||
arch: arm64
|
||||
pool:
|
||||
use: ubuntu_arm64
|
||||
|
||||
steps:
|
||||
- name: environment
|
||||
image: golang:1.19
|
||||
pull: always
|
||||
environment:
|
||||
- GOOS=linux
|
||||
- GOARCH=arm64
|
||||
- CGO_ENABLED=0
|
||||
CGO_ENABLED: "0"
|
||||
commands:
|
||||
- |
|
||||
if test "${DRONE_TAG}" = ""; then
|
||||
go build -v -ldflags "-X main.build=${DRONE_BUILD_NUMBER}" -a -o release/linux/arm64/drone-manifest
|
||||
else
|
||||
go build -v -ldflags "-X main.version=${DRONE_TAG##v} -X main.build=${DRONE_BUILD_NUMBER}" -a -o release/linux/arm64/drone-manifest
|
||||
fi
|
||||
|
||||
build_linux_arm:
|
||||
image: golang:1.10
|
||||
pull: true
|
||||
group: build
|
||||
- go version
|
||||
- go env
|
||||
- name: build
|
||||
image: golang:1.19
|
||||
environment:
|
||||
- GOOS=linux
|
||||
- GOARCH=arm
|
||||
- CGO_ENABLED=0
|
||||
- GOARM=7
|
||||
CGO_ENABLED: "0"
|
||||
commands:
|
||||
- |
|
||||
if test "${DRONE_TAG}" = ""; then
|
||||
go build -v -ldflags "-X main.build=${DRONE_BUILD_NUMBER}" -a -o release/linux/arm/drone-manifest
|
||||
else
|
||||
go build -v -ldflags "-X main.version=${DRONE_TAG##v} -X main.build=${DRONE_BUILD_NUMBER}" -a -o release/linux/arm/drone-manifest
|
||||
fi
|
||||
- go build -v -ldflags "-X main.version=" -a -tags netgo -o release/linux/arm64/drone-manifest .
|
||||
- name: docker
|
||||
image: plugins/docker
|
||||
settings:
|
||||
dockerfile: docker/Dockerfile.linux.arm64
|
||||
repo: plugins/manifest
|
||||
username:
|
||||
from_secret: docker_username
|
||||
password:
|
||||
from_secret: docker_password
|
||||
auto_tag: true
|
||||
auto_tag_suffix: linux-arm64
|
||||
depends_on:
|
||||
- testing
|
||||
trigger:
|
||||
ref:
|
||||
- refs/heads/master
|
||||
- refs/tags/**
|
||||
- refs/pull/**
|
||||
|
||||
publish_linux_amd64:
|
||||
image: plugins/docker:17.12
|
||||
pull: true
|
||||
secrets: [ docker_username, docker_password ]
|
||||
group: docker
|
||||
repo: plugins/manifest
|
||||
auto_tag: true
|
||||
auto_tag_suffix: linux-amd64
|
||||
dockerfile: Dockerfile
|
||||
when:
|
||||
event: [ push, tag ]
|
||||
---
|
||||
kind: pipeline
|
||||
type: vm
|
||||
name: windows-1809
|
||||
platform:
|
||||
os: windows
|
||||
arch: amd64
|
||||
pool:
|
||||
use: windows
|
||||
|
||||
publish_linux_i386:
|
||||
image: plugins/docker:17.12
|
||||
pull: true
|
||||
secrets: [ docker_username, docker_password ]
|
||||
group: docker
|
||||
repo: plugins/manifest
|
||||
auto_tag: true
|
||||
auto_tag_suffix: linux-i386
|
||||
dockerfile: Dockerfile.i386
|
||||
steps:
|
||||
- name: environment
|
||||
image: golang:1.19
|
||||
pull: always
|
||||
environment:
|
||||
CGO_ENABLED: "0"
|
||||
commands:
|
||||
- go version
|
||||
- go env
|
||||
- name: build
|
||||
image: golang:1.19
|
||||
environment:
|
||||
CGO_ENABLED: "0"
|
||||
commands:
|
||||
- go build -v -ldflags "-X main.version=" -a -tags netgo -o release/windows/amd64/drone-manifest.exe .
|
||||
- name: docker
|
||||
image: plugins/docker
|
||||
settings:
|
||||
dockerfile: docker/Dockerfile.windows.1809
|
||||
repo: plugins/manifest
|
||||
username:
|
||||
from_secret: docker_username
|
||||
password:
|
||||
from_secret: docker_password
|
||||
auto_tag: true
|
||||
auto_tag_suffix: windows-1809-amd64
|
||||
daemon_off: true
|
||||
purge: false
|
||||
when:
|
||||
event: [ push, tag ]
|
||||
ref:
|
||||
- refs/heads/master
|
||||
- refs/tags/**
|
||||
depends_on:
|
||||
- testing
|
||||
trigger:
|
||||
ref:
|
||||
- refs/heads/master
|
||||
- refs/tags/**
|
||||
- refs/pull/**
|
||||
|
||||
publish_linux_arm64:
|
||||
image: plugins/docker:17.12
|
||||
pull: true
|
||||
secrets: [ docker_username, docker_password ]
|
||||
group: docker
|
||||
repo: plugins/manifest
|
||||
auto_tag: true
|
||||
auto_tag_suffix: linux-arm64
|
||||
dockerfile: Dockerfile.arm64
|
||||
when:
|
||||
event: [ push, tag ]
|
||||
---
|
||||
kind: pipeline
|
||||
type: vm
|
||||
name: windows-ltsc2022
|
||||
platform:
|
||||
os: windows
|
||||
arch: amd64
|
||||
pool:
|
||||
use: windows-2022
|
||||
|
||||
publish_linux_arm:
|
||||
image: plugins/docker:17.12
|
||||
pull: true
|
||||
secrets: [ docker_username, docker_password ]
|
||||
group: docker
|
||||
repo: plugins/manifest
|
||||
auto_tag: true
|
||||
auto_tag_suffix: linux-arm
|
||||
dockerfile: Dockerfile.arm
|
||||
steps:
|
||||
- name: environment
|
||||
image: golang:1.19
|
||||
pull: always
|
||||
environment:
|
||||
CGO_ENABLED: "0"
|
||||
commands:
|
||||
- go version
|
||||
- go env
|
||||
- name: build
|
||||
image: golang:1.19
|
||||
environment:
|
||||
CGO_ENABLED: "0"
|
||||
commands:
|
||||
- go build -v -ldflags "-X main.version=" -a -tags netgo -o release/windows/amd64/drone-manifest.exe .
|
||||
- name: docker
|
||||
image: plugins/docker
|
||||
settings:
|
||||
dockerfile: docker/Dockerfile.windows.ltsc2022
|
||||
repo: plugins/manifest
|
||||
username:
|
||||
from_secret: docker_username
|
||||
password:
|
||||
from_secret: docker_password
|
||||
auto_tag: true
|
||||
auto_tag_suffix: windows-ltsc2022-amd64
|
||||
daemon_off: true
|
||||
purge: false
|
||||
when:
|
||||
event: [ push, tag ]
|
||||
ref:
|
||||
- refs/heads/master
|
||||
- refs/tags/**
|
||||
depends_on:
|
||||
- testing
|
||||
trigger:
|
||||
ref:
|
||||
- refs/heads/master
|
||||
- refs/tags/**
|
||||
- refs/pull/**
|
||||
|
||||
manifests:
|
||||
image: plugins/manifest:1
|
||||
pull: true
|
||||
secrets: [ docker_username, docker_password ]
|
||||
spec: manifest.tmpl
|
||||
auto_tag: true
|
||||
ignore_missing: true
|
||||
when:
|
||||
event: [ push, tag ]
|
||||
---
|
||||
kind: pipeline
|
||||
type: vm
|
||||
name: manifest
|
||||
platform:
|
||||
os: linux
|
||||
arch: amd64
|
||||
pool:
|
||||
use: ubuntu
|
||||
|
||||
microbadger:
|
||||
image: plugins/webhook:1
|
||||
pull: true
|
||||
secrets: [ webhook_url ]
|
||||
when:
|
||||
status: [ success ]
|
||||
steps:
|
||||
- name: manifest
|
||||
image: plugins/manifest:linux-amd64
|
||||
settings:
|
||||
auto_tag: "true"
|
||||
username:
|
||||
from_secret: docker_username
|
||||
password:
|
||||
from_secret: docker_password
|
||||
spec: docker/manifest.tmpl
|
||||
ignore_missing: true
|
||||
depends_on:
|
||||
- linux-amd64
|
||||
- linux-arm64
|
||||
- windows-1809
|
||||
- windows-ltsc2022
|
||||
trigger:
|
||||
ref:
|
||||
- refs/heads/master
|
||||
- refs/tags/**
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
<!-- PLEASE READ BEFORE DELETING
|
||||
|
||||
Bugs or Issues? Due to the high number of false positive issues we receive,
|
||||
please do not create a GitHub issue until you have discussed and verified
|
||||
with community support at:
|
||||
|
||||
https://discourse.drone.io/
|
||||
|
||||
-->
|
||||
|
||||
@@ -0,0 +1,73 @@
|
||||
repository:
|
||||
name: drone-manifest
|
||||
description: Drone plugin to push Docker manifests
|
||||
homepage: http://plugins.drone.io/drone-plugins/drone-manifest
|
||||
topics: drone, drone-plugin
|
||||
|
||||
private: false
|
||||
has_issues: true
|
||||
has_wiki: false
|
||||
has_downloads: false
|
||||
|
||||
default_branch: master
|
||||
|
||||
allow_squash_merge: true
|
||||
allow_merge_commit: true
|
||||
allow_rebase_merge: true
|
||||
|
||||
labels:
|
||||
- name: bug
|
||||
color: d73a4a
|
||||
description: Something isn't working
|
||||
- name: duplicate
|
||||
color: cfd3d7
|
||||
description: This issue or pull request already exists
|
||||
- name: enhancement
|
||||
color: a2eeef
|
||||
description: New feature or request
|
||||
- name: good first issue
|
||||
color: 7057ff
|
||||
description: Good for newcomers
|
||||
- name: help wanted
|
||||
color: 008672
|
||||
description: Extra attention is needed
|
||||
- name: invalid
|
||||
color: e4e669
|
||||
description: This doesn't seem right
|
||||
- name: question
|
||||
color: d876e3
|
||||
description: Further information is requested
|
||||
- name: renovate
|
||||
color: e99695
|
||||
description: Automated action from Renovate
|
||||
- name: wontfix
|
||||
color: ffffff
|
||||
description: This will not be worked on
|
||||
|
||||
teams:
|
||||
- name: Admins
|
||||
permission: admin
|
||||
- name: Captain
|
||||
permission: admin
|
||||
- name: Maintainers
|
||||
permission: push
|
||||
|
||||
branches:
|
||||
- name: master
|
||||
protection:
|
||||
required_pull_request_reviews:
|
||||
required_approving_review_count: 1
|
||||
dismiss_stale_reviews: false
|
||||
require_code_owner_reviews: false
|
||||
dismissal_restrictions:
|
||||
teams:
|
||||
- Admins
|
||||
- Captain
|
||||
required_status_checks:
|
||||
strict: true
|
||||
contexts:
|
||||
- continuous-integration/drone/pr
|
||||
enforce_admins: false
|
||||
restrictions:
|
||||
users: []
|
||||
teams: []
|
||||
@@ -1,17 +0,0 @@
|
||||
FROM alpine:3.6 as base
|
||||
|
||||
RUN apk add --no-cache curl && \
|
||||
curl -sSLo /bin/manifest-tool https://github.com/estesp/manifest-tool/releases/download/v0.7.0/manifest-tool-linux-armv7 && \
|
||||
chmod +x /bin/manifest-tool
|
||||
|
||||
FROM plugins/base:multiarch
|
||||
|
||||
LABEL maintainer="Drone.IO Community <drone-dev@googlegroups.com>" \
|
||||
org.label-schema.name="Drone Manifest" \
|
||||
org.label-schema.vendor="Drone.IO Community" \
|
||||
org.label-schema.schema-version="1.0"
|
||||
|
||||
COPY --from=base /bin/manifest-tool /bin/
|
||||
|
||||
ADD release/linux/arm/drone-manifest /bin/
|
||||
ENTRYPOINT ["/bin/drone-manifest"]
|
||||
@@ -1,17 +0,0 @@
|
||||
FROM alpine:3.6 as base
|
||||
|
||||
RUN apk add --no-cache curl && \
|
||||
curl -sSLo /bin/manifest-tool https://github.com/estesp/manifest-tool/releases/download/v0.7.0/manifest-tool-linux-386 && \
|
||||
chmod +x /bin/manifest-tool
|
||||
|
||||
FROM plugins/base:multiarch
|
||||
|
||||
LABEL maintainer="Drone.IO Community <drone-dev@googlegroups.com>" \
|
||||
org.label-schema.name="Drone Manifest" \
|
||||
org.label-schema.vendor="Drone.IO Community" \
|
||||
org.label-schema.schema-version="1.0"
|
||||
|
||||
COPY --from=base /bin/manifest-tool /bin/
|
||||
|
||||
ADD release/linux/i386/drone-manifest /bin/
|
||||
ENTRYPOINT ["/bin/drone-manifest"]
|
||||
@@ -1,14 +0,0 @@
|
||||
# escape=`
|
||||
FROM microsoft/nanoserver:10.0.14393.1593
|
||||
|
||||
LABEL maintainer="Drone.IO Community <drone-dev@googlegroups.com>" `
|
||||
org.label-schema.name="Drone Manifest" `
|
||||
org.label-schema.vendor="Drone.IO Community" `
|
||||
org.label-schema.schema-version="1.0"
|
||||
|
||||
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
|
||||
|
||||
RUN Invoke-WebRequest 'https://github.com/estesp/manifest-tool/releases/download/v0.7.0/manifest-tool-windows-amd64.exe' -OutFile 'c:\Windows\System32\manifest-tool.exe';
|
||||
|
||||
ADD release\drone-manifest.exe c:\drone-manifest.exe
|
||||
ENTRYPOINT [ "c:\\drone-manifest.exe" ]
|
||||
Generated
-33
@@ -1,33 +0,0 @@
|
||||
# This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'.
|
||||
|
||||
|
||||
[[projects]]
|
||||
name = "github.com/aymerick/raymond"
|
||||
packages = [".","ast","lexer","parser"]
|
||||
revision = "a2232af10b53ef1ae5a767f5178db3a6c1dab655"
|
||||
version = "v2.0.1"
|
||||
|
||||
[[projects]]
|
||||
name = "github.com/coreos/go-semver"
|
||||
packages = ["semver"]
|
||||
revision = "8ab6407b697782a06568d4b7f1db25550ec2e4c6"
|
||||
version = "v0.2.0"
|
||||
|
||||
[[projects]]
|
||||
name = "github.com/pkg/errors"
|
||||
packages = ["."]
|
||||
revision = "645ef00459ed84a119197bfb8d8205042c6df63d"
|
||||
version = "v0.8.0"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
name = "github.com/urfave/cli"
|
||||
packages = ["."]
|
||||
revision = "75104e932ac2ddb944a6ea19d9f9f26316ff1145"
|
||||
|
||||
[solve-meta]
|
||||
analyzer-name = "dep"
|
||||
analyzer-version = 1
|
||||
inputs-digest = "a89f1c3cf068c93fd8bf83840a119df2915c502193ca71a2b5ae4b6a6cfa4d70"
|
||||
solver-name = "gps-cdcl"
|
||||
solver-version = 1
|
||||
-15
@@ -1,15 +0,0 @@
|
||||
[[constraint]]
|
||||
name = "github.com/aymerick/raymond"
|
||||
version = "2.0.1"
|
||||
|
||||
[[constraint]]
|
||||
name = "github.com/coreos/go-semver"
|
||||
version = "0.2.0"
|
||||
|
||||
[[constraint]]
|
||||
name = "github.com/pkg/errors"
|
||||
version = "0.8.0"
|
||||
|
||||
[[constraint]]
|
||||
branch = "master"
|
||||
name = "github.com/urfave/cli"
|
||||
@@ -1,34 +1,42 @@
|
||||
# drone-manifest
|
||||
|
||||
[](http://beta.drone.io/drone-plugins/drone-manifest)
|
||||
[](http://cloud.drone.io/drone-plugins/drone-manifest)
|
||||
[](https://gitter.im/drone/drone)
|
||||
[](https://discourse.drone.io)
|
||||
[](https://stackoverflow.com/questions/tagged/drone.io)
|
||||
[](https://microbadger.com/images/plugins/manifest "Get your own image badge on microbadger.com")
|
||||
[](http://godoc.org/github.com/drone-plugins/drone-manifest)
|
||||
[](https://goreportcard.com/report/github.com/drone-plugins/drone-manifest)
|
||||
[](https://microbadger.com/images/plugins/manifest "Get your own image badge on microbadger.com")
|
||||
|
||||
Drone plugin to push Docker manifest to a registry for multi-architecture mappings. 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-manifest/).
|
||||
|
||||
## Build
|
||||
|
||||
Build the binary with the following commands:
|
||||
Build the binary with the following command:
|
||||
|
||||
```
|
||||
go build
|
||||
```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-manifest
|
||||
```
|
||||
|
||||
## Docker
|
||||
|
||||
Build the Docker image with the following commands:
|
||||
Build the Docker image with the following command:
|
||||
|
||||
```
|
||||
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -a -tags netgo -o release/linux/amd64/drone-manifest
|
||||
docker build --rm -t plugins/manifest .
|
||||
```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/manifest .
|
||||
```
|
||||
|
||||
### Usage
|
||||
## Usage
|
||||
|
||||
```
|
||||
```console
|
||||
docker run --rm \
|
||||
-e PLUGIN_PLATFORMS=linux/amd64,linux/arm,linux/arm64 \
|
||||
-e PLUGIN_TEMPLATE=organization/project-ARCH:1.0.0 \
|
||||
|
||||
@@ -1,102 +0,0 @@
|
||||
package command
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"os/exec"
|
||||
"strings"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
type Command struct {
|
||||
username string
|
||||
password string
|
||||
spec string
|
||||
platforms []string
|
||||
target string
|
||||
template string
|
||||
path string
|
||||
ignoreMissing bool
|
||||
}
|
||||
|
||||
func New(opts ...Option) *Command {
|
||||
c := &Command{}
|
||||
|
||||
for _, opt := range opts {
|
||||
opt(c)
|
||||
}
|
||||
|
||||
return c
|
||||
}
|
||||
|
||||
func (c *Command) Exec() error {
|
||||
args := []string{}
|
||||
|
||||
if c.username != "" {
|
||||
args = append(args, fmt.Sprintf("--username=%s", c.username))
|
||||
}
|
||||
|
||||
if c.password != "" {
|
||||
args = append(args, fmt.Sprintf("--password=%s", c.password))
|
||||
}
|
||||
|
||||
args = append(args, "push")
|
||||
|
||||
if c.spec != "" {
|
||||
tmpfile, err := ioutil.TempFile(c.path, "manifest-")
|
||||
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "failed to create tempfile")
|
||||
}
|
||||
|
||||
defer os.Remove(tmpfile.Name())
|
||||
|
||||
if _, err := tmpfile.Write([]byte(c.spec)); err != nil {
|
||||
return errors.Wrap(err, "failed to write tempfile")
|
||||
}
|
||||
|
||||
if err := tmpfile.Close(); err != nil {
|
||||
return errors.Wrap(err, "failed to close temp file")
|
||||
}
|
||||
|
||||
args = append(args, "from-spec")
|
||||
args = append(args, tmpfile.Name())
|
||||
} else {
|
||||
args = append(args, "from-args")
|
||||
|
||||
if len(c.platforms) != 0 {
|
||||
args = append(args, fmt.Sprintf("--platforms=%s", strings.Join(c.platforms, ",")))
|
||||
}
|
||||
|
||||
if c.target != "" {
|
||||
args = append(args, fmt.Sprintf("--target=%s", c.target))
|
||||
}
|
||||
|
||||
if c.template != "" {
|
||||
args = append(args, fmt.Sprintf("--template=%s", c.template))
|
||||
}
|
||||
}
|
||||
|
||||
if c.ignoreMissing {
|
||||
args = append(args, "--ignore-missing")
|
||||
}
|
||||
|
||||
cmd := exec.Command(
|
||||
"manifest-tool",
|
||||
args...,
|
||||
)
|
||||
|
||||
buf := bytes.NewBufferString("")
|
||||
cmd.Stdout = io.MultiWriter(os.Stdout, buf)
|
||||
cmd.Stderr = io.MultiWriter(os.Stderr, buf)
|
||||
|
||||
if c.path != "" {
|
||||
cmd.Dir = c.path
|
||||
}
|
||||
|
||||
return cmd.Run()
|
||||
}
|
||||
@@ -1,51 +0,0 @@
|
||||
package command
|
||||
|
||||
type Option func(*Command)
|
||||
|
||||
func WithUsername(val string) Option {
|
||||
return func(t *Command) {
|
||||
t.username = val
|
||||
}
|
||||
}
|
||||
|
||||
func WithPassword(val string) Option {
|
||||
return func(t *Command) {
|
||||
t.password = val
|
||||
}
|
||||
}
|
||||
|
||||
func WithSpec(val string) Option {
|
||||
return func(t *Command) {
|
||||
t.spec = val
|
||||
}
|
||||
}
|
||||
|
||||
func WithPlatforms(val []string) Option {
|
||||
return func(t *Command) {
|
||||
t.platforms = val
|
||||
}
|
||||
}
|
||||
|
||||
func WithTarget(val string) Option {
|
||||
return func(t *Command) {
|
||||
t.target = val
|
||||
}
|
||||
}
|
||||
|
||||
func WithTemplate(val string) Option {
|
||||
return func(t *Command) {
|
||||
t.template = val
|
||||
}
|
||||
}
|
||||
|
||||
func WithPath(val string) Option {
|
||||
return func(t *Command) {
|
||||
t.path = val
|
||||
}
|
||||
}
|
||||
|
||||
func IgnoreMissing() Option {
|
||||
return func(t *Command) {
|
||||
t.ignoreMissing = true
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,9 @@
|
||||
FROM alpine:3.6 as base
|
||||
FROM alpine:3.10 as base
|
||||
|
||||
ENV MANIFEST_TOOL_VERSION 1.0.2
|
||||
|
||||
RUN apk add --no-cache curl && \
|
||||
curl -sSLo /bin/manifest-tool https://github.com/estesp/manifest-tool/releases/download/v0.7.0/manifest-tool-linux-amd64 && \
|
||||
curl -sSLo /bin/manifest-tool https://github.com/estesp/manifest-tool/releases/download/v${MANIFEST_TOOL_VERSION}/manifest-tool-linux-amd64 && \
|
||||
chmod +x /bin/manifest-tool
|
||||
|
||||
FROM plugins/base:multiarch
|
||||
@@ -1,7 +1,9 @@
|
||||
FROM alpine:3.6 as base
|
||||
FROM alpine:3.10 as base
|
||||
|
||||
ENV MANIFEST_TOOL_VERSION 1.0.2
|
||||
|
||||
RUN apk add --no-cache curl && \
|
||||
curl -sSLo /bin/manifest-tool https://github.com/estesp/manifest-tool/releases/download/v0.7.0/manifest-tool-linux-arm64 && \
|
||||
curl -sSLo /bin/manifest-tool https://github.com/estesp/manifest-tool/releases/download/v${MANIFEST_TOOL_VERSION}/manifest-tool-linux-arm64 && \
|
||||
chmod +x /bin/manifest-tool
|
||||
|
||||
FROM plugins/base:multiarch
|
||||
@@ -0,0 +1,22 @@
|
||||
# escape=`
|
||||
FROM mcr.microsoft.com/windows/servercore:1809 as download
|
||||
|
||||
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
|
||||
|
||||
RUN mkdir C:\app
|
||||
RUN [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 ; `
|
||||
Invoke-WebRequest 'https://github.com/estesp/manifest-tool/releases/download/v1.0.3/manifest-tool-windows-amd64.exe' -OutFile 'c:\app\manifest-tool.exe'
|
||||
|
||||
FROM plugins/base:windows-1809-amd64
|
||||
|
||||
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
|
||||
|
||||
LABEL maintainer="Drone.IO Community <drone-dev@googlegroups.com>" `
|
||||
org.label-schema.name="Drone Manifest" `
|
||||
org.label-schema.vendor="Drone.IO Community" `
|
||||
org.label-schema.schema-version="1.0"
|
||||
|
||||
COPY --from=download /app/manifest-tool.exe C:/bin/docker.exe
|
||||
|
||||
ADD release/windows/amd64/drone-manifest.exe C:/bin/drone-manifest.exe
|
||||
ENTRYPOINT [ "C:\\bin\\drone-manifest.exe" ]
|
||||
@@ -0,0 +1,22 @@
|
||||
# escape=`
|
||||
FROM mcr.microsoft.com/windows/servercore:ltsc2022 as download
|
||||
|
||||
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
|
||||
|
||||
RUN mkdir C:\app
|
||||
RUN [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 ; `
|
||||
Invoke-WebRequest 'https://github.com/estesp/manifest-tool/releases/download/v1.0.3/manifest-tool-windows-amd64.exe' -OutFile 'c:\app\manifest-tool.exe'
|
||||
|
||||
FROM plugins/base:windows-ltsc2022-amd64@sha256:0f90d5bceb432f1ee6f93cf44eed6a38c322834edd55df8a6648c9e6f15131f4
|
||||
|
||||
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
|
||||
|
||||
LABEL maintainer="Drone.IO Community <drone-dev@googlegroups.com>" `
|
||||
org.label-schema.name="Drone Manifest" `
|
||||
org.label-schema.vendor="Drone.IO Community" `
|
||||
org.label-schema.schema-version="1.0"
|
||||
|
||||
COPY --from=download /app/manifest-tool.exe C:/bin/docker.exe
|
||||
|
||||
ADD release/windows/amd64/drone-manifest.exe C:/bin/drone-manifest.exe
|
||||
ENTRYPOINT [ "C:\\bin\\drone-manifest.exe" ]
|
||||
@@ -0,0 +1,31 @@
|
||||
image: plugins/manifest:{{#if build.tag}}{{trimPrefix "v" build.tag}}{{else}}latest{{/if}}
|
||||
{{#if build.tags}}
|
||||
tags:
|
||||
{{#each build.tags}}
|
||||
- {{this}}
|
||||
{{/each}}
|
||||
{{/if}}
|
||||
manifests:
|
||||
-
|
||||
image: plugins/manifest:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}linux-amd64
|
||||
platform:
|
||||
architecture: amd64
|
||||
os: linux
|
||||
-
|
||||
image: plugins/manifest:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}linux-arm64
|
||||
platform:
|
||||
architecture: arm64
|
||||
os: linux
|
||||
variant: v8
|
||||
-
|
||||
image: plugins/manifest:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}windows-1809-amd64
|
||||
platform:
|
||||
architecture: amd64
|
||||
os: windows
|
||||
version: 1809
|
||||
-
|
||||
image: plugins/manifest:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}windows-ltsc2022-amd64
|
||||
platform:
|
||||
architecture: amd64
|
||||
os: windows
|
||||
version: ltsc2022
|
||||
@@ -0,0 +1,29 @@
|
||||
module github.com/drone-plugins/drone-manifest
|
||||
|
||||
go 1.19
|
||||
|
||||
require (
|
||||
github.com/coreos/go-semver v0.3.0
|
||||
github.com/drone/drone-template-lib v1.0.1-0.20201006172840-a58a3f26ebca
|
||||
github.com/pkg/errors v0.9.1
|
||||
github.com/urfave/cli v1.22.10
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/Masterminds/goutils v1.1.1 // indirect
|
||||
github.com/Masterminds/semver/v3 v3.1.0 // indirect
|
||||
github.com/Masterminds/sprig/v3 v3.1.0 // indirect
|
||||
github.com/aymerick/raymond v2.0.2+incompatible // indirect
|
||||
github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect
|
||||
github.com/google/uuid v1.3.0 // indirect
|
||||
github.com/huandu/xstrings v1.4.0 // indirect
|
||||
github.com/imdario/mergo v0.3.13 // indirect
|
||||
github.com/mitchellh/copystructure v1.2.0 // indirect
|
||||
github.com/mitchellh/reflectwalk v1.0.2 // indirect
|
||||
github.com/russross/blackfriday/v2 v2.1.0 // indirect
|
||||
github.com/spf13/cast v1.3.1 // indirect
|
||||
github.com/stretchr/testify v1.8.1 // indirect
|
||||
golang.org/x/crypto v0.4.0 // indirect
|
||||
gopkg.in/yaml.v2 v2.4.0 // indirect
|
||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||
)
|
||||
@@ -0,0 +1,72 @@
|
||||
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
||||
github.com/Masterminds/goutils v1.1.0/go.mod h1:8cTjp+g8YejhMuvIA5y2vz3BpJxksy863GQaJW2MFNU=
|
||||
github.com/Masterminds/goutils v1.1.1 h1:5nUrii3FMTL5diU80unEVvNevw1nH4+ZV4DSLVJLSYI=
|
||||
github.com/Masterminds/goutils v1.1.1/go.mod h1:8cTjp+g8YejhMuvIA5y2vz3BpJxksy863GQaJW2MFNU=
|
||||
github.com/Masterminds/semver/v3 v3.1.0 h1:Y2lUDsFKVRSYGojLJ1yLxSXdMmMYTYls0rCvoqmMUQk=
|
||||
github.com/Masterminds/semver/v3 v3.1.0/go.mod h1:VPu/7SZ7ePZ3QOrcuXROw5FAcLl4a0cBrbBpGY/8hQs=
|
||||
github.com/Masterminds/sprig/v3 v3.1.0 h1:j7GpgZ7PdFqNsmncycTHsLmVPf5/3wJtlgW9TNDYD9Y=
|
||||
github.com/Masterminds/sprig/v3 v3.1.0/go.mod h1:ONGMf7UfYGAbMXCZmQLy8x3lCDIPrEZE/rU8pmrbihA=
|
||||
github.com/aymerick/raymond v2.0.2+incompatible h1:VEp3GpgdAnv9B2GFyTvqgcKvY+mfKMjPOA3SbKLtnU0=
|
||||
github.com/aymerick/raymond v2.0.2+incompatible/go.mod h1:osfaiScAUVup+UC9Nfq76eWqDhXlp+4UYaA8uhTBO6g=
|
||||
github.com/coreos/go-semver v0.3.0 h1:wkHLiw0WNATZnSG7epLsujiMCgPAc9xhjJ4tgnAxmfM=
|
||||
github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk=
|
||||
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
|
||||
github.com/cpuguy83/go-md2man/v2 v2.0.2 h1:p1EgwI/C7NhT0JmVkwCD2ZBK8j4aeHQX2pMHHBfMQ6w=
|
||||
github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/drone/drone-template-lib v1.0.1-0.20201006172840-a58a3f26ebca h1:8kk7qaQJ1R3aIDMQ04NhKRZQZZgBE9veNYme2Wjudts=
|
||||
github.com/drone/drone-template-lib v1.0.1-0.20201006172840-a58a3f26ebca/go.mod h1:4DHXhrDoAGam5Sx6LHygmi2tkhWt2dWXqNFLQNxmWTc=
|
||||
github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
|
||||
github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/huandu/xstrings v1.3.1/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE=
|
||||
github.com/huandu/xstrings v1.4.0 h1:D17IlohoQq4UcpqD7fDk80P7l+lwAmlFaBHgOipl2FU=
|
||||
github.com/huandu/xstrings v1.4.0/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE=
|
||||
github.com/imdario/mergo v0.3.8/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA=
|
||||
github.com/imdario/mergo v0.3.13 h1:lFzP57bqS/wsqKssCGmtLAb8A0wKjLGrve2q3PPVcBk=
|
||||
github.com/imdario/mergo v0.3.13/go.mod h1:4lJ1jqUDcsbIECGy0RUJAXNIhg+6ocWgb1ALK2O4oXg=
|
||||
github.com/mitchellh/copystructure v1.0.0/go.mod h1:SNtv71yrdKgLRyLFxmLdkAbkKEFWgYaq1OVrnRcwhnw=
|
||||
github.com/mitchellh/copystructure v1.2.0 h1:vpKXTN4ewci03Vljg/q9QvCGUDttBOGBIa15WveJJGw=
|
||||
github.com/mitchellh/copystructure v1.2.0/go.mod h1:qLl+cE2AmVv+CoeAwDPye/v+N2HKCj9FbZEVFJRxO9s=
|
||||
github.com/mitchellh/reflectwalk v1.0.0/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw=
|
||||
github.com/mitchellh/reflectwalk v1.0.2 h1:G2LzWKi524PWgd3mLHV8Y5k7s6XUvT0Gef6zxSIeXaQ=
|
||||
github.com/mitchellh/reflectwalk v1.0.2/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw=
|
||||
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
|
||||
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
|
||||
github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk=
|
||||
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
|
||||
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
|
||||
github.com/spf13/cast v1.3.1 h1:nFm6S0SMdyzrzcmThSipiEubIDy8WEXKNZ0UOgiRpng=
|
||||
github.com/spf13/cast v1.3.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
|
||||
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
|
||||
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
||||
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
|
||||
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
|
||||
github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk=
|
||||
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
|
||||
github.com/urfave/cli v1.22.10 h1:p8Fspmz3iTctJstry1PYS3HVdllxnEzTEsgIgtxTrCk=
|
||||
github.com/urfave/cli v1.22.10/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20200414173820-0848c9571904/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||
golang.org/x/crypto v0.4.0 h1:UVQgzMY87xqpKNgb+kDsll2Igd33HszWHFLmpaRMq/8=
|
||||
golang.org/x/crypto v0.4.0/go.mod h1:3quD/ATkf6oY+rnes5c3ExXTbLc8mueNue5/DoinL80=
|
||||
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
|
||||
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gopkg.in/yaml.v3 v3.0.0/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
@@ -1,7 +1,6 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
|
||||
@@ -10,16 +9,15 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
version = "0.0.0"
|
||||
build = "0"
|
||||
version = "unknown"
|
||||
)
|
||||
|
||||
func main() {
|
||||
app := cli.NewApp()
|
||||
app.Name = "manifest plugin"
|
||||
app.Usage = "manifest plugin"
|
||||
app.Version = fmt.Sprintf("%s+%s", version, build)
|
||||
app.Action = run
|
||||
app.Version = version
|
||||
app.Flags = []cli.Flag{
|
||||
cli.StringFlag{
|
||||
Name: "username",
|
||||
@@ -31,6 +29,11 @@ func main() {
|
||||
Usage: "password for registry",
|
||||
EnvVar: "PLUGIN_PASSWORD,MANIFEST_PASSWORD,DOCKER_PASSWORD",
|
||||
},
|
||||
cli.BoolFlag{
|
||||
Name: "insecure",
|
||||
Usage: "enable allow insecure registry",
|
||||
EnvVar: "PLUGIN_INSECURE",
|
||||
},
|
||||
cli.StringSliceFlag{
|
||||
Name: "platforms",
|
||||
Usage: "platforms for manifests",
|
||||
@@ -68,6 +71,11 @@ func main() {
|
||||
Usage: "automatically build tags",
|
||||
EnvVar: "PLUGIN_DEFAULT_TAGS,PLUGIN_AUTO_TAG",
|
||||
},
|
||||
cli.BoolFlag{
|
||||
Name: "dump",
|
||||
Usage: "dump the spec to stdout for debug purposes",
|
||||
EnvVar: "PLUGIN_DUMP",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "path",
|
||||
Usage: "git clone path",
|
||||
@@ -183,17 +191,16 @@ func run(c *cli.Context) error {
|
||||
Job: Job{
|
||||
Started: c.Int64("job.started"),
|
||||
},
|
||||
Auto: Auto{
|
||||
Tags: []string{"1.0", "1"},
|
||||
},
|
||||
Config: Config{
|
||||
Username: c.String("username"),
|
||||
Password: c.String("password"),
|
||||
Insecure: c.Bool("insecure"),
|
||||
Platforms: c.StringSlice("platforms"),
|
||||
Target: c.String("target"),
|
||||
Template: c.String("template"),
|
||||
Spec: c.String("spec"),
|
||||
IgnoreMissing: c.Bool("ignore-missing"),
|
||||
Dump: c.Bool("dump"),
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
@@ -1,33 +0,0 @@
|
||||
image: plugins/manifest:{{#if build.tag}}{{trimPrefix build.tag "v"}}{{else}}latest{{/if}}
|
||||
{{#if build.tags}}
|
||||
tags:
|
||||
{{#each build.tags}}
|
||||
- {{this}}
|
||||
{{/each}}
|
||||
{{/if}}
|
||||
manifests:
|
||||
-
|
||||
image: plugins/manifest:{{#if build.tag}}{{trimPrefix build.tag "v"}}-{{/if}}linux-amd64
|
||||
platform:
|
||||
architecture: amd64
|
||||
os: linux
|
||||
-
|
||||
image: plugins/manifest:{{#if build.tag}}{{trimPrefix build.tag "v"}}-{{/if}}linux-i386
|
||||
platform:
|
||||
architecture: 386
|
||||
os: linux
|
||||
-
|
||||
image: plugins/manifest:{{#if build.tag}}{{trimPrefix build.tag "v"}}-{{/if}}linux-arm64
|
||||
platform:
|
||||
architecture: arm64
|
||||
os: linux
|
||||
-
|
||||
image: plugins/manifest:{{#if build.tag}}{{trimPrefix build.tag "v"}}-{{/if}}linux-arm
|
||||
platform:
|
||||
architecture: arm
|
||||
os: linux
|
||||
-
|
||||
image: plugins/manifest:{{#if build.tag}}{{trimPrefix build.tag "v"}}-{{/if}}windows-amd64
|
||||
platform:
|
||||
architecture: amd64
|
||||
os: windows
|
||||
@@ -1,11 +1,16 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
"log"
|
||||
"os"
|
||||
"os/exec"
|
||||
"runtime"
|
||||
"strings"
|
||||
|
||||
"github.com/drone-plugins/drone-manifest/command"
|
||||
"github.com/drone/drone-template-lib/template"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
type (
|
||||
@@ -38,73 +43,119 @@ type (
|
||||
Started int64
|
||||
}
|
||||
|
||||
Auto struct {
|
||||
Tags []string
|
||||
}
|
||||
|
||||
Config struct {
|
||||
Username string
|
||||
Password string
|
||||
Insecure bool
|
||||
Platforms []string
|
||||
Target string
|
||||
Template string
|
||||
Spec string
|
||||
IgnoreMissing bool
|
||||
Dump bool
|
||||
}
|
||||
|
||||
Plugin struct {
|
||||
Repo Repo
|
||||
Build Build
|
||||
Job Job
|
||||
Auto Auto
|
||||
Config Config
|
||||
}
|
||||
)
|
||||
|
||||
func (p *Plugin) Exec() error {
|
||||
opts := make([]command.Option, 0)
|
||||
func mainfestToolPath() string {
|
||||
if runtime.GOOS == "windows" {
|
||||
return "C:/bin/manifest-tool.exe"
|
||||
}
|
||||
|
||||
if p.Config.Username == "" {
|
||||
return "/bin/manifest-tool"
|
||||
}
|
||||
|
||||
func (p *Plugin) Exec() error {
|
||||
args := []string{}
|
||||
|
||||
if p.Config.Username == "" && p.Config.Password != "" {
|
||||
return errors.New("you must provide a username")
|
||||
} else {
|
||||
opts = append(opts, command.WithUsername(p.Config.Username))
|
||||
args = append(args, fmt.Sprintf("--username=%s", p.Config.Username))
|
||||
}
|
||||
|
||||
if p.Config.Password == "" {
|
||||
if p.Config.Password == "" && p.Config.Username != "" {
|
||||
return errors.New("you must provide a password")
|
||||
} else {
|
||||
opts = append(opts, command.WithPassword(p.Config.Password))
|
||||
args = append(args, fmt.Sprintf("--password=%s", p.Config.Password))
|
||||
}
|
||||
|
||||
if p.Config.Spec != "" {
|
||||
spec, err := RenderTrim(p.Config.Spec, p)
|
||||
if p.Config.Insecure {
|
||||
args = append(args, "--insecure")
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
args = append(args, "push")
|
||||
|
||||
if p.Config.Spec != "" {
|
||||
var raw []byte
|
||||
// if spec is not a valid file, assume inlining
|
||||
if _, err := os.Stat(p.Config.Spec); os.IsNotExist(err) {
|
||||
raw = []byte(p.Config.Spec)
|
||||
} else { // otherwise read it
|
||||
raw, err = os.ReadFile(p.Config.Spec)
|
||||
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "failed to read template")
|
||||
}
|
||||
}
|
||||
|
||||
opts = append(opts, command.WithSpec(spec))
|
||||
spec, err := template.RenderTrim(string(raw), p)
|
||||
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "failed to render template")
|
||||
}
|
||||
|
||||
tmpfile, err := os.CreateTemp(p.Build.Path, "manifest-")
|
||||
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "failed to create tempfile")
|
||||
}
|
||||
|
||||
defer os.Remove(tmpfile.Name())
|
||||
|
||||
if _, err := tmpfile.Write([]byte(spec)); err != nil {
|
||||
return errors.Wrap(err, "failed to write tempfile")
|
||||
}
|
||||
|
||||
if err := tmpfile.Close(); err != nil {
|
||||
return errors.Wrap(err, "failed to close tempfile")
|
||||
}
|
||||
|
||||
if p.Config.Dump {
|
||||
println(spec)
|
||||
}
|
||||
|
||||
args = append(args, "from-spec")
|
||||
args = append(args, tmpfile.Name())
|
||||
|
||||
log.Printf(
|
||||
"pushing by spec",
|
||||
)
|
||||
} else {
|
||||
args = append(args, "from-args")
|
||||
|
||||
if len(p.Config.Platforms) == 0 {
|
||||
return errors.New("you must provide platforms")
|
||||
} else {
|
||||
opts = append(opts, command.WithPlatforms(p.Config.Platforms))
|
||||
args = append(args, fmt.Sprintf("--platforms=%s", strings.Join(p.Config.Platforms, ",")))
|
||||
}
|
||||
|
||||
if p.Config.Target == "" {
|
||||
return errors.New("you must provide a target")
|
||||
} else {
|
||||
opts = append(opts, command.WithTarget(p.Config.Target))
|
||||
args = append(args, fmt.Sprintf("--target=%s", p.Config.Target))
|
||||
}
|
||||
|
||||
if p.Config.Template == "" {
|
||||
return errors.New("you must provide a template")
|
||||
} else {
|
||||
opts = append(opts, command.WithTemplate(p.Config.Template))
|
||||
args = append(args, fmt.Sprintf("--template=%s", p.Config.Template))
|
||||
}
|
||||
|
||||
log.Printf(
|
||||
@@ -116,12 +167,20 @@ func (p *Plugin) Exec() error {
|
||||
}
|
||||
|
||||
if p.Config.IgnoreMissing {
|
||||
opts = append(opts, command.IgnoreMissing())
|
||||
args = append(args, "--ignore-missing")
|
||||
}
|
||||
|
||||
cmd := exec.Command(
|
||||
mainfestToolPath(),
|
||||
args...,
|
||||
)
|
||||
|
||||
cmd.Stdout = os.Stdout
|
||||
cmd.Stderr = os.Stderr
|
||||
|
||||
if p.Build.Path != "" {
|
||||
opts = append(opts, command.WithPath(p.Build.Path))
|
||||
cmd.Dir = p.Build.Path
|
||||
}
|
||||
|
||||
return command.New(opts...).Exec()
|
||||
return cmd.Run()
|
||||
}
|
||||
|
||||
+19
-5
@@ -7,6 +7,16 @@ import (
|
||||
"github.com/coreos/go-semver/semver"
|
||||
)
|
||||
|
||||
func splitOff(input string, delim string) string {
|
||||
parts := strings.SplitN(input, delim, 2)
|
||||
|
||||
if len(parts) == 2 {
|
||||
return parts[0]
|
||||
}
|
||||
|
||||
return input
|
||||
}
|
||||
|
||||
// DefaultTags returns a set of default suggested tags.
|
||||
func DefaultTags(ref string) []string {
|
||||
if !strings.HasPrefix(ref, "refs/tags/") {
|
||||
@@ -27,17 +37,21 @@ func DefaultTags(ref string) []string {
|
||||
}
|
||||
}
|
||||
|
||||
v = stripTagPrefix(ref)
|
||||
v = splitOff(splitOff(v, "+"), "-")
|
||||
dotParts := strings.SplitN(v, ".", 3)
|
||||
|
||||
if version.Major == 0 {
|
||||
return []string{
|
||||
fmt.Sprintf("%d.%d", version.Major, version.Minor),
|
||||
fmt.Sprintf("%d.%d.%d", version.Major, version.Minor, version.Patch),
|
||||
fmt.Sprintf("%0*d.%0*d", len(dotParts[0]), version.Major, len(dotParts[1]), version.Minor),
|
||||
fmt.Sprintf("%0*d.%0*d.%0*d", len(dotParts[0]), version.Major, len(dotParts[1]), version.Minor, len(dotParts[2]), version.Patch),
|
||||
}
|
||||
}
|
||||
|
||||
return []string{
|
||||
fmt.Sprint(version.Major),
|
||||
fmt.Sprintf("%d.%d", version.Major, version.Minor),
|
||||
fmt.Sprintf("%d.%d.%d", version.Major, version.Minor, version.Patch),
|
||||
fmt.Sprintf("%0*d", len(dotParts[0]), version.Major),
|
||||
fmt.Sprintf("%0*d.%0*d", len(dotParts[0]), version.Major, len(dotParts[1]), version.Minor),
|
||||
fmt.Sprintf("%0*d.%0*d.%0*d", len(dotParts[0]), version.Major, len(dotParts[1]), version.Minor, len(dotParts[2]), version.Patch),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@ func TestDefaultTags(t *testing.T) {
|
||||
// malformed or errors
|
||||
{"refs/tags/x1.0.0", []string{"latest"}},
|
||||
{"v1.0.0", []string{"latest"}},
|
||||
{"refs/tags/v18.06.0", []string{"18", "18.06", "18.06.0"}},
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
|
||||
-141
@@ -1,141 +0,0 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
"unicode"
|
||||
"unicode/utf8"
|
||||
|
||||
"github.com/aymerick/raymond"
|
||||
)
|
||||
|
||||
func init() {
|
||||
raymond.RegisterHelpers(funcs)
|
||||
}
|
||||
|
||||
// Render parses and executes a template, returning the results in string format.
|
||||
func Render(template string, payload interface{}) (s string, err error) {
|
||||
u, err := url.Parse(template)
|
||||
if err == nil {
|
||||
switch u.Scheme {
|
||||
case "http", "https":
|
||||
res, err := http.Get(template)
|
||||
if err != nil {
|
||||
return s, err
|
||||
}
|
||||
defer res.Body.Close()
|
||||
out, err := ioutil.ReadAll(res.Body)
|
||||
if err != nil {
|
||||
return s, err
|
||||
}
|
||||
template = string(out)
|
||||
|
||||
default:
|
||||
out, err := ioutil.ReadFile(u.Path)
|
||||
if err != nil {
|
||||
return s, err
|
||||
}
|
||||
template = string(out)
|
||||
}
|
||||
}
|
||||
|
||||
return raymond.Render(template, payload)
|
||||
}
|
||||
|
||||
// RenderTrim parses and executes a template, returning the results in string
|
||||
// format. The result is trimmed to remove left and right padding and newlines
|
||||
// that may be added unintentially in the template markup.
|
||||
func RenderTrim(template string, playload interface{}) (string, error) {
|
||||
out, err := Render(template, playload)
|
||||
return strings.Trim(out, " \n"), err
|
||||
}
|
||||
|
||||
var funcs = map[string]interface{}{
|
||||
"uppercase": strings.ToUpper,
|
||||
"lowercase": strings.ToLower,
|
||||
"trimPrefix": strings.TrimPrefix,
|
||||
"trimSuffix": strings.TrimSuffix,
|
||||
"quote": strconv.Quote,
|
||||
"join": strings.Join,
|
||||
"uppercasefirst": uppercaseFirst,
|
||||
"duration": toDuration,
|
||||
"datetime": toDatetime,
|
||||
"success": isSuccess,
|
||||
"failure": isFailure,
|
||||
"truncate": truncate,
|
||||
"urlencode": urlencode,
|
||||
"since": since,
|
||||
}
|
||||
|
||||
func uppercaseFirst(s string) string {
|
||||
a := []rune(s)
|
||||
a[0] = unicode.ToUpper(a[0])
|
||||
s = string(a)
|
||||
return s
|
||||
}
|
||||
|
||||
func toDuration(started, finished float64) string {
|
||||
return fmt.Sprintln(time.Duration(finished-started) * time.Second)
|
||||
}
|
||||
|
||||
func toDatetime(timestamp float64, layout, zone string) string {
|
||||
if len(zone) == 0 {
|
||||
return time.Unix(int64(timestamp), 0).Format(layout)
|
||||
}
|
||||
loc, err := time.LoadLocation(zone)
|
||||
if err != nil {
|
||||
return time.Unix(int64(timestamp), 0).Local().Format(layout)
|
||||
}
|
||||
return time.Unix(int64(timestamp), 0).In(loc).Format(layout)
|
||||
}
|
||||
|
||||
func isSuccess(conditional bool, options *raymond.Options) string {
|
||||
if !conditional {
|
||||
return options.Inverse()
|
||||
}
|
||||
|
||||
switch options.ParamStr(0) {
|
||||
case "success":
|
||||
return options.Fn()
|
||||
default:
|
||||
return options.Inverse()
|
||||
}
|
||||
}
|
||||
|
||||
func isFailure(conditional bool, options *raymond.Options) string {
|
||||
if !conditional {
|
||||
return options.Inverse()
|
||||
}
|
||||
|
||||
switch options.ParamStr(0) {
|
||||
case "failure", "error", "killed":
|
||||
return options.Fn()
|
||||
default:
|
||||
return options.Inverse()
|
||||
}
|
||||
}
|
||||
|
||||
func truncate(s string, len int) string {
|
||||
if utf8.RuneCountInString(s) <= len {
|
||||
return s
|
||||
}
|
||||
runes := []rune(s)
|
||||
return string(runes[:len])
|
||||
}
|
||||
|
||||
func urlencode(options *raymond.Options) string {
|
||||
return url.QueryEscape(options.Fn())
|
||||
}
|
||||
|
||||
func since(start int64) string {
|
||||
// NOTE: not using `time.Since()` because the fractional second component
|
||||
// will give us something like "40m12.917523438s" vs "40m12s". We lose
|
||||
// some precision, but the format is much more readable.
|
||||
now := time.Unix(time.Now().Unix(), 0)
|
||||
return fmt.Sprintln(now.Sub(time.Unix(start, 0)))
|
||||
}
|
||||
Reference in New Issue
Block a user