Skip to content

Commit 1c0d50b

Browse files
authored
Add Ubuntu 20.04 (#422)
1 parent 97b027c commit 1c0d50b

File tree

14 files changed

+309
-27
lines changed

14 files changed

+309
-27
lines changed

.dependabot/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ update_configs:
3232
update_schedule: "weekly"
3333

3434
- package_manager: "docker"
35-
directory: "/release/preview/ubuntu18.04/dependabot"
35+
directory: "/release/preview/ubuntu20.04/docker"
3636
update_schedule: "weekly"
3737

3838
- package_manager: "docker"

.vsts-ci/releasePhase.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,25 @@ jobs:
2626
displayName: ${{ parameters.jobName }}
2727

2828
steps:
29+
- task: DownloadBuildArtifacts@0
30+
displayName: 'Download Build Artifacts'
31+
inputs:
32+
downloadType: specific
33+
itemPattern: buildMeta/**/*.json
34+
- powershell: |
35+
$json = Get-ChildItem $(System.ArtifactsDirectory)/buildmeta.json -recurse -File
36+
if($json.Count -ge 1)
37+
{
38+
$jsonText = Get-Content -Path $json.FullName
39+
$fullTag = ($jsonText | ConvertFrom-Json).FullTag
40+
Write-Verbose "setting FULL_TAG to $fullTag" -verbose
41+
Write-Host "##vso[task.setvariable variable=FULL_TAG;]$fullTag"
42+
}
43+
else{
44+
Write-Verbose "Did not find buildmeta json" -verbose
45+
}
46+
displayName: Set FULL_TAG variable
47+
2948
- pwsh: |
3049
Write-Host "##vso[task.setvariable variable=ACR_NAME;]$env:ACR_NAME_VAR"
3150
displayName: 'Enable ACR'

.vsts-ci/releaseStage.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ parameters:
77

88
stages:
99
- stage: GenerateYaml_${{ parameters.channel }}
10-
dependsOn: []
10+
dependsOn: ['GenerateFullTag']
1111
displayName: Build ${{ parameters.channel }}
1212
jobs:
1313
- job: GenerateYaml_${{ parameters.channel }}

.vsts-ci/releasebuild.yml

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,25 @@ variables:
88
POWERSHELL_TELEMETRY_OPTOUT: 1
99

1010
stages:
11+
- stage: GenerateFullTag
12+
displayName: Generate Full Tag
13+
jobs:
14+
- job: GenerateFullTag
15+
16+
displayName: Generate Full Tag
17+
18+
condition: succeededOrFailed()
19+
pool:
20+
vmImage: ubuntu-latest
21+
timeoutInMinutes: 30
22+
23+
steps:
24+
- pwsh: |
25+
$path = '$(SYSTEM.DEFAULTWORKINGDIRECTORY)/BuildMeta.json'
26+
@{
27+
FullTag = (Get-Date).ToString("yyyyMMdd")
28+
} | ConvertTo-Json | Out-File -Encoding utf8NoBOM -FilePath ./BuildMeta.json
29+
Write-Host "##vso[artifact.upload containerfolder=buildMeta;artifactname=buildMeta]$path"
1130
- template: releaseStage.yml
1231
parameters:
1332
channel: stable
@@ -54,7 +73,7 @@ stages:
5473
- template: manifestSteps.yml
5574

5675
- stage: GenerateTagsYaml
57-
dependsOn: []
76+
dependsOn: ['GenerateFullTag']
5877
jobs:
5978
- job: GenerateTagsYaml
6079

@@ -66,6 +85,25 @@ stages:
6685
timeoutInMinutes: 30
6786

6887
steps:
88+
- task: DownloadBuildArtifacts@0
89+
displayName: 'Download Build Artifacts'
90+
inputs:
91+
downloadType: specific
92+
itemPattern: buildMeta/**/*.json
93+
- powershell: |
94+
$json = Get-ChildItem $(System.ArtifactsDirectory)/buildmeta.json -recurse -File
95+
if($json.Count -ge 1)
96+
{
97+
$jsonText = Get-Content -Path $json.FullName
98+
$fullTag = ($jsonText | ConvertFrom-Json).FullTag
99+
Write-Verbose "setting FULL_TAG to $fullTag" -verbose
100+
Write-Host "##vso[task.setvariable variable=FULL_TAG;]$fullTag"
101+
}
102+
else{
103+
Write-Verbose "Did not find buildmeta json" -verbose
104+
}
105+
displayName: Set FULL_TAG variable
106+
69107
- powershell: |
70108
$stableVersion = '$(stableReleaseTag)' -replace '^v', ''
71109
Write-Host "##vso[task.setvariable variable=StableVersion;]$stableVersion"

release/lts/debian11/test-deps/meta.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@
1111
"test-deps-debian"
1212
],
1313
"TestProperties": {
14-
"size": 316
14+
"size": 332
1515
}
1616
}

