Compare commits

..

No commits in common. "39d233b3d9eccc68e66508a06a725a2567f33143" and "487521c8bceac11a8e87f4173abf309bfa3b0369" have entirely different histories.

14 changed files with 459 additions and 209 deletions

130
.drone.starlark Normal file
View File

@ -0,0 +1,130 @@
# this starlark script should be used to generate the .drone.yml
# configuration file.
def main(ctx):
# TODO consider running unit tests before building and
# publishing docker images.
before = {}
stages = [
linux('arm'),
linux('arm64'),
linux('amd64'),
windows('1903'),
windows('1809'),
]
after = manifest()
# the after stage should only execute after all previous
# stages complete. this builds the dependency graph.
for stage in stages:
after['depends_on'].append(stage['name'])
return stages + [ after ]
# create a pipeline stage responsible for building and
# publishing the Docker image on linux.
def linux(arch):
return {
'kind': 'pipeline',
'type': 'docker',
'name': 'linux-%s' % arch,
'platform': {
'os': 'linux',
'arch': arch,
},
'steps': [
{
'name': 'build',
'image': 'golang:1.10',
'commands': [
'cd posix',
'tar -xf fixtures.tar -C /',
'go test -v',
],
},
{
'name': 'publish',
'image': 'plugins/docker',
'settings': {
'auto_tag': 'true',
'auto_tag_suffix': 'linux-%s' % arch,
'dockerfile': 'docker/Dockerfile.linux.%s' % arch,
'password': {
'from_secret': 'docker_password',
},
'repo': 'drone/git',
'username': 'drone',
},
'when': {
'event': ['push', 'tag']
}
}
]
}
# create a pipeline stage responsible for building and
# publishing the Docker image on windows. The windows stage
# uses an ssh runner, as opposed to a docker runner.
def windows(version):
return {
'kind': 'pipeline',
'type': 'ssh',
'name': 'windows-%s-amd64' % version,
'platform': {
'os': 'windows'
},
'server': {
'host': { 'from_secret': 'windows_server_%s' % version },
'user': { 'from_secret': 'windows_username' },
'password': { 'from_secret': 'windows_password' },
},
'steps': [
{
'name': 'build',
'environment': {
'USERNAME': { 'from_secret': 'docker_username' },
'PASSWORD': { 'from_secret': 'docker_password' },
},
# TODO these commands build and publish the latest
# docker tag regardless of git tag.
'commands': [
'docker login -u $env:USERNAME -p $env:PASSWORD',
'docker build -f docker/Dockerfile.windows.%s -t drone/git:windows-%s-amd64 .' % (version, version),
'docker push drone/git:windows-%s-amd64' % version,
],
},
],
'trigger': {
'event': ['push']
}
}
# create a pipeline stage responsible for creating and
# publishing a docker manifest to the registry.
def manifest():
return {
'kind': 'pipeline',
'type': 'docker',
'name': 'manifest',
'steps': [
{
'name': 'manifest',
'image': 'plugins/manifest',
'settings': {
'auto_tag': 'true',
'username': 'drone',
'password': {
'from_secret': 'docker_password'
},
'spec': 'docker/manifest.tmpl',
'ignore_missing': 'true',
},
},
],
'depends_on': [],
'trigger': {
'event': ['push', 'tag']
}
}

View File

