diff --git a/docker/Dockerfile.windows.1803 b/docker/Dockerfile.windows.1803 index cbd58a7..888dbea 100644 --- a/docker/Dockerfile.windows.1803 +++ b/docker/Dockerfile.windows.1803 @@ -6,6 +6,9 @@ SHELL ["powershell.exe", "-Command", "$ErrorActionPreference = 'Stop'; $Progress 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; +RUN [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 ; ` + Invoke-WebRequest -UseBasicParsing https://github.com/git-lfs/git-lfs/releases/download/v2.12.0/git-lfs-windows-amd64-v2.12.0.zip -OutFile git-lfs.zip; ` + Expand-Archive git-lfs.zip -DestinationPath C:\git\lfs; FROM mcr.microsoft.com/powershell:nanoserver-1803 COPY --from=git /git /git diff --git a/docker/Dockerfile.windows.1809 b/docker/Dockerfile.windows.1809 index 936400d..5a8c48e 100644 --- a/docker/Dockerfile.windows.1809 +++ b/docker/Dockerfile.windows.1809 @@ -6,6 +6,9 @@ SHELL ["powershell.exe", "-Command", "$ErrorActionPreference = 'Stop'; $Progress 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; +RUN [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 ; ` + Invoke-WebRequest -UseBasicParsing https://github.com/git-lfs/git-lfs/releases/download/v2.12.0/git-lfs-windows-amd64-v2.12.0.zip -OutFile git-lfs.zip; ` + Expand-Archive git-lfs.zip -DestinationPath C:\git\lfs; FROM mcr.microsoft.com/powershell:nanoserver-1809 COPY --from=git /git /git diff --git a/docker/Dockerfile.windows.1903 b/docker/Dockerfile.windows.1903 index 71982da..2c630c4 100644 --- a/docker/Dockerfile.windows.1903 +++ b/docker/Dockerfile.windows.1903 @@ -6,6 +6,9 @@ SHELL ["powershell.exe", "-Command", "$ErrorActionPreference = 'Stop'; $Progress 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; +RUN [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 ; ` + Invoke-WebRequest -UseBasicParsing https://github.com/git-lfs/git-lfs/releases/download/v2.12.0/git-lfs-windows-amd64-v2.12.0.zip -OutFile git-lfs.zip; ` + Expand-Archive git-lfs.zip -DestinationPath C:\git\lfs; FROM mcr.microsoft.com/powershell:nanoserver-1903 COPY --from=git /git /git diff --git a/docker/Dockerfile.windows.1909 b/docker/Dockerfile.windows.1909 index 7e53708..8aa645d 100644 --- a/docker/Dockerfile.windows.1909 +++ b/docker/Dockerfile.windows.1909 @@ -6,6 +6,9 @@ SHELL ["powershell.exe", "-Command", "$ErrorActionPreference = 'Stop'; $Progress 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; +RUN [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 ; ` + Invoke-WebRequest -UseBasicParsing https://github.com/git-lfs/git-lfs/releases/download/v2.12.0/git-lfs-windows-amd64-v2.12.0.zip -OutFile git-lfs.zip; ` + Expand-Archive git-lfs.zip -DestinationPath C:\git\lfs; FROM mcr.microsoft.com/powershell:nanoserver-1909 COPY --from=git /git /git diff --git a/docker/Dockerfile.windows.ltsc2022 b/docker/Dockerfile.windows.ltsc2022 new file mode 100644 index 0000000..c38995a --- /dev/null +++ b/docker/Dockerfile.windows.ltsc2022 @@ -0,0 +1,25 @@ +# escape=` + +FROM mcr.microsoft.com/windows/servercore:ltsc2022 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; +RUN [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 ; ` + Invoke-WebRequest -UseBasicParsing https://github.com/git-lfs/git-lfs/releases/download/v2.12.0/git-lfs-windows-amd64-v2.12.0.zip -OutFile git-lfs.zip; ` + Expand-Archive git-lfs.zip -DestinationPath C:\git\lfs; + +FROM mcr.microsoft.com/powershell:windowsserver-ltsc2022 +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;c:\git\lfs\;c:\git\cmd" + +SHELL ["pwsh", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"] +CMD [ "pwsh", "C:\\bin\\clone.ps1" ] + +LABEL org.opencontainers.image.source=https://github.com/johanvdw/drone-git/ diff --git a/windows/clone-commit.ps1 b/windows/clone-commit.ps1 index 43566c5..05aa31c 100644 --- a/windows/clone-commit.ps1 +++ b/windows/clone-commit.ps1 @@ -1,9 +1,3 @@ - -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 @@ -11,7 +5,8 @@ if (!(Test-Path .git)) { 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 fetch origin +refs/heads/${Env:DRONE_COMMIT_BRANCH}:"; +git fetch 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; +git lfs logs last \ No newline at end of file diff --git a/windows/clone-tag.ps1 b/windows/clone-tag.ps1 index a37a3f1..04b3992 100644 --- a/windows/clone-tag.ps1 +++ b/windows/clone-tag.ps1 @@ -1,13 +1,8 @@ -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 fetch origin "+refs/tags/${Env:DRONE_TAG}:" git checkout -qf FETCH_HEAD diff --git a/windows/clone.ps1 b/windows/clone.ps1 index 4be8cc4..cb09bcc 100644 --- a/windows/clone.ps1 +++ b/windows/clone.ps1 @@ -1,8 +1,8 @@ $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' +# so am setting it here instead. This is not ideal. +$Env:PATH += ';C:\git\cmd;C:\git\mingw64\bin;C:\git\usr\bin;c:\git\lfs\git-lfs-2.12.0' # if the workspace is set we should make sure # it is the current working directory. @@ -21,6 +21,13 @@ login $Env:DRONE_NETRC_USERNAME password $Env:DRONE_NETRC_PASSWORD "@ > (Join-Path $Env:USERPROFILE '_netrc'); } +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: