mirror of
https://github.com/drone/drone-git.git
synced 2026-06-16 14:50:26 +08:00
Compare commits
25 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| a01800911c | |||
| dddd99c40a | |||
| a2c9b60089 | |||
| a818535cfc | |||
| 584c0ee731 | |||
| 68c60db9d5 | |||
| 214a9d2492 | |||
| 059b7b18b0 | |||
| 5f6bea6871 | |||
| b7b05f526c | |||
| 1ef9ff7e4d | |||
| 3174a3cfd3 | |||
| 6dca8731a7 | |||
| 1b0a44afc1 | |||
| 1fc5fded5a | |||
| e7468f9a19 | |||
| 419d29331d | |||
| 7bb19442db | |||
| f290e93029 | |||
| 16d4b8019f | |||
| 7a6564cc28 | |||
| 95ae01e6dd | |||
| 1bd2db0719 | |||
| 6b831bd981 | |||
| 0014fd5f14 |
@@ -0,0 +1,74 @@
|
||||
local windows_pipe = '\\\\\\\\.\\\\pipe\\\\docker_engine';
|
||||
local windows_pipe_volume = 'docker_pipe';
|
||||
local versions = [
|
||||
//'1803',
|
||||
'1809',
|
||||
];
|
||||
local trigger = {
|
||||
ref: [
|
||||
'refs/heads/master',
|
||||
'refs/tags/**',
|
||||
],
|
||||
};
|
||||
local pipeline_name(version) = 'Windows ' + version;
|
||||
|
||||
local pipeline(version, arch) = {
|
||||
kind: 'pipeline',
|
||||
name: pipeline_name(version),
|
||||
|
||||
platform: {
|
||||
os: 'windows',
|
||||
arch: arch,
|
||||
version: version,
|
||||
},
|
||||
|
||||
steps: [{
|
||||
name: 'git',
|
||||
image: 'plugins/docker:windows-1809', // TODO: This should just use the manifest
|
||||
settings: {
|
||||
repo: 'drone/git',
|
||||
dockerfile: 'docker/Dockerfile.windows.' + version,
|
||||
auto_tag: true,
|
||||
auto_tag_suffix: 'windows-' + version + '-' + arch,
|
||||
|
||||
username: { from_secret: 'docker_username' },
|
||||
password: { from_secret: 'docker_password' },
|
||||
|
||||
// Windows specific options
|
||||
daemon_off: true,
|
||||
purge: 'false', // TODO: Fix bug where setting false won't generate the yaml value
|
||||
},
|
||||
volumes: [{ name: windows_pipe_volume, path: windows_pipe }],
|
||||
}],
|
||||
|
||||
volumes: [{ name: windows_pipe_volume, host: { path: windows_pipe } }],
|
||||
trigger: trigger,
|
||||
};
|
||||
|
||||
[
|
||||
pipeline(version, 'amd64')
|
||||
for version in versions
|
||||
] + [
|
||||
{
|
||||
kind: 'pipeline',
|
||||
name: 'Image Manifest',
|
||||
|
||||
steps: [{
|
||||
name: 'manifest',
|
||||
image: 'plugins/manifest',
|
||||
settings: {
|
||||
spec: 'docker/manifest.tmpl',
|
||||
ignore_missing: true,
|
||||
|
||||
username: { from_secret: 'docker_username' },
|
||||
password: { from_secret: 'docker_password' },
|
||||
},
|
||||
}],
|
||||
|
||||
depends_on: [
|
||||
pipeline_name(version)
|
||||
for version in versions
|
||||
],
|
||||
trigger: trigger,
|
||||
},
|
||||
]
|
||||
@@ -0,0 +1,65 @@
|
||||
---
|
||||
kind: pipeline
|
||||
name: Windows 1809
|
||||
|
||||
platform:
|
||||
os: windows
|
||||
arch: amd64
|
||||
version: 1809
|
||||
|
||||
steps:
|
||||
- name: git
|
||||
image: plugins/docker:windows-1809
|
||||
settings:
|
||||
auto_tag: true
|
||||
auto_tag_suffix: windows-1809-amd64
|
||||
daemon_off: true
|
||||
dockerfile: docker/Dockerfile.windows.1809
|
||||
password:
|
||||
from_secret: docker_password
|
||||
purge: false
|
||||
repo: drone/git
|
||||
username:
|
||||
from_secret: docker_username
|
||||
volumes:
|
||||
- name: docker_pipe
|
||||
path: \\\\.\\pipe\\docker_engine
|
||||
|
||||
volumes:
|
||||
- name: docker_pipe
|
||||
host:
|
||||
path: \\\\.\\pipe\\docker_engine
|
||||
|
||||
trigger:
|
||||
ref:
|
||||
- refs/heads/master
|
||||
- "refs/tags/**"
|
||||
|
||||
---
|
||||
kind: pipeline
|
||||
name: Image Manifest
|
||||
|
||||
platform:
|
||||
os: linux
|
||||
arch: amd64
|
||||
|
||||
steps:
|
||||
- name: manifest
|
||||
image: plugins/manifest
|
||||
settings:
|
||||
ignore_missing: true
|
||||
password:
|
||||
from_secret: docker_password
|
||||
spec: docker/manifest.tmpl
|
||||
username:
|
||||
from_secret: docker_username
|
||||
|
||||
trigger:
|
||||
ref:
|
||||
- refs/heads/master
|
||||
- "refs/tags/**"
|
||||
|
||||
depends_on:
|
||||
- Windows 1809
|
||||
|
||||
...
|
||||
@@ -0,0 +1,24 @@
|
||||
# drone-git
|
||||
|
||||
Drone plugin to clone `git` repositories.
|
||||
|
||||
## Build
|
||||
|
||||
Build the Docker image with the following commands:
|
||||
|
||||
```
|
||||
docker build --rm -f docker/Dockerfile.linux.amd64 -t drone/git .
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
Clone a commit:
|
||||
|
||||
```
|
||||
docker run --rm \
|
||||
-e DRONE_REMOTE_URL=https://github.com/drone/envsubst.git \
|
||||
-e DRONE_BUILD_EVENT=push \
|
||||
-e DRONE_COMMIT_SHA=15e3f9b7e16332eee3bbdff9ef31f95d23c5da2c \
|
||||
-e DRONE_COMMIT_BRANCH=master \
|
||||
drone/git
|
||||
```
|
||||
@@ -1,5 +1,5 @@
|
||||
FROM alpine:3.6
|
||||
RUN apk add --no-cache ca-certificates git openssh curl perl
|
||||
FROM alpine:3.7
|
||||
RUN apk add --no-cache ca-certificates git git-lfs openssh curl perl
|
||||
|
||||
ADD posix/* /usr/local/bin/
|
||||
ENTRYPOINT ["/usr/local/bin/clone"]
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
FROM arm32v6/alpine:3.6
|
||||
RUN apk add --no-cache ca-certificates git openssh curl perl
|
||||
FROM arm32v6/alpine:3.7
|
||||
RUN apk add --no-cache ca-certificates git git-lfs openssh curl perl
|
||||
|
||||
ADD posix/* /usr/local/bin/
|
||||
ENTRYPOINT ["/usr/local/bin/clone"]
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
FROM arm32v6/alpine:3.6
|
||||
RUN apk add --no-cache ca-certificates git openssh curl perl
|
||||
FROM arm32v6/alpine:3.7
|
||||
RUN apk add --no-cache ca-certificates git git-lfs openssh curl perl
|
||||
|
||||
ADD posix/* /usr/local/bin/
|
||||
ENTRYPOINT ["/usr/local/bin/clone"]
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
FROM arm64v8/alpine:3.6
|
||||
RUN apk add --no-cache ca-certificates git openssh curl perl
|
||||
FROM arm64v8/alpine:3.7
|
||||
RUN apk add --no-cache ca-certificates git git-lfs openssh curl perl
|
||||
|
||||
ADD posix/* /usr/local/bin/
|
||||
ENTRYPOINT ["/usr/local/bin/clone"]
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
FROM arm32v6/alpine:3.6
|
||||
RUN apk add --no-cache ca-certificates git openssh curl perl
|
||||
FROM arm32v6/alpine:3.7
|
||||
RUN apk add --no-cache ca-certificates git git-lfs openssh curl perl
|
||||
|
||||
ADD posix/* /usr/local/bin/
|
||||
ENTRYPOINT ["/usr/local/bin/clone"]
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
FROM arm64v8/alpine:3.6
|
||||
RUN apk add --no-cache ca-certificates git openssh curl perl
|
||||
FROM arm64v8/alpine:3.7
|
||||
RUN apk add --no-cache ca-certificates git git-lfs openssh curl perl
|
||||
|
||||
ADD posix/* /usr/local/bin/
|
||||
ENTRYPOINT ["/usr/local/bin/clone"]
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
FROM microsoft/windowsservercore:1803 AS git
|
||||
# escape=`
|
||||
|
||||
FROM mcr.microsoft.com/windows/servercore:1803 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.19.0-rc2.windows.1/MinGit-2.19.0.rc2.windows.1-64-bit.zip -OutFile git.zip; \
|
||||
Expand-Archive git.zip -DestinationPath C:\git
|
||||
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 microsoft/powershell:nanoserver-1803
|
||||
FROM mcr.microsoft.com/powershell:nanoserver-1803
|
||||
COPY --from=git /git /git
|
||||
|
||||
ADD windows/* /bin/
|
||||
@@ -14,7 +16,5 @@ ADD windows/* /bin/
|
||||
USER ContainerAdministrator
|
||||
RUN setx /M PATH "%PATH%;C:\Program Files\PowerShell"
|
||||
|
||||
ENV HOME C:\\Users\\ContainerAdministrator
|
||||
|
||||
SHELL ["pwsh", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
|
||||
CMD [ "pwsh", "C:\\bin\\clone.ps1" ]
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
FROM microsoft/windowsservercore:1709 AS git
|
||||
# escape=`
|
||||
|
||||
FROM mcr.microsoft.com/windows/servercore:1809 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.19.0-rc2.windows.1/MinGit-2.19.0.rc2.windows.1-64-bit.zip -OutFile git.zip; \
|
||||
Expand-Archive git.zip -DestinationPath C:\git
|
||||
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 microsoft/powershell:nanoserver-1709
|
||||
FROM mcr.microsoft.com/powershell:nanoserver-1809
|
||||
COPY --from=git /git /git
|
||||
|
||||
ADD windows/* /bin/
|
||||
@@ -14,7 +16,5 @@ ADD windows/* /bin/
|
||||
USER ContainerAdministrator
|
||||
RUN setx /M PATH "%PATH%;C:\Program Files\PowerShell"
|
||||
|
||||
ENV HOME C:\\Users\\ContainerAdministrator
|
||||
|
||||
SHELL ["pwsh", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
|
||||
CMD [ "pwsh", "C:\\bin\\clone.ps1" ]
|
||||
+10
-4
@@ -24,8 +24,14 @@ manifests:
|
||||
architecture: arm
|
||||
os: linux
|
||||
-
|
||||
image: drone/git:windows-1803
|
||||
image: drone/git:windows-1803-amd64
|
||||
platform:
|
||||
architecture: arm
|
||||
os: linux
|
||||
os.version: 10.0.17134.165
|
||||
architecture: amd64
|
||||
os: windows
|
||||
version: 1803
|
||||
-
|
||||
image: drone/git:windows-1809-amd64
|
||||
platform:
|
||||
architecture: amd64
|
||||
os: windows
|
||||
version: 1809
|
||||
|
||||
+18
-6
@@ -32,18 +32,30 @@ fi
|
||||
# configure git global behavior and parameters via the
|
||||
# following environment variables:
|
||||
|
||||
export GIT_AUTHOR_NAME=${DRONE_COMMIT_AUTHOR_NAME=drone}
|
||||
export GIT_AUTHOR_EMAIL=${DRONE_COMMIT_AUTHOR_EMAIL=drone@localhost}
|
||||
export GIT_COMMITTER_NAME=${GIT_AUTHOR_NAME}
|
||||
export GIT_COMMITTER_EMAIL=${GIT_AUTHOR_EMAIL}
|
||||
# GIT_SSL_NO_VERIFY=
|
||||
|
||||
if [[ -z "${DRONE_COMMIT_AUTHOR_NAME}" ]]; then
|
||||
export DRONE_COMMIT_AUTHOR_NAME=drone
|
||||
fi
|
||||
|
||||
if [[ -z "${DRONE_COMMIT_AUTHOR_EMAIL}" ]]; then
|
||||
export DRONE_COMMIT_AUTHOR_EMAIL=drone@localhost
|
||||
fi
|
||||
|
||||
export GIT_AUTHOR_NAME=${DRONE_COMMIT_AUTHOR_NAME}
|
||||
export GIT_AUTHOR_EMAIL=${DRONE_COMMIT_AUTHOR_EMAIL}
|
||||
export GIT_COMMITTER_NAME=${DRONE_COMMIT_AUTHOR_NAME}
|
||||
export GIT_COMMITTER_EMAIL=${DRONE_COMMIT_AUTHOR_EMAIL}
|
||||
|
||||
# invoke the sub-script based on the drone event type.
|
||||
# TODO we should ultimately look at the ref, since
|
||||
# we need something compatible with deployment events.
|
||||
|
||||
case $DRONE_BUILD_EVENT in
|
||||
CLONE_TYPE=$DRONE_BUILD_EVENT
|
||||
case $DRONE_COMMIT_REF in
|
||||
refs/tags/* ) CLONE_TYPE=tag ;;
|
||||
esac
|
||||
|
||||
case $CLONE_TYPE in
|
||||
pull_request)
|
||||
clone-pull-request
|
||||
;;
|
||||
|
||||
@@ -17,4 +17,4 @@ git fetch ${FLAGS} origin +refs/heads/${DRONE_COMMIT_BRANCH}:
|
||||
git checkout ${DRONE_COMMIT_BRANCH}
|
||||
|
||||
git fetch origin ${DRONE_COMMIT_REF}:
|
||||
git rebase ${DRONE_COMMIT_SHA}
|
||||
git merge ${DRONE_COMMIT_SHA}
|
||||
|
||||
@@ -1 +1,3 @@
|
||||
package posix
|
||||
|
||||
//go:generate go run ../scripts/includetext.go --input=clone --input=clone-commit --input=clone-pull-request --input=clone-tag --package=posix --output=posix_gen.go
|
||||
|
||||
@@ -0,0 +1,137 @@
|
||||
package posix
|
||||
|
||||
// DO NOT EDIT. This file is automatically generated.
|
||||
|
||||
// Contents of clone
|
||||
const Clone = `#!/bin/sh
|
||||
|
||||
if [[ ! -z "${DRONE_WORKSPACE}" ]]; then
|
||||
cd ${DRONE_WORKSPACE}
|
||||
fi
|
||||
|
||||
# if the netrc enviornment variables exist, write
|
||||
# the netrc file.
|
||||
|
||||
if [[ ! -z "${DRONE_NETRC_MACHINE}" ]]; then
|
||||
cat <<EOF > /root/.netrc
|
||||
machine ${DRONE_NETRC_MACHINE}
|
||||
login ${DRONE_NETRC_USERNAME}
|
||||
password ${DRONE_NETRC_PASSWORD}
|
||||
EOF
|
||||
fi
|
||||
|
||||
# if the ssh_key environment variable exists, write
|
||||
# the ssh key and add the netrc machine to the
|
||||
# known hosts file.
|
||||
|
||||
if [[ ! -z "${SSH_KEY}" ]]; then
|
||||
mkdir /root/.ssh
|
||||
echo -n "$SSH_KEY" > /root/.ssh/id_rsa
|
||||
chmod 600 /root/.ssh/id_rsa
|
||||
|
||||
touch /root/.ssh/known_hosts
|
||||
chmod 600 /root/.ssh/known_hosts
|
||||
ssh-keyscan -H ${DRONE_NETRC_MACHINE} > /etc/ssh/ssh_known_hosts 2> /dev/null
|
||||
fi
|
||||
|
||||
# configure git global behavior and parameters via the
|
||||
# following environment variables:
|
||||
|
||||
|
||||
if [[ -z "${DRONE_COMMIT_AUTHOR_NAME}" ]]; then
|
||||
export DRONE_COMMIT_AUTHOR_NAME=drone
|
||||
fi
|
||||
|
||||
if [[ -z "${DRONE_COMMIT_AUTHOR_EMAIL}" ]]; then
|
||||
export DRONE_COMMIT_AUTHOR_EMAIL=drone@localhost
|
||||
fi
|
||||
|
||||
export GIT_AUTHOR_NAME=${DRONE_COMMIT_AUTHOR_NAME}
|
||||
export GIT_AUTHOR_EMAIL=${DRONE_COMMIT_AUTHOR_EMAIL}
|
||||
export GIT_COMMITTER_NAME=${DRONE_COMMIT_AUTHOR_NAME}
|
||||
export GIT_COMMITTER_EMAIL=${DRONE_COMMIT_AUTHOR_EMAIL}
|
||||
|
||||
# invoke the sub-script based on the drone event type.
|
||||
# TODO we should ultimately look at the ref, since
|
||||
# we need something compatible with deployment events.
|
||||
|
||||
CLONE_TYPE=$DRONE_BUILD_EVENT
|
||||
case $DRONE_COMMIT_REF in
|
||||
refs/tags/* ) CLONE_TYPE=tag ;;
|
||||
esac
|
||||
|
||||
case $CLONE_TYPE in
|
||||
pull_request)
|
||||
clone-pull-request
|
||||
;;
|
||||
tag)
|
||||
clone-tag
|
||||
;;
|
||||
*)
|
||||
clone-commit
|
||||
;;
|
||||
esac
|
||||
`
|
||||
|
||||
// Contents of clone-commit
|
||||
const CloneCommit = `#!/bin/sh
|
||||
|
||||
FLAGS=""
|
||||
if [[ ! -z "${PLUGIN_DEPTH}" ]]; then
|
||||
FLAGS="--depth=${PLUGIN_DEPTH}"
|
||||
fi
|
||||
|
||||
if [ ! -d .git ]; then
|
||||
git init
|
||||
git remote add origin ${DRONE_REMOTE_URL}
|
||||
fi
|
||||
|
||||
set -e
|
||||
set -x
|
||||
|
||||
git fetch ${FLAGS} origin +refs/heads/${DRONE_COMMIT_BRANCH}:
|
||||
git checkout ${DRONE_COMMIT_SHA} -b ${DRONE_COMMIT_BRANCH}
|
||||
`
|
||||
|
||||
// Contents of clone-pull-request
|
||||
const ClonePullRequest = `#!/bin/sh
|
||||
|
||||
FLAGS=""
|
||||
if [[ ! -z "${PLUGIN_DEPTH}" ]]; then
|
||||
FLAGS="--depth=${PLUGIN_DEPTH}"
|
||||
fi
|
||||
|
||||
if [ ! -d .git ]; then
|
||||
git init
|
||||
git remote add origin ${DRONE_REMOTE_URL}
|
||||
fi
|
||||
|
||||
set -e
|
||||
set -x
|
||||
|
||||
git fetch ${FLAGS} origin +refs/heads/${DRONE_COMMIT_BRANCH}:
|
||||
git checkout ${DRONE_COMMIT_BRANCH}
|
||||
|
||||
git fetch origin ${DRONE_COMMIT_REF}:
|
||||
git merge ${DRONE_COMMIT_SHA}
|
||||
`
|
||||
|
||||
// Contents of clone-tag
|
||||
const CloneTag = `#!/bin/sh
|
||||
|
||||
FLAGS=""
|
||||
if [[ ! -z "${PLUGIN_DEPTH}" ]]; then
|
||||
FLAGS="--depth=${PLUGIN_DEPTH}"
|
||||
fi
|
||||
|
||||
if [ ! -d .git ]; then
|
||||
git init
|
||||
git remote add origin ${DRONE_REMOTE_URL}
|
||||
fi
|
||||
|
||||
set -e
|
||||
set -x
|
||||
|
||||
git fetch ${FLAGS} origin +refs/tags/${DRONE_TAG}:
|
||||
git checkout -qf FETCH_HEAD
|
||||
`
|
||||
@@ -0,0 +1,87 @@
|
||||
// +build ignore
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"flag"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"text/template"
|
||||
)
|
||||
|
||||
var (
|
||||
input stringSlice
|
||||
output string
|
||||
name string
|
||||
)
|
||||
|
||||
func main() {
|
||||
flag.Var(&input, "input", "input files")
|
||||
flag.StringVar(&output, "output", "", "output file")
|
||||
flag.StringVar(&name, "package", "", "package name")
|
||||
flag.Parse()
|
||||
|
||||
var files []File
|
||||
for _, file := range input {
|
||||
out, err := ioutil.ReadFile(file)
|
||||
if err != nil {
|
||||
log.Fatalln(err)
|
||||
}
|
||||
files = append(files, File{
|
||||
Name: file,
|
||||
Slug: slugify(file),
|
||||
Data: string(out),
|
||||
})
|
||||
}
|
||||
|
||||
data := map[string]interface{}{
|
||||
"Files": files,
|
||||
"Package": name,
|
||||
}
|
||||
buf := new(bytes.Buffer)
|
||||
err := tmpl.Execute(buf, data)
|
||||
if err != nil {
|
||||
log.Fatalln(err)
|
||||
}
|
||||
|
||||
ioutil.WriteFile(output, buf.Bytes(), 0644)
|
||||
}
|
||||
|
||||
func slugify(s string) string {
|
||||
ext := filepath.Ext(s)
|
||||
s = strings.TrimSuffix(s, ext)
|
||||
s = strings.Title(s)
|
||||
s = strings.ReplaceAll(s, "-", "")
|
||||
s = strings.ReplaceAll(s, "_", "")
|
||||
return s
|
||||
}
|
||||
|
||||
type stringSlice []string
|
||||
|
||||
func (s *stringSlice) String() string {
|
||||
return strings.Join(*s, ",")
|
||||
}
|
||||
|
||||
func (s *stringSlice) Set(value string) error {
|
||||
*s = append(*s, value)
|
||||
return nil
|
||||
}
|
||||
|
||||
type File struct {
|
||||
Name string
|
||||
Data string
|
||||
Slug string
|
||||
}
|
||||
|
||||
var tmpl = template.Must(template.New("_").Parse(`package {{ .Package }}
|
||||
|
||||
// DO NOT EDIT. This file is automatically generated.
|
||||
|
||||
{{ range .Files -}}
|
||||
// Contents of {{ .Name }}
|
||||
const {{ .Slug }} = ` + "`{{ .Data }}`" + `
|
||||
|
||||
{{ end -}}`))
|
||||
@@ -5,9 +5,13 @@ if ($Env:PLUGIN_DEPTH) {
|
||||
}
|
||||
|
||||
if (!(Test-Path .git)) {
|
||||
Write-Host 'git init';
|
||||
git init
|
||||
Write-Host "git remote add origin $Env:DRONE_REMOTE_URL"
|
||||
git remote add origin $Env:DRONE_REMOTE_URL
|
||||
}
|
||||
|
||||
git fetch $FLAGS origin "+refs/heads/${Env:DRONE_COMMIT_BRANCH}:"
|
||||
git checkout $Env:DRONE_COMMIT_SHA -b $Env:DRONE_COMMIT_BRANCH
|
||||
Write-Host "git fetch $FLAGS origin +refs/heads/${Env:DRONE_COMMIT_BRANCH}:";
|
||||
git fetch $FLAGS origin "+refs/heads/${Env:DRONE_COMMIT_BRANCH}:";
|
||||
Write-Host "git checkout $Env:DRONE_COMMIT_SHA -f $Env:DRONE_COMMIT_BRANCH";
|
||||
git checkout $Env:DRONE_COMMIT_SHA -b $Env:DRONE_COMMIT_BRANCH;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
|
||||
Set-Variable -Name "FLAGS" -Value ""
|
||||
if ($Env:PLUGIN_DEPTH) {
|
||||
Set-Variable -Name "FLAGS" -Value "--depth=$Env:PLUGIN_DEPTH"
|
||||
Set-Variable -Name "FLAGS" -Value "--depth=$Env:PLUGIN_DEPTH"
|
||||
}
|
||||
|
||||
if (!(Test-Path .git)) {
|
||||
@@ -12,5 +12,5 @@ if (!(Test-Path .git)) {
|
||||
git fetch $FLAGS origin "+refs/heads/${Env:DRONE_COMMIT_BRANCH}:"
|
||||
git checkout $Env:DRONE_COMMIT_BRANCH
|
||||
|
||||
git fetch origin $Env:DRONE_COMMIT_REF:
|
||||
git rebase $Env:DRONE_COMMIT_SHA
|
||||
git fetch origin "${Env:DRONE_COMMIT_REF}:"
|
||||
git merge $Env:DRONE_COMMIT_SHA
|
||||
|
||||
+13
-13
@@ -15,11 +15,11 @@ if ($Env:DRONE_WORKSPACE) {
|
||||
# the netrc file.
|
||||
|
||||
if ($Env:DRONE_NETRC_MACHINE) {
|
||||
|
||||
$netrc=[string]::Format("{0}\_netrc",$Env:HOME);
|
||||
"machine $Env:CI_NETRC_MACHINE" >> $netrc;
|
||||
"login $Env:CI_NETRC_USERNAME" >> $netrc;
|
||||
"password $Env:CI_NETRC_PASSWORD" >> $netrc;
|
||||
@"
|
||||
machine $Env:DRONE_NETRC_MACHINE
|
||||
login $Env:DRONE_NETRC_USERNAME
|
||||
password $Env:DRONE_NETRC_PASSWORD
|
||||
"@ > (Join-Path $Env:USERPROFILE '_netrc');
|
||||
}
|
||||
|
||||
# configure git global behavior and parameters via the
|
||||
@@ -29,16 +29,16 @@ if ($Env:PLUGIN_SKIP_VERIFY) {
|
||||
$Env:GIT_SSL_NO_VERIFY = "true"
|
||||
}
|
||||
|
||||
if ($Env:DRONE_COMMIT_AUTHOR_NAME) {
|
||||
$Env:GIT_AUTHOR_NAME = $Env:DRONE_COMMIT_AUTHOR_NAME
|
||||
} else {
|
||||
if ($Env:DRONE_COMMIT_AUTHOR_NAME -eq '' -or $Env:DRONE_COMMIT_AUTHOR_NAME -eq $null) {
|
||||
$Env:GIT_AUTHOR_NAME = "drone"
|
||||
} else {
|
||||
$Env:GIT_AUTHOR_NAME = $Env:DRONE_COMMIT_AUTHOR_NAME
|
||||
}
|
||||
|
||||
if ($Env:DRONE_COMMIT_AUTHOR_NAME) {
|
||||
$Env:GIT_AUTHOR_NAME = $Env:DRONE_COMMIT_AUTHOR_NAME
|
||||
if ($Env:DRONE_COMMIT_AUTHOR_EMAIL -eq '' -or $Env:DRONE_COMMIT_AUTHOR_EMAIL -eq $null) {
|
||||
$Env:GIT_AUTHOR_EMAIL = 'drone@localhost'
|
||||
} else {
|
||||
$Env:GIT_AUTHOR_NAME = 'drone@localhost'
|
||||
$Env:GIT_AUTHOR_EMAIL = $Env:DRONE_COMMIT_AUTHOR_EMAIL
|
||||
}
|
||||
|
||||
$Env:GIT_COMMITTER_NAME = $Env:GIT_AUTHOR_NAME
|
||||
@@ -50,7 +50,7 @@ $Env:GIT_COMMITTER_EMAIL = $Env:GIT_AUTHOR_EMAIL
|
||||
|
||||
switch ($Env:DRONE_BUILD_EVENT) {
|
||||
"pull_request" {
|
||||
Invoke-Expression "${PSScriptRoot}\clone-pull-reqest.ps1"
|
||||
Invoke-Expression "${PSScriptRoot}\clone-pull-request.ps1"
|
||||
break
|
||||
}
|
||||
"tag" {
|
||||
@@ -61,4 +61,4 @@ switch ($Env:DRONE_BUILD_EVENT) {
|
||||
Invoke-Expression "${PSScriptRoot}\clone-commit.ps1"
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
package windows
|
||||
|
||||
//go:generate go run ../scripts/includetext.go --input=clone.ps1 --input=clone-commit.ps1 --input=clone-pull-request.ps1 --input=clone-tag.ps1 --package=windows --output=windows_gen.go
|
||||
@@ -0,0 +1,125 @@
|
||||
package windows
|
||||
|
||||
// DO NOT EDIT. This file is automatically generated.
|
||||
|
||||
// Contents of clone.ps1
|
||||
const Clone = `$ErrorActionPreference = 'Stop';
|
||||
|
||||
# HACK: no clue how to set the PATH inside the Dockerfile,
|
||||
# so am setting it here instead. This is not idea.
|
||||
$Env:PATH += ';C:\git\cmd;C:\git\mingw64\bin;C:\git\usr\bin'
|
||||
|
||||
# if the workspace is set we should make sure
|
||||
# it is the current working directory.
|
||||
|
||||
if ($Env:DRONE_WORKSPACE) {
|
||||
cd $Env:DRONE_WORKSPACE
|
||||
}
|
||||
|
||||
# if the netrc enviornment variables exist, write
|
||||
# the netrc file.
|
||||
|
||||
if ($Env:DRONE_NETRC_MACHINE) {
|
||||
@"
|
||||
machine $Env:DRONE_NETRC_MACHINE
|
||||
login $Env:DRONE_NETRC_USERNAME
|
||||
password $Env:DRONE_NETRC_PASSWORD
|
||||
"@ > (Join-Path $Env:USERPROFILE '_netrc');
|
||||
}
|
||||
|
||||
# configure git global behavior and parameters via the
|
||||
# following environment variables:
|
||||
|
||||
if ($Env:PLUGIN_SKIP_VERIFY) {
|
||||
$Env:GIT_SSL_NO_VERIFY = "true"
|
||||
}
|
||||
|
||||
if ($Env:DRONE_COMMIT_AUTHOR_NAME) {
|
||||
$Env:GIT_AUTHOR_NAME = $Env:DRONE_COMMIT_AUTHOR_NAME
|
||||
} else {
|
||||
$Env:GIT_AUTHOR_NAME = "drone"
|
||||
}
|
||||
|
||||
if ($Env:DRONE_COMMIT_AUTHOR_NAME) {
|
||||
$Env:GIT_AUTHOR_NAME = $Env:DRONE_COMMIT_AUTHOR_NAME
|
||||
} else {
|
||||
$Env:GIT_AUTHOR_NAME = 'drone@localhost'
|
||||
}
|
||||
|
||||
$Env:GIT_COMMITTER_NAME = $Env:GIT_AUTHOR_NAME
|
||||
$Env:GIT_COMMITTER_EMAIL = $Env:GIT_AUTHOR_EMAIL
|
||||
|
||||
# invoke the sub-script based on the drone event type.
|
||||
# TODO we should ultimately look at the ref, since
|
||||
# we need something compatible with deployment events.
|
||||
|
||||
switch ($Env:DRONE_BUILD_EVENT) {
|
||||
"pull_request" {
|
||||
Invoke-Expression "${PSScriptRoot}\clone-pull-request.ps1"
|
||||
break
|
||||
}
|
||||
"tag" {
|
||||
Invoke-Expression "${PSScriptRoot}\clone-tag.ps1"
|
||||
break
|
||||
}
|
||||
default {
|
||||
Invoke-Expression "${PSScriptRoot}\clone-commit.ps1"
|
||||
break
|
||||
}
|
||||
}
|
||||
`
|
||||
|
||||
// Contents of clone-commit.ps1
|
||||
const CloneCommit = `
|
||||
Set-Variable -Name "FLAGS" -Value ""
|
||||
if ($Env:PLUGIN_DEPTH) {
|
||||
Set-Variable -Name "FLAGS" -Value "--depth=$Env:PLUGIN_DEPTH"
|
||||
}
|
||||
|
||||
if (!(Test-Path .git)) {
|
||||
Write-Host 'git init';
|
||||
git init
|
||||
Write-Host "git remote add origin $Env:DRONE_REMOTE_URL"
|
||||
git remote add origin $Env:DRONE_REMOTE_URL
|
||||
}
|
||||
|
||||
Write-Host "git fetch $FLAGS origin +refs/heads/${Env:DRONE_COMMIT_BRANCH}:";
|
||||
git fetch $FLAGS origin "+refs/heads/${Env:DRONE_COMMIT_BRANCH}:";
|
||||
Write-Host "git checkout $Env:DRONE_COMMIT_SHA -f $Env:DRONE_COMMIT_BRANCH";
|
||||
git checkout $Env:DRONE_COMMIT_SHA -b $Env:DRONE_COMMIT_BRANCH;
|
||||
`
|
||||
|
||||
// Contents of clone-pull-request.ps1
|
||||
const ClonePullRequest = `
|
||||
Set-Variable -Name "FLAGS" -Value ""
|
||||
if ($Env:PLUGIN_DEPTH) {
|
||||
Set-Variable -Name "FLAGS" -Value "--depth=$Env:PLUGIN_DEPTH"
|
||||
}
|
||||
|
||||
if (!(Test-Path .git)) {
|
||||
git init
|
||||
git remote add origin $Env:DRONE_REMOTE_URL
|
||||
}
|
||||
|
||||
git fetch $FLAGS origin "+refs/heads/${Env:DRONE_COMMIT_BRANCH}:"
|
||||
git checkout $Env:DRONE_COMMIT_BRANCH
|
||||
|
||||
git fetch origin $Env:DRONE_COMMIT_REF:
|
||||
git rebase $Env:DRONE_COMMIT_SHA
|
||||
`
|
||||
|
||||
// Contents of clone-tag.ps1
|
||||
const CloneTag = `
|
||||
Set-Variable -Name "FLAGS" -Value ""
|
||||
if ($Env:PLUGIN_DEPTH) {
|
||||
Set-Variable -Name "FLAGS" -Value "--depth=$Env:PLUGIN_DEPTH"
|
||||
}
|
||||
|
||||
if (!(Test-Path .git)) {
|
||||
git init
|
||||
git remote add origin $Env:DRONE_REMOTE_URL
|
||||
}
|
||||
|
||||
git fetch $FLAGS origin "+refs/tags/${Env:DRONE_TAG}:"
|
||||
git checkout -qf FETCH_HEAD
|
||||
`
|
||||
Reference in New Issue
Block a user