@ -1,24 +1,23 @@
--- ---
# this file is automatically generated. DO NOT EDIT
kind: pipeline kind: pipeline
type: vm type: docker
name: linux-amd64 name: linux-amd64
platform: platform:
os: linux
arch: amd64 arch: amd64
os: linux
pool:
use: ubuntu
steps: steps:
- name: build - name: build
image: golang:1.10 image: golang:1.10
commands: commands:
- cd posix - cd posix
- tar -xf fixtures.tar -C / - tar -xf fixtures.tar -C /
- go test -v - go test -v
- name: publish - name: publish
image: plugins/docker:18 image: plugins/docker:18
settings: settings:
dockerfile: docker/Dockerfile.linux.amd64 dockerfile: docker/Dockerfile.linux.amd64
@ -36,25 +35,22 @@ steps:
--- ---
kind: pipeline kind: pipeline
type: vm type: docker
name: linux-arm64 name: linux-arm64
platform: platform:
os: linux
arch: arm64 arch: arm64
os: linux
pool:
use: ubuntu_arm64
steps: steps:
- name: build - name: build
image: golang:1.10 image: golang:1.10
commands: commands:
- cd posix - cd posix
- tar -xf fixtures.tar -C / - tar -xf fixtures.tar -C /
- go test -v - go test -v
- name: publish - name: publish
image: plugins/docker:18 image: plugins/docker:18
settings: settings:
dockerfile: docker/Dockerfile.linux.arm64 dockerfile: docker/Dockerfile.linux.arm64
@ -72,30 +68,64 @@ steps:
--- ---
kind: pipeline kind: pipeline
type: vm type: docker
name: windows-1809 name: linux-arm
platform: platform:
os: windows arch: arm
arch: amd64 os: linux
pool:
use: windows
steps: steps:
- name: docker - name: build
image: plugins/docker image: golang:1.10
commands:
- cd posix
- tar -xf fixtures.tar -C /
- go test -v
- name: publish
image: plugins/docker:18
settings: settings:
dockerfile: docker/Dockerfile.windows.1809 dockerfile: docker/Dockerfile.linux.arm
repo: drone/git repo: drone/git
auto_tag: "true"
auto_tag_suffix: linux-arm
username: username:
from_secret: docker_username from_secret: docker_username
password: password:
from_secret: docker_password from_secret: docker_password
auto_tag: true when:
auto_tag_suffix: windows-1809-amd64 event:
daemon_off: true - push
purge: false - tag
---
kind: pipeline
type: ssh
name: windows-1909-amd64
platform:
os: windows
server:
host:
from_secret: windows_server_1909
password:
from_secret: windows_password
user:
from_secret: windows_username
steps:
- name: build
commands:
- docker login -u $env:USERNAME -p $env:PASSWORD
- docker build -f docker/Dockerfile.windows.1909 -t drone/git:windows-1909-amd64 .
- docker push drone/git:windows-1909-amd64
environment:
USERNAME:
from_secret: docker_username
PASSWORD:
from_secret: docker_password
trigger: trigger:
event: event:
@ -103,30 +133,31 @@ trigger:
--- ---
kind: pipeline kind: pipeline
type: vm type: ssh
name: windows-ltsc2022 name: windows-1903-amd64
platform: platform:
os: windows os: windows
arch: amd64
pool: server:
use: windows-2022 host:
from_secret: windows_server_1903
password:
from_secret: windows_password
user:
from_secret: windows_username
steps: steps:
- name: docker - name: build
image: plugins/docker commands:
settings: - docker login -u $env:USERNAME -p $env:PASSWORD
dockerfile: docker/Dockerfile.windows.ltsc2022 - docker build -f docker/Dockerfile.windows.1903 -t drone/git:windows-1903-amd64 .
repo: drone/git - docker push drone/git:windows-1903-amd64
username: environment:
USERNAME:
from_secret: docker_username from_secret: docker_username
password: PASSWORD:
from_secret: docker_password from_secret: docker_password
auto_tag: true
auto_tag_suffix: windows-ltsc2022-amd64
daemon_off: true
purge: false
trigger: trigger:
event: event:
@ -134,18 +165,43 @@ trigger:
--- ---
kind: pipeline kind: pipeline
type: vm type: ssh
name: windows-1809-amd64
platform:
os: windows
server:
host:
from_secret: windows_server_1809
password:
from_secret: windows_password
user:
from_secret: windows_username
steps:
- name: build
commands:
- docker login -u $env:USERNAME -p $env:PASSWORD
- docker build -f docker/Dockerfile.windows.1809 -t drone/git:windows-1809-amd64 .
- docker push drone/git:windows-1809-amd64
environment:
USERNAME:
from_secret: docker_username
PASSWORD:
from_secret: docker_password
trigger:
event:
- push
---
kind: pipeline
type: docker
name: manifest name: manifest
platform:
os: linux
arch: amd64
pool:
use: ubuntu
steps: steps:
- name: manifest - name: manifest
image: plugins/manifest image: plugins/manifest
settings: settings:
auto_tag: "true" auto_tag: "true"
@ -162,7 +218,9 @@ trigger:
- tag - tag
depends_on: depends_on:
- linux-amd64 - linux-amd64
- linux-arm64 - linux-arm64
- windows-1809 - linux-arm
- windows-ltsc2022 - windows-1909-amd64
- windows-1903-amd64
- windows-1809-amd64

View File

@ -16,7 +16,6 @@ Clone a commit:
``` ```
docker run --rm \ docker run --rm \
-e DRONE_WORKSPACE=/drone \
-e DRONE_REMOTE_URL=https://github.com/drone/envsubst.git \ -e DRONE_REMOTE_URL=https://github.com/drone/envsubst.git \
-e DRONE_BUILD_EVENT=push \ -e DRONE_BUILD_EVENT=push \
-e DRONE_COMMIT_SHA=15e3f9b7e16332eee3bbdff9ef31f95d23c5da2c \ -e DRONE_COMMIT_SHA=15e3f9b7e16332eee3bbdff9ef31f95d23c5da2c \