release/preview/debian11/test-deps/meta.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@
1111
"test-deps-debian"
1212
],
1313
"TestProperties": {
14-
"size": 316
14+
"size": 332
1515
}
1616
}

release/preview/ubuntu18.04/dependabot/Dockerfile

Lines changed: 0 additions & 6 deletions
This file was deleted.
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
# Docker image file that describes an Ubuntu20.04 image with PowerShell installed from Microsoft APT Repo
2+
FROM ubuntu:20.04 AS installer-env
3+
4+
# Define Args for the needed to add the package
5+
ARG PS_VERSION=6.2.4
6+
ARG PS_PACKAGE=powershell-${PS_VERSION}-linux-x64.tar.gz
7+
ARG PS_PACKAGE_URL=https://github.com/PowerShell/PowerShell/releases/download/v${PS_VERSION}/${PS_PACKAGE}
8+
ARG PS_INSTALL_VERSION=7-preview
9+
10+
# Download the Linux tar.gz and save it
11+
ADD ${PS_PACKAGE_URL} /tmp/linux.tar.gz
12+
13+
RUN echo ${PS_PACKAGE_URL}
14+
15+
# define the folder we will be installing PowerShell to
16+
ENV PS_INSTALL_FOLDER=/opt/microsoft/powershell/$PS_INSTALL_VERSION
17+
18+
# Create the install folder
19+
RUN mkdir -p ${PS_INSTALL_FOLDER}
20+
21+
# Unzip the Linux tar.gz
22+
RUN tar zxf /tmp/linux.tar.gz -C ${PS_INSTALL_FOLDER}
23+
24+
# Start a new stage so we lose all the tar.gz layers from the final image
25+
FROM ubuntu:20.04 AS powershell
26+
27+
ARG PS_VERSION=6.2.0-preview.3
28+
ARG PS_INSTALL_VERSION=7-preview
29+
30+
# Copy only the files we need from the previous stage
31+
COPY --from=installer-env ["/opt/microsoft/powershell", "/opt/microsoft/powershell"]
32+
33+
# Define Args and Env needed to create links
34+
ARG PS_INSTALL_VERSION=7-preview
35+
ENV PS_INSTALL_FOLDER=/opt/microsoft/powershell/$PS_INSTALL_VERSION \
36+
\
37+
# Define ENVs for Localization/Globalization
38+
DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=false \
39+
LC_ALL=en_US.UTF-8 \
40+
LANG=en_US.UTF-8 \
41+
# set a fixed location for the Module analysis cache
42+
PSModuleAnalysisCachePath=/var/cache/microsoft/powershell/PSModuleAnalysisCache/ModuleAnalysisCache \
43+
POWERSHELL_DISTRIBUTION_CHANNEL=PSDocker-Debian-11
44+
45+
# Install dependencies and clean up
46+
RUN apt-get update \
47+
&& apt-get install --no-install-recommends -y \
48+
# less is required for help in powershell
49+
less \
50+
# requied to setup the locale
51+
locales \
52+
# required for SSL
53+
ca-certificates \
54+
gss-ntlmssp \
55+
libicu66 \
56+
libssl1.1 \
57+
libc6 \
58+
libgcc1 \
59+
libgssapi-krb5-2 \
60+
liblttng-ust0 \
61+
libstdc++6 \
62+
zlib1g \
63+
# Download the Linux package and save it
64+
&& apt-get dist-upgrade -y \
65+
&& apt-get clean \
66+
&& rm -rf /var/lib/apt/lists/* \
67+
&& locale-gen $LANG && update-locale
68+
69+
# Give all user execute permissions and remove write permissions for others
70+
RUN chmod a+x,o-w ${PS_INSTALL_FOLDER}/pwsh \
71+
# Create the pwsh symbolic link that points to powershell
72+
&& ln -s ${PS_INSTALL_FOLDER}/pwsh /usr/bin/pwsh \
73+
# intialize powershell module cache
74+
&& pwsh \
75+
-NoLogo \
76+
-NoProfile \
77+
-Command " \
78+
\$ErrorActionPreference = 'Stop' ; \
79+
\$ProgressPreference = 'SilentlyContinue' ; \
80+
while(!(Test-Path -Path \$env:PSModuleAnalysisCachePath)) { \
81+
Write-Host "'Waiting for $env:PSModuleAnalysisCachePath'" ; \
82+
Start-Sleep -Seconds 6 ; \
83+
}"
84+
85+
# Define args needed only for the labels
86+
ARG VCS_REF="none"
87+
ARG IMAGE_NAME=mcr.microsoft.com/powershell:ubuntu18.04
88+
89+
LABEL maintainer="PowerShell Team <powershellteam@hotmail.com>" \
90+
readme.md="https://github.com/PowerShell/PowerShell/blob/master/docker/README.md" \
91+
description="This Dockerfile will install the latest release of PowerShell." \
92+
org.label-schema.usage="https://github.com/PowerShell/PowerShell/tree/master/docker#run-the-docker-image-you-built" \
93+
org.label-schema.url="https://github.com/PowerShell/PowerShell/blob/master/docker/README.md" \
94+
org.label-schema.vcs-url="https://github.com/PowerShell/PowerShell-Docker" \
95+
org.label-schema.name="powershell" \
96+
org.label-schema.vendor="PowerShell" \
97+
org.label-schema.version=${PS_VERSION} \
98+
org.label-schema.schema-version="1.0" \
99+
org.label-schema.vcs-ref=${VCS_REF} \
100+
org.label-schema.docker.cmd="docker run ${IMAGE_NAME} pwsh -c '$psversiontable'" \
101+
org.label-schema.docker.cmd.devel="docker run ${IMAGE_NAME}" \
102+
org.label-schema.docker.cmd.test="docker run ${IMAGE_NAME} pwsh -c Invoke-Pester" \
103+
org.label-schema.docker.cmd.help="docker run ${IMAGE_NAME} pwsh -c Get-Help"
104+
105+
# Use PowerShell as the default shell
106+
# Use array to avoid Docker prepending /bin/sh -c
107+
CMD [ "pwsh-preview" ]

release/preview/ubuntu20.04/meta.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"IsLinux" : true,
3+
"UseLinuxVersion": false,
4+
"PackageFormat": "powershell-${PS_VERSION}-linux-x64.tar.gz",
5+
"osVersion": "Ubuntu 20.04",
6+
"SkipGssNtlmSspTests": false,
7+
"shortTags": [
8+
{"Tag": "20.04"}
9+
],
10+
"tagTemplates": [
11+
"#psversion#-ubuntu-#tag#",
12+
"preview-ubuntu-#shorttag#"
13+
],
14+
"TestProperties": {
15+
"size": 355
16+
},
17+
"SubImage": "test-deps"
18+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Docker image file that describes an Ubuntu image with PowerShell and test dependencies
2+
ARG BaseImage=mcr.microsoft.com/powershell:ubuntu-20.04
3+
4+
FROM ${BaseImage}
5+
6+
# Install dependencies and clean up
7+
RUN apt-get update \
8+
&& apt-get install --no-install-recommends -y \
9+
sudo \
10+
curl \
11+
wget \
12+
iputils-ping \
13+
iputils-tracepath \
14+
&& apt-get clean \
15+
&& rm -rf /var/lib/apt/lists/*
16+
17+
ENV POWERSHELL_DISTRIBUTION_CHANNEL=PSDocker-TestDeps-Ubuntu-20.04
18+
19+
# Define args needed only for the labels
20+
ARG VCS_REF="none"
21+
ARG IMAGE_NAME=mcr.microsoft.com/powershell/test-deps:ubuntu-20.04
22+
ARG PS_VERSION=6.2.3
23+
24+
LABEL maintainer="PowerShell Team <powershellteam@hotmail.com>" \
25+
readme.md="https://github.com/PowerShell/PowerShell/blob/master/docker/README.md" \
26+
description="This Dockerfile will install the latest release of PowerShell and tools needed for runing CI/CD container jobs." \
27+
org.label-schema.usage="https://github.com/PowerShell/PowerShell/tree/master/docker#run-the-docker-image-you-built" \
28+
org.label-schema.url="https://github.com/PowerShell/PowerShell/blob/master/docker/README.md" \
29+
org.label-schema.vcs-url="https://github.com/PowerShell/PowerShell-Docker" \
30+
org.label-schema.name="powershell" \
31+
org.label-schema.vendor="PowerShell" \
32+
org.label-schema.version=${PS_VERSION} \
33+
org.label-schema.schema-version="1.0" \
34+
org.label-schema.vcs-ref=${VCS_REF} \
35+
org.label-schema.docker.cmd="docker run ${IMAGE_NAME} pwsh -c '$psversiontable'" \
36+
org.label-schema.docker.cmd.devel="docker run ${IMAGE_NAME}" \
37+
org.label-schema.docker.cmd.test="docker run ${IMAGE_NAME} pwsh -c Invoke-Pester" \
38+
org.label-schema.docker.cmd.help="docker run ${IMAGE_NAME} pwsh -c Get-Help"
39+
40+
# Use PowerShell as the default shell
41+
# Use array to avoid Docker prepending /bin/sh -c
42+
CMD [ "pwsh" ]
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"IsLinux" : true,
3+
"UseLinuxVersion": false,
4+
"osVersion": "Ubuntu 20.04",
5+
"tagTemplates": [
6+
"preview-ubuntu-#shorttag#"
7+
],
8+
"SubRepository": "test-deps",
9+
"OptionalTests": [
10+
"test-deps",
11+
"test-deps-debian"
12+
],
13+
"TestProperties": {
14+
"size": 358
15+
}
16+
}

release/stable/debian11/test-deps/meta.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@
1111
"test-deps-debian"
1212
],
1313
"TestProperties": {
14-
"size": 316
14+
"size": 332
1515
}
1616
}

tools/buildHelper/buildHelper.psm1

Lines changed: 30 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
1-
# Copyright (c) Microsoft Corporation. All rights reserved.
1+
# Copyright (c) Microsoft Corporation.
22
# Licensed under the MIT License.
33

44
# Gets the current version of PowerShell from the PowerShell repo
55
# or formats the version based on the parameters
66

7+
$parent = Join-Path -Path $PSScriptRoot -ChildPath '..'
8+
$repoRoot = Join-Path -path $parent -ChildPath '..'
9+
$modulePath = Join-Path -Path $repoRoot -ChildPath 'tools\getDockerTags'
10+
Import-Module $modulePath -Force
11+
712
function Get-PowerShellVersion
813
{
914
[CmdletBinding(DefaultParameterSetName='Default')]
@@ -428,10 +433,11 @@ function Get-DockerImageMetaDataWrapper
428433
$scriptPath = Join-Path -Path $imagePath -ChildPath 'getLatestTag.ps1'
429434
$metaJsonPath = Join-Path -Path $imagePath -ChildPath 'meta.json'
430435

431-
# skip an image if it doesn't exist
432-
if(!(Test-Path $scriptPath) -and !$TagData)
433-
{
434-
return
436+
if ($env:FULL_TAG) {
437+
$fullTag = $env:FULL_TAG
438+
}
439+
else {
440+
$fullTag = (Get-Date).ToString("yyyyMMdd")
435441
}
436442

437443
$meta = Get-DockerImageMetaData -Path $metaJsonPath
@@ -458,17 +464,27 @@ function Get-DockerImageMetaDataWrapper
458464

459465
if(!$TagData)
460466
{
461-
# Get the tag data for the image
462-
$tagDataFromScript = @(& $scriptPath -CI:$CI.IsPresent @getTagsExtraParams | Where-Object {$_.FromTag})
463-
Write-Verbose "tdfs count:$($tagDataFromScript.count)-$($Strict.IsPresent)"
464-
if($tagDataFromScript.count -eq 0 -and $Strict.IsPresent)
467+
if((Test-Path $scriptPath) )
465468
{
466-
throw "Did not get tag data from script for $scriptPath!"
467-
}
469+
# Get the tag data for the image
470+
$tagDataFromScript = @(& $scriptPath -CI:$CI.IsPresent @getTagsExtraParams | Where-Object {$_.FromTag})
471+
Write-Verbose "tdfs count:$($tagDataFromScript.count)-$($Strict.IsPresent)"
472+
if($tagDataFromScript.count -eq 0 -and $Strict.IsPresent)
473+
{
474+
throw "Did not get tag data from script for $scriptPath!"
475+
}
468476

469-
if($TagFilter)
470-
{
471-
$tagDataFromScript = @($tagDataFromScript | Where-Object { $_.FromTag -match $TagFilter })
477+
if($TagFilter)
478+
{
479+
$tagDataFromScript = @($tagDataFromScript | Where-Object { $_.FromTag -match $TagFilter })
480+
}
481+
}
482+
else {
483+
Write-Verbose "getting docker tag list" -Verbose
484+
if($shortTags)
485+
{
486+
$tagDataFromScript = Get-DockerTagList -ShortTag $shortTags -FullTag $fullTag
487+
}
472488
}
473489
}
474490
elseif ($meta.TagMapping)

0 commit comments

Comments
 (0)