View File

@ -2,10 +2,9 @@ FROM alpine:3.12
RUN apk add --no-cache ca-certificates git git-lfs openssh curl perl aws-cli sudo RUN apk add --no-cache ca-certificates git git-lfs openssh curl perl aws-cli sudo
ADD posix/* /usr/local/bin/ ADD posix/* /usr/local/bin/
RUN adduser -g Drone -s /bin/sh -D -u 1000 drone
# RUN adduser -g Drone -s /bin/sh -D -u 1000 drone RUN echo 'drone ALL=(ALL) NOPASSWD:ALL' > /etc/sudoers.d/drone
# RUN echo 'drone ALL=(ALL) NOPASSWD:ALL' > /etc/sudoers.d/drone USER drone:drone
# USER drone:drone RUN chmod -R 777 /home/drone
# RUN chmod -R 777 /home/drone
ENTRYPOINT ["/usr/local/bin/clone"] ENTRYPOINT ["/usr/local/bin/clone"]

View File

@ -0,0 +1,5 @@
FROM arm32v6/alpine:3.12
RUN apk add --no-cache ca-certificates git git-lfs openssh curl perl
ADD posix/* /usr/local/bin/
ENTRYPOINT ["/usr/local/bin/clone"]

View File

@ -0,0 +1,5 @@
FROM arm32v6/alpine:3.12
RUN apk add --no-cache ca-certificates git git-lfs openssh curl perl
ADD posix/* /usr/local/bin/
ENTRYPOINT ["/usr/local/bin/clone"]

View File

@ -1,11 +1,5 @@
FROM arm64v8/alpine:3.12 FROM arm64v8/alpine:3.12
RUN apk add --no-cache ca-certificates git git-lfs openssh curl perl aws-cli sudo RUN apk add --no-cache ca-certificates git git-lfs openssh curl perl
ADD posix/* /usr/local/bin/ ADD posix/* /usr/local/bin/
# RUN adduser -g Drone -s /bin/sh -D -u 1000 drone
# RUN echo 'drone ALL=(ALL) NOPASSWD:ALL' > /etc/sudoers.d/drone
# USER drone:drone
# RUN chmod -R 777 /home/drone
ENTRYPOINT ["/usr/local/bin/clone"] ENTRYPOINT ["/usr/local/bin/clone"]

View File

@ -0,0 +1,5 @@
FROM arm32v6/alpine:3.12
RUN apk add --no-cache ca-certificates git git-lfs openssh curl perl
ADD posix/* /usr/local/bin/
ENTRYPOINT ["/usr/local/bin/clone"]

View File

@ -0,0 +1,5 @@
FROM arm64v8/alpine:3.12
RUN apk add --no-cache ca-certificates git git-lfs openssh curl perl
ADD posix/* /usr/local/bin/
ENTRYPOINT ["/usr/local/bin/clone"]

View File

@ -1,13 +1,13 @@
# escape=` # escape=`
FROM mcr.microsoft.com/windows/servercore:ltsc2022 AS git FROM mcr.microsoft.com/windows/servercore:1803 AS git
SHELL ["powershell.exe", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"] SHELL ["powershell.exe", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
RUN [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 ; ` RUN [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 ; `
Invoke-WebRequest -UseBasicParsing https://github.com/git-for-windows/git/releases/download/v2.21.0.windows.1/MinGit-2.21.0-64-bit.zip -OutFile git.zip; ` Invoke-WebRequest -UseBasicParsing https://github.com/git-for-windows/git/releases/download/v2.21.0.windows.1/MinGit-2.21.0-64-bit.zip -OutFile git.zip; `
Expand-Archive git.zip -DestinationPath C:\git; Expand-Archive git.zip -DestinationPath C:\git;
FROM mcr.microsoft.com/powershell:nanoserver-ltsc2022 FROM mcr.microsoft.com/powershell:nanoserver-1803
COPY --from=git /git /git COPY --from=git /git /git
ADD windows/* /bin/ ADD windows/* /bin/

View File

@ -0,0 +1,20 @@
# escape=`
FROM mcr.microsoft.com/windows/servercore:1903 AS git
SHELL ["powershell.exe", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
RUN [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 ; `
Invoke-WebRequest -UseBasicParsing https://github.com/git-for-windows/git/releases/download/v2.21.0.windows.1/MinGit-2.21.0-64-bit.zip -OutFile git.zip; `
Expand-Archive git.zip -DestinationPath C:\git;
FROM mcr.microsoft.com/powershell:nanoserver-1903
COPY --from=git /git /git
ADD windows/* /bin/
# https://github.com/PowerShell/PowerShell/issues/6211#issuecomment-367477137
USER ContainerAdministrator
RUN setx /M PATH "%PATH%;C:\Program Files\PowerShell"
SHELL ["pwsh", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
CMD [ "pwsh", "C:\\bin\\clone.ps1" ]

View File

@ -0,0 +1,20 @@
# escape=`
FROM mcr.microsoft.com/windows/servercore:1909 AS git
SHELL ["powershell.exe", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
RUN [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 ; `
Invoke-WebRequest -UseBasicParsing https://github.com/git-for-windows/git/releases/download/v2.21.0.windows.1/MinGit-2.21.0-64-bit.zip -OutFile git.zip; `
Expand-Archive git.zip -DestinationPath C:\git;
FROM mcr.microsoft.com/powershell:nanoserver-1909
COPY --from=git /git /git
ADD windows/* /bin/
# https://github.com/PowerShell/PowerShell/issues/6211#issuecomment-367477137
USER ContainerAdministrator
RUN setx /M PATH "%PATH%;C:\Program Files\PowerShell"
SHELL ["pwsh", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
CMD [ "pwsh", "C:\\bin\\clone.ps1" ]

View File

@ -17,6 +17,24 @@ manifests:
variant: v8 variant: v8
architecture: arm64 architecture: arm64
os: linux os: linux
-
image: drone/git:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}linux-arm
platform:
variant: v7
architecture: arm
os: linux
-
image: drone/git:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}linux-arm
platform:
variant: v6
architecture: arm
os: linux
-
image: drone/git:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}windows-1803-amd64
platform:
architecture: amd64
os: windows
version: 1803
- -
image: drone/git:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}windows-1809-amd64 image: drone/git:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}windows-1809-amd64
platform: platform:
@ -24,8 +42,14 @@ manifests:
os: windows os: windows
version: 1809 version: 1809
- -
image: drone/git:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}windows-ltsc2022-amd64 image: drone/git:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}windows-1903-amd64
platform: platform:
architecture: amd64 architecture: amd64
os: windows os: windows
version: ltsc2022 version: 1903
-
image: drone/git:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}windows-1909-amd64
platform:
architecture: amd64
os: windows
version: 1909

View File

@ -1,25 +1,28 @@
#!/bin/sh #!/bin/sh
if [[ -n "${DRONE_WORKSPACE}" ]]; then if [[ ! -z "${DRONE_WORKSPACE}" ]]; then
# ensure the unprivileged drone user can write if [[ -n "${CI}" ]]; then
# to the workspace. This is required because sudo mkdir -p ${DRONE_WORKSPACE}
# the workspace is a docker volume and is owned sudo chown drone:drone ${DRONE_WORKSPACE}
# by root. else
# sudo mkdir -p ${DRONE_WORKSPACE} mkdir -p ${DRONE_WORKSPACE}
# sudo chown drone:drone ${DRONE_WORKSPACE} fi
# ensure the workspace is the current working
# directory. This should already be the case,
# but we cd just to be safe.
cd ${DRONE_WORKSPACE} cd ${DRONE_WORKSPACE}
fi fi
# force the home directory path. # we default home directory to /home/drone
# if [ "$HOME" != "/home/drone" ]; then if [ "$HOME" != "/home/drone" ]; then
# echo "[DEBUG] setting default home directory" export HOME=/home/drone
# export HOME=/home/drone fi
# fi
# if the home directory does not exist it should
# be created.
if [ ! -d "${HOME}" ]; then
echo "HOME directory does not exist; creating ${HOME}"
mkdir -p ${HOME}
fi
# if the netrc enviornment variables exist, write # if the netrc enviornment variables exist, write
# the netrc file. # the netrc file.
@ -87,31 +90,14 @@ case $DRONE_COMMIT_REF in
refs/merge-requests/* ) CLONE_TYPE=pull_request ;; refs/merge-requests/* ) CLONE_TYPE=pull_request ;;
esac esac
git_clone_retry(){
retries="${PLUGIN_RETRIES:-0}"
if [ -n "${retries##*[0-9]*}" ] || [ "${retries}" -lt 0 ]; then
echo "PLUGIN_RETRIES defined but is not a number: ${retries}" >&2
exit 1
fi
echo "Cloning with ${retries} retries"
n=0
until [ "$n" -gt "${retries}" ]; do
$1 && return
n=$((n+1))
done
exit 1
}
case $CLONE_TYPE in case $CLONE_TYPE in
pull_request) pull_request)
git_clone_retry clone-pull-request clone-pull-request
;; ;;
tag) tag)
git_clone_retry clone-tag clone-tag
;; ;;
*) *)
git_clone_retry clone-commit clone-commit
;; ;;
esac esac