From ecc8bee5ad5577bd848f50d88fb85a890382fd5d Mon Sep 17 00:00:00 2001 From: Aleks Date: Mon, 14 Mar 2022 00:37:08 +0100 Subject: [PATCH 01/70] building docker image in workflows --- .github/workflows/nightlyrelease.yml | 40 +++++----------------- docker/pnppowershell-prerelease.dockerFile | 6 ++++ 2 files changed, 15 insertions(+), 31 deletions(-) create mode 100644 docker/pnppowershell-prerelease.dockerFile diff --git a/.github/workflows/nightlyrelease.yml b/.github/workflows/nightlyrelease.yml index 0e01889e5..fb8c7d6c7 100644 --- a/.github/workflows/nightlyrelease.yml +++ b/.github/workflows/nightlyrelease.yml @@ -2,40 +2,18 @@ name: Nightly Release to PowerShell Gallery on: workflow_dispatch: - schedule: - - cron: '30 2 * * *' + push: + branches: + - dev + paths: + - 'docker/**' jobs: build: - runs-on: windows-latest + runs-on: ubuntu-latest steps: - - name: Setup .NET Core - uses: actions/setup-dotnet@v1 - with: - dotnet-version: | - 3.1.301 - 5.x - - uses: actions/checkout@v2 - with: - ref: dev - token: ${{ secrets.PAT }} - - name: Build and Publish Module - env: - POWERSHELLGALLERY_API_KEY: ${{ secrets.POWERSHELLGALLERY_API_KEY }} - shell: pwsh + - name: Build an image run: | - ./build/Build-Nightly.ps1 - - name: Set variables - shell: pwsh - run: | - $version = Get-Content version.txt -raw - "BUILDVERSION=$version" | Out-File $env:GITHUB_ENV -Encoding utf8 -Append - - name: Add & Commit - uses: EndBug/add-and-commit@v6 - with: - message: 'Nightly publish to PowerShell Gallery' - tag: '${{env.BUILDVERSION}}-nightly --force' - push: true - branch: dev - token: ${{ secrets.PAT }} + VERSION=$(cat ./version.txt) + docker build --build-arg "PNP_MODULE_VERSION=$VERSION" ./docker -f ./docker/pnppowershell-prerelease.dockerFile --tag pnp-powershell:$VERSION diff --git a/docker/pnppowershell-prerelease.dockerFile b/docker/pnppowershell-prerelease.dockerFile new file mode 100644 index 000000000..333283f76 --- /dev/null +++ b/docker/pnppowershell-prerelease.dockerFile @@ -0,0 +1,6 @@ +FROM mcr.microsoft.com/powershell:7.2.1-alpine-3.14-20211215 + +SHELL ["pwsh", "-command"] +ARG PNP_MODULE_VERSION +RUN Write-Host $env:PNP_MODULE_VERSION +RUN Install-Module -Name PnP.PowerShell -RequiredVersion $env:PNP_MODULE_VERSION -Force -AllowPrerelease From a55bae383573b0cd09ced796ff19014c2f159d44 Mon Sep 17 00:00:00 2001 From: Aleks Date: Mon, 14 Mar 2022 00:42:02 +0100 Subject: [PATCH 02/70] ls --- .github/workflows/nightlyrelease.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/nightlyrelease.yml b/.github/workflows/nightlyrelease.yml index fb8c7d6c7..c1c8b70eb 100644 --- a/.github/workflows/nightlyrelease.yml +++ b/.github/workflows/nightlyrelease.yml @@ -15,5 +15,6 @@ jobs: steps: - name: Build an image run: | + ls VERSION=$(cat ./version.txt) docker build --build-arg "PNP_MODULE_VERSION=$VERSION" ./docker -f ./docker/pnppowershell-prerelease.dockerFile --tag pnp-powershell:$VERSION From 0df806796b0833cf38cd6b410d2f4bc95b95ebb6 Mon Sep 17 00:00:00 2001 From: Aleks Date: Mon, 14 Mar 2022 00:45:00 +0100 Subject: [PATCH 03/70] cd dev --- .github/workflows/nightlyrelease.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/nightlyrelease.yml b/.github/workflows/nightlyrelease.yml index c1c8b70eb..7b18ca2f3 100644 --- a/.github/workflows/nightlyrelease.yml +++ b/.github/workflows/nightlyrelease.yml @@ -15,6 +15,7 @@ jobs: steps: - name: Build an image run: | + cd dev ls VERSION=$(cat ./version.txt) docker build --build-arg "PNP_MODULE_VERSION=$VERSION" ./docker -f ./docker/pnppowershell-prerelease.dockerFile --tag pnp-powershell:$VERSION From 12d3e6f84bddd7dc3cb64d6823a7bbc627526301 Mon Sep 17 00:00:00 2001 From: Aleks Date: Mon, 14 Mar 2022 00:48:51 +0100 Subject: [PATCH 04/70] checkout --- .github/workflows/nightlyrelease.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/nightlyrelease.yml b/.github/workflows/nightlyrelease.yml index 7b18ca2f3..2217bb19d 100644 --- a/.github/workflows/nightlyrelease.yml +++ b/.github/workflows/nightlyrelease.yml @@ -13,8 +13,10 @@ jobs: runs-on: ubuntu-latest steps: + - uses: actions/checkout@v2 - name: Build an image run: | + ls cd dev ls VERSION=$(cat ./version.txt) From 18f75ca4dbf299868208e296b74fe5d2e7dd40e8 Mon Sep 17 00:00:00 2001 From: Aleks Date: Mon, 14 Mar 2022 00:50:24 +0100 Subject: [PATCH 05/70] removing debug output --- .github/workflows/nightlyrelease.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/nightlyrelease.yml b/.github/workflows/nightlyrelease.yml index 2217bb19d..c58c1cbe6 100644 --- a/.github/workflows/nightlyrelease.yml +++ b/.github/workflows/nightlyrelease.yml @@ -16,8 +16,5 @@ jobs: - uses: actions/checkout@v2 - name: Build an image run: | - ls - cd dev - ls VERSION=$(cat ./version.txt) docker build --build-arg "PNP_MODULE_VERSION=$VERSION" ./docker -f ./docker/pnppowershell-prerelease.dockerFile --tag pnp-powershell:$VERSION From ac8acae6139fa651e86c9bdbb5d36f13eefaf60d Mon Sep 17 00:00:00 2001 From: Aleks Date: Mon, 14 Mar 2022 01:05:41 +0100 Subject: [PATCH 06/70] nightly version --- .github/workflows/nightlyrelease.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/nightlyrelease.yml b/.github/workflows/nightlyrelease.yml index c58c1cbe6..b2125cc48 100644 --- a/.github/workflows/nightlyrelease.yml +++ b/.github/workflows/nightlyrelease.yml @@ -16,5 +16,5 @@ jobs: - uses: actions/checkout@v2 - name: Build an image run: | - VERSION=$(cat ./version.txt) + VERSION=$(cat ./version.txt)-nightly docker build --build-arg "PNP_MODULE_VERSION=$VERSION" ./docker -f ./docker/pnppowershell-prerelease.dockerFile --tag pnp-powershell:$VERSION From 99e27dc4fd849c8af91b0696e053cf461bbd160a Mon Sep 17 00:00:00 2001 From: Aleks Date: Mon, 14 Mar 2022 01:22:27 +0100 Subject: [PATCH 07/70] docker login --- .github/workflows/nightlyrelease.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/nightlyrelease.yml b/.github/workflows/nightlyrelease.yml index b2125cc48..86ff47a31 100644 --- a/.github/workflows/nightlyrelease.yml +++ b/.github/workflows/nightlyrelease.yml @@ -18,3 +18,4 @@ jobs: run: | VERSION=$(cat ./version.txt)-nightly docker build --build-arg "PNP_MODULE_VERSION=$VERSION" ./docker -f ./docker/pnppowershell-prerelease.dockerFile --tag pnp-powershell:$VERSION + docker login -u asapozhkov -p ${{ secrets.GITHUB_TOKEN }} From 902f251ae7674a416f05ffb0fc1ee454168f4635 Mon Sep 17 00:00:00 2001 From: Aleks Date: Mon, 14 Mar 2022 01:23:40 +0100 Subject: [PATCH 08/70] docker secret --- .github/workflows/nightlyrelease.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/nightlyrelease.yml b/.github/workflows/nightlyrelease.yml index 86ff47a31..c7c56587e 100644 --- a/.github/workflows/nightlyrelease.yml +++ b/.github/workflows/nightlyrelease.yml @@ -18,4 +18,4 @@ jobs: run: | VERSION=$(cat ./version.txt)-nightly docker build --build-arg "PNP_MODULE_VERSION=$VERSION" ./docker -f ./docker/pnppowershell-prerelease.dockerFile --tag pnp-powershell:$VERSION - docker login -u asapozhkov -p ${{ secrets.GITHUB_TOKEN }} + docker login -u asapozhkov -p ${{ secrets.DOCKER_TOKEN }} From 7777e912cd514fa455f4a3ffcf2f7242c0dcdd15 Mon Sep 17 00:00:00 2001 From: Aleks Date: Mon, 14 Mar 2022 01:33:34 +0100 Subject: [PATCH 09/70] pushing to docker hub --- .github/workflows/nightlyrelease.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/nightlyrelease.yml b/.github/workflows/nightlyrelease.yml index c7c56587e..39d84ffce 100644 --- a/.github/workflows/nightlyrelease.yml +++ b/.github/workflows/nightlyrelease.yml @@ -17,5 +17,6 @@ jobs: - name: Build an image run: | VERSION=$(cat ./version.txt)-nightly - docker build --build-arg "PNP_MODULE_VERSION=$VERSION" ./docker -f ./docker/pnppowershell-prerelease.dockerFile --tag pnp-powershell:$VERSION + docker build --build-arg "PNP_MODULE_VERSION=$VERSION" ./docker -f ./docker/pnppowershell-prerelease.dockerFile --tag asapozhkov/pnp-powershell:$VERSION docker login -u asapozhkov -p ${{ secrets.DOCKER_TOKEN }} + docker push asapozhkov/pnp-powershell:$VERSION \ No newline at end of file From 96e559c9d719ba5c8a455df7f0d20280377ff5b6 Mon Sep 17 00:00:00 2001 From: Aleks Date: Mon, 14 Mar 2022 01:44:57 +0100 Subject: [PATCH 10/70] docker readme --- docker/README.md | 26 +++++++++++ docker/build-module-in-linux.ps1 | 75 ++++++++++++++++++++++++++++++++ 2 files changed, 101 insertions(+) create mode 100644 docker/README.md create mode 100644 docker/build-module-in-linux.ps1 diff --git a/docker/README.md b/docker/README.md new file mode 100644 index 000000000..2f145eb84 --- /dev/null +++ b/docker/README.md @@ -0,0 +1,26 @@ +# Build module in Docker in Linux + +```bash +docker run --rm -it -v $(pwd):/home/powershell mcr.microsoft.com/dotnet/sdk:6.0 pwsh +``` + +```powershell +/home/powershell/docker/build-module-in-linux.ps1 +``` + +# Publish with prereleases manually + +1. Set "DOCKER_TOKEN" variable in Github Actions Secrets + +2. Run + +```bash +VERSION=$(cat ./version.txt) +docker build --build-arg "PNP_MODULE_VERSION=$VERSION" ./docker -f ./docker/pnppowershell-prerelease.dockerFile --tag asapozhkov/pnp-powershell:$VERSION +docker login -u asapozhkov -p $DOCKER_TOKEN +docker push asapozhkov/pnp-powershell:$VERSION +``` + +# Publish automatically with Github Actions + +Set "DOCKER_TOKEN" variable in Github Actions Secrets diff --git a/docker/build-module-in-linux.ps1 b/docker/build-module-in-linux.ps1 new file mode 100644 index 000000000..93e022f5f --- /dev/null +++ b/docker/build-module-in-linux.ps1 @@ -0,0 +1,75 @@ +cd /home/powershell + +$versionFileContents = (Get-Content ./version.txt -Raw).Trim() +$versionFileContents +$versionObject = [System.Management.Automation.SemanticVersion]::Parse($versionFileContents) +$buildVersion = $versionObject.Patch + 1; +$version = "$($versionObject.Major).$($versionObject.Minor).$buildVersion" +dotnet build ./src/Commands/PnP.PowerShell.csproj --nologo --configuration Release --no-incremental -p:VersionPrefix=$version -p:VersionSuffix=nightly + +$documentsFolder = [environment]::getfolderpath("mydocuments"); +$destinationFolder = "$documentsFolder/.local/share/powershell/Modules/PnP.PowerShell" +$corePath = "$destinationFolder/Core" +$commonPath = "$destinationFolder/Common" +$frameworkPath = "$destinationFolder/Framework" +$assemblyExceptions = @("System.Memory.dll"); +Write-Host "Creating target folders: $destinationFolder" -ForegroundColor Yellow +New-Item -Path $destinationFolder -ItemType Directory -Force | Out-Null +New-Item -Path "$destinationFolder\Core" -ItemType Directory -Force | Out-Null +New-Item -Path "$destinationFolder\Common" -ItemType Directory -Force | Out-Null +Write-Host "Copying files to $destinationFolder" -ForegroundColor Yellow + +$commonFiles = [System.Collections.Generic.Hashset[string]]::new() +Copy-Item -Path "./resources/*.ps1xml" -Destination "$destinationFolder" +Get-ChildItem -Path "./src/ALC/bin/Release/netstandard2.0" | Where-Object { $_.Extension -in '.dll', '.pdb' } | Foreach-Object { if (!$assemblyExceptions.Contains($_.Name)) { [void]$commonFiles.Add($_.Name) }; Copy-Item -LiteralPath $_.FullName -Destination $commonPath } +Get-ChildItem -Path "./src/Commands/bin/Release/netcoreapp3.1" | Where-Object { $_.Extension -in '.dll', '.pdb' -and -not $commonFiles.Contains($_.Name) } | Foreach-Object { Copy-Item -LiteralPath $_.FullName -Destination $corePath } + +Write-Host "Generating PnP.PowerShell.psd1" -ForegroundColor Yellow +# Load the Module in a new PowerShell session +$scriptBlock = { + $documentsFolder = [environment]::getfolderpath("mydocuments"); + $destinationFolder = "$documentsFolder/.local/share/powershell/Modules/PnP.PowerShell" + Import-Module -Name "$destinationFolder/Core/PnP.PowerShell.dll" -DisableNameChecking + Write-Host "Getting cmdlet info" -ForegroundColor Yellow + $cmdlets = Get-Command -Module PnP.PowerShell | ForEach-Object { "`"$_`"" } + $cmdlets -Join "," +} + +Write-Host "Starting job to retrieve cmdlet names" -ForegroundColor Yellow +$cmdletsString = Start-ThreadJob -ScriptBlock $scriptBlock | Receive-Job -Wait + +Write-Host "Writing PSD1" -ForegroundColor Yellow +$manifest = "@{ + NestedModules = if (`$PSEdition -eq 'Core') + { + 'Core/PnP.PowerShell.dll' + } + else + { + 'Framework/PnP.PowerShell.dll' + } + ModuleVersion = '$version' + Description = 'Microsoft 365 Patterns and Practices PowerShell Cmdlets' + GUID = '0b0430ce-d799-4f3b-a565-f0dca1f31e17' + Author = 'Microsoft 365 Patterns and Practices' + CompanyName = 'Microsoft 365 Patterns and Practices' + CompatiblePSEditions = @(`"Core`",`"Desktop`") + PowerShellVersion = '5.1' + DotNetFrameworkVersion = '4.6.1' + ProcessorArchitecture = 'None' + FunctionsToExport = '*' + CmdletsToExport = @($cmdletsString) + VariablesToExport = '*' + AliasesToExport = '*' + FormatsToProcess = 'PnP.PowerShell.Format.ps1xml' + PrivateData = @{ + PSData = @{ + Tags = 'SharePoint','PnP','Teams','Planner' + Prerelease = 'nightly' + ProjectUri = 'https://aka.ms/sppnp' + IconUri = 'https://raw.githubusercontent.com/pnp/media/40e7cd8952a9347ea44e5572bb0e49622a102a12/parker/ms/300w/parker-ms-300.png' + } + } +}" +$manifest | Out-File "$destinationFolder/PnP.PowerShell.psd1" -Force +Import-Module -Name PnP.PowerShell From dec85216857ea187c8031d470d83f28e3206767b Mon Sep 17 00:00:00 2001 From: Aleks Date: Mon, 14 Mar 2022 23:41:27 +0100 Subject: [PATCH 11/70] using DOCKER_USERNAME and DOCKER_PASSWORD --- .github/workflows/nightlyrelease.yml | 6 +++--- docker/README.md | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/nightlyrelease.yml b/.github/workflows/nightlyrelease.yml index 39d84ffce..a4713504b 100644 --- a/.github/workflows/nightlyrelease.yml +++ b/.github/workflows/nightlyrelease.yml @@ -17,6 +17,6 @@ jobs: - name: Build an image run: | VERSION=$(cat ./version.txt)-nightly - docker build --build-arg "PNP_MODULE_VERSION=$VERSION" ./docker -f ./docker/pnppowershell-prerelease.dockerFile --tag asapozhkov/pnp-powershell:$VERSION - docker login -u asapozhkov -p ${{ secrets.DOCKER_TOKEN }} - docker push asapozhkov/pnp-powershell:$VERSION \ No newline at end of file + docker build --build-arg "PNP_MODULE_VERSION=$VERSION" ./docker -f ./docker/pnppowershell-prerelease.dockerFile --tag ${{ secrets.DOCKER_USERNAME }}/powershell:$VERSION + docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }} + docker push ${{ secrets.DOCKER_USERNAME }}/powershell:$VERSION diff --git a/docker/README.md b/docker/README.md index 2f145eb84..fca1958ac 100644 --- a/docker/README.md +++ b/docker/README.md @@ -10,7 +10,7 @@ docker run --rm -it -v $(pwd):/home/powershell mcr.microsoft.com/dotnet/sdk:6.0 # Publish with prereleases manually -1. Set "DOCKER_TOKEN" variable in Github Actions Secrets +1. Set "DOCKER_USERNAME" and "DOCKER_PASSWORD" variables 2. Run From c0122b789ab6bd5107e0024d9a6d75838767e2b0 Mon Sep 17 00:00:00 2001 From: Aleks Date: Mon, 14 Mar 2022 23:43:59 +0100 Subject: [PATCH 12/70] using DOCKER_USERNAME and DOCKER_PASSWORD --- docker/README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docker/README.md b/docker/README.md index fca1958ac..f57dce992 100644 --- a/docker/README.md +++ b/docker/README.md @@ -16,11 +16,11 @@ docker run --rm -it -v $(pwd):/home/powershell mcr.microsoft.com/dotnet/sdk:6.0 ```bash VERSION=$(cat ./version.txt) -docker build --build-arg "PNP_MODULE_VERSION=$VERSION" ./docker -f ./docker/pnppowershell-prerelease.dockerFile --tag asapozhkov/pnp-powershell:$VERSION -docker login -u asapozhkov -p $DOCKER_TOKEN -docker push asapozhkov/pnp-powershell:$VERSION +docker build --build-arg "PNP_MODULE_VERSION=$VERSION" ./docker -f ./docker/pnppowershell-prerelease.dockerFile --tag $DOCKER_USERNAME/powershell:$VERSION +docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD +docker push $DOCKER_USERNAME/powershell:$VERSION ``` # Publish automatically with Github Actions -Set "DOCKER_TOKEN" variable in Github Actions Secrets +Set "DOCKER_USERNAME" and "DOCKER_PASSWORD" variables in Github Actions Secrets From e1859ba5d3c5c34c4714b16cd8d32a63619bf40e Mon Sep 17 00:00:00 2001 From: Aleks Date: Mon, 14 Mar 2022 23:46:25 +0100 Subject: [PATCH 13/70] adding nightly tag --- .github/workflows/nightlyrelease.yml | 1 + docker/README.md | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/nightlyrelease.yml b/.github/workflows/nightlyrelease.yml index a4713504b..04606b231 100644 --- a/.github/workflows/nightlyrelease.yml +++ b/.github/workflows/nightlyrelease.yml @@ -20,3 +20,4 @@ jobs: docker build --build-arg "PNP_MODULE_VERSION=$VERSION" ./docker -f ./docker/pnppowershell-prerelease.dockerFile --tag ${{ secrets.DOCKER_USERNAME }}/powershell:$VERSION docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }} docker push ${{ secrets.DOCKER_USERNAME }}/powershell:$VERSION + docker push ${{ secrets.DOCKER_USERNAME }}/powershell:nightly diff --git a/docker/README.md b/docker/README.md index f57dce992..7857542d5 100644 --- a/docker/README.md +++ b/docker/README.md @@ -15,10 +15,11 @@ docker run --rm -it -v $(pwd):/home/powershell mcr.microsoft.com/dotnet/sdk:6.0 2. Run ```bash -VERSION=$(cat ./version.txt) +VERSION=$(cat ./version.txt)-nightly docker build --build-arg "PNP_MODULE_VERSION=$VERSION" ./docker -f ./docker/pnppowershell-prerelease.dockerFile --tag $DOCKER_USERNAME/powershell:$VERSION docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD docker push $DOCKER_USERNAME/powershell:$VERSION +docker push $DOCKER_USERNAME/powershell:nightly ``` # Publish automatically with Github Actions From 3e896f73c3503a7a87d148899841844a1a07f251 Mon Sep 17 00:00:00 2001 From: Aleks Date: Mon, 14 Mar 2022 23:56:21 +0100 Subject: [PATCH 14/70] verified adding nightly tag --- .github/workflows/nightlyrelease.yml | 1 + docker/README.md | 1 + 2 files changed, 2 insertions(+) diff --git a/.github/workflows/nightlyrelease.yml b/.github/workflows/nightlyrelease.yml index 04606b231..7f04663ea 100644 --- a/.github/workflows/nightlyrelease.yml +++ b/.github/workflows/nightlyrelease.yml @@ -18,6 +18,7 @@ jobs: run: | VERSION=$(cat ./version.txt)-nightly docker build --build-arg "PNP_MODULE_VERSION=$VERSION" ./docker -f ./docker/pnppowershell-prerelease.dockerFile --tag ${{ secrets.DOCKER_USERNAME }}/powershell:$VERSION + docker image tag $DOCKER_USERNAME/powershell:$VERSION $DOCKER_USERNAME/powershell:nightly docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }} docker push ${{ secrets.DOCKER_USERNAME }}/powershell:$VERSION docker push ${{ secrets.DOCKER_USERNAME }}/powershell:nightly diff --git a/docker/README.md b/docker/README.md index 7857542d5..736fa32ff 100644 --- a/docker/README.md +++ b/docker/README.md @@ -17,6 +17,7 @@ docker run --rm -it -v $(pwd):/home/powershell mcr.microsoft.com/dotnet/sdk:6.0 ```bash VERSION=$(cat ./version.txt)-nightly docker build --build-arg "PNP_MODULE_VERSION=$VERSION" ./docker -f ./docker/pnppowershell-prerelease.dockerFile --tag $DOCKER_USERNAME/powershell:$VERSION +docker image tag $DOCKER_USERNAME/powershell:$VERSION $DOCKER_USERNAME/powershell:nightly docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD docker push $DOCKER_USERNAME/powershell:$VERSION docker push $DOCKER_USERNAME/powershell:nightly From 9f877c244341b1bb65826d02827e57cff8ecb428 Mon Sep 17 00:00:00 2001 From: Aleks Date: Tue, 15 Mar 2022 00:00:13 +0100 Subject: [PATCH 15/70] corrected user name ref --- .github/workflows/nightlyrelease.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/nightlyrelease.yml b/.github/workflows/nightlyrelease.yml index 7f04663ea..965da7d8a 100644 --- a/.github/workflows/nightlyrelease.yml +++ b/.github/workflows/nightlyrelease.yml @@ -18,7 +18,7 @@ jobs: run: | VERSION=$(cat ./version.txt)-nightly docker build --build-arg "PNP_MODULE_VERSION=$VERSION" ./docker -f ./docker/pnppowershell-prerelease.dockerFile --tag ${{ secrets.DOCKER_USERNAME }}/powershell:$VERSION - docker image tag $DOCKER_USERNAME/powershell:$VERSION $DOCKER_USERNAME/powershell:nightly + docker image tag ${{ secrets.DOCKER_USERNAME }}/powershell:$VERSION ${{ secrets.DOCKER_USERNAME }}/powershell:nightly docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }} docker push ${{ secrets.DOCKER_USERNAME }}/powershell:$VERSION docker push ${{ secrets.DOCKER_USERNAME }}/powershell:nightly From 433d55aeae807f47d49f75464e20fcfffb16efd9 Mon Sep 17 00:00:00 2001 From: Aleks Date: Thu, 31 Mar 2022 16:47:25 +0200 Subject: [PATCH 16/70] run via schedule again --- .github/workflows/nightlyrelease.yml | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/.github/workflows/nightlyrelease.yml b/.github/workflows/nightlyrelease.yml index 965da7d8a..c872c4553 100644 --- a/.github/workflows/nightlyrelease.yml +++ b/.github/workflows/nightlyrelease.yml @@ -2,11 +2,8 @@ name: Nightly Release to PowerShell Gallery on: workflow_dispatch: - push: - branches: - - dev - paths: - - 'docker/**' + schedule: + - cron: '30 3 * * *' jobs: build: From bb6f9f2bc140e39c9ec162e3969d3aecab730a09 Mon Sep 17 00:00:00 2001 From: Aleks Date: Thu, 31 Mar 2022 16:47:54 +0200 Subject: [PATCH 17/70] more specific job name --- .github/workflows/nightlyrelease.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/nightlyrelease.yml b/.github/workflows/nightlyrelease.yml index c872c4553..4d371e6ac 100644 --- a/.github/workflows/nightlyrelease.yml +++ b/.github/workflows/nightlyrelease.yml @@ -5,10 +5,8 @@ on: schedule: - cron: '30 3 * * *' jobs: - build: - + publish-docker: runs-on: ubuntu-latest - steps: - uses: actions/checkout@v2 - name: Build an image From eb6fd6b08b048a1a72c40bcf290b74ce7baa351d Mon Sep 17 00:00:00 2001 From: Aleks Date: Thu, 31 Mar 2022 16:49:16 +0200 Subject: [PATCH 18/70] divided job into simpler steps --- .github/workflows/nightlyrelease.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/nightlyrelease.yml b/.github/workflows/nightlyrelease.yml index 4d371e6ac..4859543c8 100644 --- a/.github/workflows/nightlyrelease.yml +++ b/.github/workflows/nightlyrelease.yml @@ -13,7 +13,13 @@ jobs: run: | VERSION=$(cat ./version.txt)-nightly docker build --build-arg "PNP_MODULE_VERSION=$VERSION" ./docker -f ./docker/pnppowershell-prerelease.dockerFile --tag ${{ secrets.DOCKER_USERNAME }}/powershell:$VERSION + - name: Tag the image + run: | + VERSION=$(cat ./version.txt)-nightly docker image tag ${{ secrets.DOCKER_USERNAME }}/powershell:$VERSION ${{ secrets.DOCKER_USERNAME }}/powershell:nightly + - name: Push the image + run: | + VERSION=$(cat ./version.txt)-nightly docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }} docker push ${{ secrets.DOCKER_USERNAME }}/powershell:$VERSION docker push ${{ secrets.DOCKER_USERNAME }}/powershell:nightly From dad1ba598e3c658c2390b47cdcdfee9ddef54ac1 Mon Sep 17 00:00:00 2001 From: Aleks Date: Thu, 31 Mar 2022 17:10:52 +0200 Subject: [PATCH 19/70] testing pipeline for publishing --- .github/workflows/release.yml | 16 ++++++++++++++++ docker/publish.ps1 | 1 + 2 files changed, 17 insertions(+) create mode 100644 .github/workflows/release.yml create mode 100644 docker/publish.ps1 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 000000000..d969d216d --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,16 @@ +name: Release to Docker Hub + +on: + workflow_dispatch: + push: + branches: + - dev + paths: + - 'docker/**' +jobs: + publish-docker: + runs-on: windows-latest + steps: + - uses: actions/checkout@v2 + - name: Build an image + run: ./docker/publish.ps1 diff --git a/docker/publish.ps1 b/docker/publish.ps1 new file mode 100644 index 000000000..3b47ed418 --- /dev/null +++ b/docker/publish.ps1 @@ -0,0 +1 @@ +docker image list \ No newline at end of file From 3450cc284ca2e22b455ffae3b96fa04130e346a9 Mon Sep 17 00:00:00 2001 From: Aleks Date: Thu, 31 Mar 2022 17:13:53 +0200 Subject: [PATCH 20/70] preparing for linux containers --- .github/workflows/release.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index d969d216d..5086523c7 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -9,8 +9,9 @@ on: - 'docker/**' jobs: publish-docker: - runs-on: windows-latest + runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - name: Build an image + shell: pwsh run: ./docker/publish.ps1 From f5b96511f1e7329798a4f606fd51bfe7dc4b475d Mon Sep 17 00:00:00 2001 From: Aleks Date: Thu, 31 Mar 2022 17:15:13 +0200 Subject: [PATCH 21/70] triggering on yaml change --- .github/workflows/release.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 5086523c7..f2112331a 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -7,6 +7,7 @@ on: - dev paths: - 'docker/**' + - '.github/workflows/release.yml' jobs: publish-docker: runs-on: ubuntu-latest From 46ec4f2f91af5717c763aadcd3de43c07701b7f8 Mon Sep 17 00:00:00 2001 From: Aleks Date: Thu, 31 Mar 2022 22:23:34 +0200 Subject: [PATCH 22/70] password in quoutes --- .github/workflows/nightlyrelease.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/nightlyrelease.yml b/.github/workflows/nightlyrelease.yml index 4859543c8..47ee4bb16 100644 --- a/.github/workflows/nightlyrelease.yml +++ b/.github/workflows/nightlyrelease.yml @@ -20,6 +20,6 @@ jobs: - name: Push the image run: | VERSION=$(cat ./version.txt)-nightly - docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }} + docker login -u ${{ secrets.DOCKER_USERNAME }} -p '${{ secrets.DOCKER_PASSWORD }}' docker push ${{ secrets.DOCKER_USERNAME }}/powershell:$VERSION docker push ${{ secrets.DOCKER_USERNAME }}/powershell:nightly From 19c8a63fa35aec61e6e6dd7e06eacac04e7ad4be Mon Sep 17 00:00:00 2001 From: Aleks Date: Thu, 31 Mar 2022 22:24:41 +0200 Subject: [PATCH 23/70] testing publishing script with parameters --- .github/workflows/release.yml | 6 ++++-- docker/Publish-UnpublishedImage.ps1 | 25 +++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 2 deletions(-) create mode 100644 docker/Publish-UnpublishedImage.ps1 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index f2112331a..8187a5408 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -13,6 +13,8 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - - name: Build an image + - name: Build and Publish All shell: pwsh - run: ./docker/publish.ps1 + run: | + `$securedPassword = ConvertTo-SecureString "${{ secrets.DOCKER_PASSWORD }}" -AsPlainText -Force + ./docker/Publish-UnpublishedImage.ps1 PnP.PowerShell ${{ secrets.DOCKER_USERNAME }} powershell `$securedPassword diff --git a/docker/Publish-UnpublishedImage.ps1 b/docker/Publish-UnpublishedImage.ps1 new file mode 100644 index 000000000..7ca884c6e --- /dev/null +++ b/docker/Publish-UnpublishedImage.ps1 @@ -0,0 +1,25 @@ +Param( + [Parameter(Position = 0, + Mandatory = $true, + ValueFromPipeline = $false)] + [String] + $PS_MODULE_NAME, + [Parameter(Position = 1, + Mandatory = $true, + ValueFromPipeline = $false)] + [String] + $DOCKER_USERNAME, + [Parameter(Position = 2, + Mandatory = $true, + ValueFromPipeline = $false)] + [String] + $DOCKER_IMAGE_NAME, + [Parameter(Position = 3, + Mandatory = $true, + ValueFromPipeline = $false)] + [Security.SecureString] + $DOCKER_PASSWORD +) +$publishedImageVersions = docker image list $DOCKER_USERNAME/$DOCKER_IMAGE_NAME --format "{{.Tag}}" +Write-Host $publishedImageVersions.Count; +Find-Module $PS_MODULE_NAME -AllVersions \ No newline at end of file From e7579239eb0520d31fc67500615aa9e3e92a7b03 Mon Sep 17 00:00:00 2001 From: Aleks Date: Thu, 31 Mar 2022 22:27:03 +0200 Subject: [PATCH 24/70] no ` needed for pwsh jobs --- .github/workflows/release.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 8187a5408..306e9a86a 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -16,5 +16,5 @@ jobs: - name: Build and Publish All shell: pwsh run: | - `$securedPassword = ConvertTo-SecureString "${{ secrets.DOCKER_PASSWORD }}" -AsPlainText -Force - ./docker/Publish-UnpublishedImage.ps1 PnP.PowerShell ${{ secrets.DOCKER_USERNAME }} powershell `$securedPassword + $securedPassword = ConvertTo-SecureString "${{ secrets.DOCKER_PASSWORD }}" -AsPlainText -Force + ./docker/Publish-UnpublishedImage.ps1 PnP.PowerShell ${{ secrets.DOCKER_USERNAME }} powershell $securedPassword From 80e54c3bd03c816a61429471551f3d326984709a Mon Sep 17 00:00:00 2001 From: Aleks Date: Thu, 31 Mar 2022 22:48:01 +0200 Subject: [PATCH 25/70] Getting docker tags via Invoke-RestMethod --- docker/Publish-UnpublishedImage.ps1 | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docker/Publish-UnpublishedImage.ps1 b/docker/Publish-UnpublishedImage.ps1 index 7ca884c6e..e30451a66 100644 --- a/docker/Publish-UnpublishedImage.ps1 +++ b/docker/Publish-UnpublishedImage.ps1 @@ -20,6 +20,8 @@ Param( [Security.SecureString] $DOCKER_PASSWORD ) -$publishedImageVersions = docker image list $DOCKER_USERNAME/$DOCKER_IMAGE_NAME --format "{{.Tag}}" +$publishedImageVersions = (Invoke-RestMethod https://registry.hub.docker.com/v2/repositories/$DOCKER_USERNAME/$DOCKER_IMAGE_NAME/tags).results | % { + $_.name +} Write-Host $publishedImageVersions.Count; Find-Module $PS_MODULE_NAME -AllVersions \ No newline at end of file From 6a8e7143428ce038e7589dfcb499e056aa97ff71 Mon Sep 17 00:00:00 2001 From: Aleks Date: Thu, 31 Mar 2022 22:52:56 +0200 Subject: [PATCH 26/70] show every unpublished image --- docker/Publish-UnpublishedImage.ps1 | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/docker/Publish-UnpublishedImage.ps1 b/docker/Publish-UnpublishedImage.ps1 index e30451a66..fda04e076 100644 --- a/docker/Publish-UnpublishedImage.ps1 +++ b/docker/Publish-UnpublishedImage.ps1 @@ -23,5 +23,8 @@ Param( $publishedImageVersions = (Invoke-RestMethod https://registry.hub.docker.com/v2/repositories/$DOCKER_USERNAME/$DOCKER_IMAGE_NAME/tags).results | % { $_.name } -Write-Host $publishedImageVersions.Count; -Find-Module $PS_MODULE_NAME -AllVersions \ No newline at end of file +Find-Module $PS_MODULE_NAME -AllVersions -AllowPrerelease | % { + if ( !( $publishedImageVersions -contains $_ ) ) { + $_ + } +} \ No newline at end of file From 1d5ed1ec2aa588bd8c2814f2c126a75a5f4b8bf2 Mon Sep 17 00:00:00 2001 From: Aleks Date: Thu, 31 Mar 2022 22:56:46 +0200 Subject: [PATCH 27/70] fixed version comparisons --- docker/Publish-UnpublishedImage.ps1 | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/docker/Publish-UnpublishedImage.ps1 b/docker/Publish-UnpublishedImage.ps1 index fda04e076..286f40bb8 100644 --- a/docker/Publish-UnpublishedImage.ps1 +++ b/docker/Publish-UnpublishedImage.ps1 @@ -24,7 +24,8 @@ $publishedImageVersions = (Invoke-RestMethod https://registry.hub.docker.com/v2/ $_.name } Find-Module $PS_MODULE_NAME -AllVersions -AllowPrerelease | % { - if ( !( $publishedImageVersions -contains $_ ) ) { - $_ + $moduleVersion = $_.Version; + if ( !( $publishedImageVersions -contains $moduleVersion ) ) { + $moduleVersion } } \ No newline at end of file From f8c886c94eccd0217412aa7eb5cb5482f28b6e37 Mon Sep 17 00:00:00 2001 From: Aleks Date: Thu, 31 Mar 2022 23:35:08 +0200 Subject: [PATCH 28/70] publishin all not prereleases --- docker/Publish-UnpublishedImage.ps1 | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/docker/Publish-UnpublishedImage.ps1 b/docker/Publish-UnpublishedImage.ps1 index 286f40bb8..481c35c74 100644 --- a/docker/Publish-UnpublishedImage.ps1 +++ b/docker/Publish-UnpublishedImage.ps1 @@ -23,9 +23,15 @@ Param( $publishedImageVersions = (Invoke-RestMethod https://registry.hub.docker.com/v2/repositories/$DOCKER_USERNAME/$DOCKER_IMAGE_NAME/tags).results | % { $_.name } -Find-Module $PS_MODULE_NAME -AllVersions -AllowPrerelease | % { +$moduleVersions = Find-Module $PS_MODULE_NAME -AllVersions; +[array]::Reverse($moduleVersions); +$moduleVersions | % { $moduleVersion = $_.Version; if ( !( $publishedImageVersions -contains $moduleVersion ) ) { - $moduleVersion + docker build --build-arg "PNP_MODULE_VERSION=$moduleVersion" ./docker -f ./docker/pnppowershell.dockerFile --tag $DOCKER_USERNAME/$DOCKER_IMAGE_NAME:$moduleVersion; + docker image tag $DOCKER_USERNAME/$DOCKER_IMAGE_NAME:$moduleVersion $DOCKER_USERNAME/$DOCKER_IMAGE_NAME:latest; + docker login -u $DOCKER_USERNAME -p "$([System.Net.NetworkCredential]::new("", $DOCKER_PASSWORD).Password)"; + docker push $DOCKER_USERNAME/$DOCKER_IMAGE_NAME:$moduleVersion; + docker push $DOCKER_USERNAME/$DOCKER_IMAGE_NAME:latest; } } \ No newline at end of file From 57fb24e457ee7722322857d7181e7fd817130d35 Mon Sep 17 00:00:00 2001 From: Aleks Date: Thu, 31 Mar 2022 23:37:47 +0200 Subject: [PATCH 29/70] safer manipulating with : --- docker/Publish-UnpublishedImage.ps1 | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docker/Publish-UnpublishedImage.ps1 b/docker/Publish-UnpublishedImage.ps1 index 481c35c74..94746a886 100644 --- a/docker/Publish-UnpublishedImage.ps1 +++ b/docker/Publish-UnpublishedImage.ps1 @@ -28,10 +28,10 @@ $moduleVersions = Find-Module $PS_MODULE_NAME -AllVersions; $moduleVersions | % { $moduleVersion = $_.Version; if ( !( $publishedImageVersions -contains $moduleVersion ) ) { - docker build --build-arg "PNP_MODULE_VERSION=$moduleVersion" ./docker -f ./docker/pnppowershell.dockerFile --tag $DOCKER_USERNAME/$DOCKER_IMAGE_NAME:$moduleVersion; - docker image tag $DOCKER_USERNAME/$DOCKER_IMAGE_NAME:$moduleVersion $DOCKER_USERNAME/$DOCKER_IMAGE_NAME:latest; + docker build --build-arg "PNP_MODULE_VERSION=$moduleVersion" ./docker -f ./docker/pnppowershell.dockerFile --tag $DOCKER_USERNAME/$DOCKER_IMAGE_NAME`:$moduleVersion; + docker image tag $DOCKER_USERNAME/$DOCKER_IMAGE_NAME`:$moduleVersion $DOCKER_USERNAME/$DOCKER_IMAGE_NAME`:latest; docker login -u $DOCKER_USERNAME -p "$([System.Net.NetworkCredential]::new("", $DOCKER_PASSWORD).Password)"; - docker push $DOCKER_USERNAME/$DOCKER_IMAGE_NAME:$moduleVersion; - docker push $DOCKER_USERNAME/$DOCKER_IMAGE_NAME:latest; + docker push $DOCKER_USERNAME/$DOCKER_IMAGE_NAME`:$moduleVersion; + docker push $DOCKER_USERNAME/$DOCKER_IMAGE_NAME`:latest; } } \ No newline at end of file From e10069a45ab9dc98bb554e066c1239b818933df2 Mon Sep 17 00:00:00 2001 From: Aleks Date: Thu, 31 Mar 2022 23:48:11 +0200 Subject: [PATCH 30/70] replacing quotes --- docker/Publish-UnpublishedImage.ps1 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docker/Publish-UnpublishedImage.ps1 b/docker/Publish-UnpublishedImage.ps1 index 94746a886..cd8db9d40 100644 --- a/docker/Publish-UnpublishedImage.ps1 +++ b/docker/Publish-UnpublishedImage.ps1 @@ -30,7 +30,8 @@ $moduleVersions | % { if ( !( $publishedImageVersions -contains $moduleVersion ) ) { docker build --build-arg "PNP_MODULE_VERSION=$moduleVersion" ./docker -f ./docker/pnppowershell.dockerFile --tag $DOCKER_USERNAME/$DOCKER_IMAGE_NAME`:$moduleVersion; docker image tag $DOCKER_USERNAME/$DOCKER_IMAGE_NAME`:$moduleVersion $DOCKER_USERNAME/$DOCKER_IMAGE_NAME`:latest; - docker login -u $DOCKER_USERNAME -p "$([System.Net.NetworkCredential]::new("", $DOCKER_PASSWORD).Password)"; + $plainStringPassword = [System.Net.NetworkCredential]::new("", $DOCKER_PASSWORD).Password; + docker login -u $DOCKER_USERNAME -p "$plainStringPassword"; docker push $DOCKER_USERNAME/$DOCKER_IMAGE_NAME`:$moduleVersion; docker push $DOCKER_USERNAME/$DOCKER_IMAGE_NAME`:latest; } From 70831454ec728e94b31483d3b6353a950cc0e6b3 Mon Sep 17 00:00:00 2001 From: Aleks Date: Thu, 31 Mar 2022 23:57:29 +0200 Subject: [PATCH 31/70] universal docker file --- docker/pnppowershell.dockerFile | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/docker/pnppowershell.dockerFile b/docker/pnppowershell.dockerFile index 6771f01bc..ea3ba51b0 100644 --- a/docker/pnppowershell.dockerFile +++ b/docker/pnppowershell.dockerFile @@ -1,3 +1,5 @@ -FROM mcr.microsoft.com/powershell:lts-debian-10 -COPY ./powershell/ powershell -RUN /usr/bin/pwsh -File ./powershell/installModules.ps1 && rm -rf ./powershell \ No newline at end of file +FROM mcr.microsoft.com/powershell:7.2.1-alpine-3.14-20211215 + +SHELL ["pwsh", "-command"] +ARG PNP_MODULE_VERSION +RUN Install-Module -Name PnP.PowerShell -RequiredVersion $env:PNP_MODULE_VERSION -Force -AllowPrerelease From 5fe379fd3c3f0fc7f2ffc92693f70ebb2badbacb Mon Sep 17 00:00:00 2001 From: Aleks Date: Thu, 31 Mar 2022 23:58:24 +0200 Subject: [PATCH 32/70] using universal dockerfile instead of special --- .github/workflows/nightlyrelease.yml | 2 +- docker/pnppowershell-prerelease.dockerFile | 6 ------ 2 files changed, 1 insertion(+), 7 deletions(-) delete mode 100644 docker/pnppowershell-prerelease.dockerFile diff --git a/.github/workflows/nightlyrelease.yml b/.github/workflows/nightlyrelease.yml index 47ee4bb16..2a21abd41 100644 --- a/.github/workflows/nightlyrelease.yml +++ b/.github/workflows/nightlyrelease.yml @@ -12,7 +12,7 @@ jobs: - name: Build an image run: | VERSION=$(cat ./version.txt)-nightly - docker build --build-arg "PNP_MODULE_VERSION=$VERSION" ./docker -f ./docker/pnppowershell-prerelease.dockerFile --tag ${{ secrets.DOCKER_USERNAME }}/powershell:$VERSION + docker build --build-arg "PNP_MODULE_VERSION=$VERSION" ./docker -f ./docker/pnppowershell.dockerFile --tag ${{ secrets.DOCKER_USERNAME }}/powershell:$VERSION - name: Tag the image run: | VERSION=$(cat ./version.txt)-nightly diff --git a/docker/pnppowershell-prerelease.dockerFile b/docker/pnppowershell-prerelease.dockerFile deleted file mode 100644 index 333283f76..000000000 --- a/docker/pnppowershell-prerelease.dockerFile +++ /dev/null @@ -1,6 +0,0 @@ -FROM mcr.microsoft.com/powershell:7.2.1-alpine-3.14-20211215 - -SHELL ["pwsh", "-command"] -ARG PNP_MODULE_VERSION -RUN Write-Host $env:PNP_MODULE_VERSION -RUN Install-Module -Name PnP.PowerShell -RequiredVersion $env:PNP_MODULE_VERSION -Force -AllowPrerelease From 5023a9ba4ee4ff345adca1f9f228729f39995ed8 Mon Sep 17 00:00:00 2001 From: Aleks Date: Fri, 1 Apr 2022 00:15:12 +0200 Subject: [PATCH 33/70] listing published images with 10k limit --- docker/Publish-UnpublishedImage.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/Publish-UnpublishedImage.ps1 b/docker/Publish-UnpublishedImage.ps1 index cd8db9d40..55f1183ca 100644 --- a/docker/Publish-UnpublishedImage.ps1 +++ b/docker/Publish-UnpublishedImage.ps1 @@ -20,7 +20,7 @@ Param( [Security.SecureString] $DOCKER_PASSWORD ) -$publishedImageVersions = (Invoke-RestMethod https://registry.hub.docker.com/v2/repositories/$DOCKER_USERNAME/$DOCKER_IMAGE_NAME/tags).results | % { +$publishedImageVersions = (Invoke-RestMethod https://registry.hub.docker.com/v2/repositories/$DOCKER_USERNAME/$DOCKER_IMAGE_NAME/tags?page_size=10240).results | % { $_.name } $moduleVersions = Find-Module $PS_MODULE_NAME -AllVersions; From f3df35703d818a965b921d69c09fed0b4a59ada2 Mon Sep 17 00:00:00 2001 From: Aleks Date: Fri, 1 Apr 2022 10:37:59 +0200 Subject: [PATCH 34/70] release only running via schedule --- .github/workflows/release.yml | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 306e9a86a..8d2129030 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -2,12 +2,8 @@ name: Release to Docker Hub on: workflow_dispatch: - push: - branches: - - dev - paths: - - 'docker/**' - - '.github/workflows/release.yml' + schedule: + - cron: '30 3 * * *' jobs: publish-docker: runs-on: ubuntu-latest From 64bdca8eb2680ccf39f1bd66371cbbbff4d64d48 Mon Sep 17 00:00:00 2001 From: Aleks Date: Fri, 1 Apr 2022 10:40:56 +0200 Subject: [PATCH 35/70] updated base image version --- docker/pnppowershell.dockerFile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/pnppowershell.dockerFile b/docker/pnppowershell.dockerFile index ea3ba51b0..b46b7e6c9 100644 --- a/docker/pnppowershell.dockerFile +++ b/docker/pnppowershell.dockerFile @@ -1,4 +1,4 @@ -FROM mcr.microsoft.com/powershell:7.2.1-alpine-3.14-20211215 +FROM mcr.microsoft.com/powershell:7.2.2-alpine-3.14-20220318 SHELL ["pwsh", "-command"] ARG PNP_MODULE_VERSION From fb57053a70144dee1fe3f0e1a31d0f286c3e750c Mon Sep 17 00:00:00 2001 From: Aleks Date: Fri, 1 Apr 2022 10:45:03 +0200 Subject: [PATCH 36/70] cleaning nightly release before merging to origin --- .github/workflows/nightlyrelease.yml | 40 ++++++++++++++++++++++++++-- 1 file changed, 38 insertions(+), 2 deletions(-) diff --git a/.github/workflows/nightlyrelease.yml b/.github/workflows/nightlyrelease.yml index 2a21abd41..fe37d37e4 100644 --- a/.github/workflows/nightlyrelease.yml +++ b/.github/workflows/nightlyrelease.yml @@ -1,12 +1,48 @@ -name: Nightly Release to PowerShell Gallery +name: Nightly Release to PowerShell Gallery and Docker Hub on: workflow_dispatch: schedule: - - cron: '30 3 * * *' + - cron: '30 2 * * *' jobs: + build: + + runs-on: windows-latest + + steps: + - name: Setup .NET Core + uses: actions/setup-dotnet@v1 + with: + dotnet-version: | + 3.1.301 + 5.x + - uses: actions/checkout@v2 + with: + ref: dev + token: ${{ secrets.PAT }} + - name: Build and Publish Module + env: + POWERSHELLGALLERY_API_KEY: ${{ secrets.POWERSHELLGALLERY_API_KEY }} + shell: pwsh + run: | + ./build/Build-Nightly.ps1 + - name: Set variables + shell: pwsh + run: | + $version = Get-Content version.txt -raw + "BUILDVERSION=$version" | Out-File $env:GITHUB_ENV -Encoding utf8 -Append + - name: Add & Commit + uses: EndBug/add-and-commit@v6 + with: + message: 'Nightly publish to PowerShell Gallery' + tag: '${{env.BUILDVERSION}}-nightly --force' + push: true + branch: dev + token: ${{ secrets.PAT }} + name: Nightly Release to PowerShell Gallery publish-docker: runs-on: ubuntu-latest + needs: [ build ] steps: - uses: actions/checkout@v2 - name: Build an image From c518b51127eb6c742429c97ee3615c6cc03a9227 Mon Sep 17 00:00:00 2001 From: Aleks Date: Fri, 1 Apr 2022 10:46:37 +0200 Subject: [PATCH 37/70] typo in yaml cleaning --- .github/workflows/nightlyrelease.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/nightlyrelease.yml b/.github/workflows/nightlyrelease.yml index fe37d37e4..f6c9493ee 100644 --- a/.github/workflows/nightlyrelease.yml +++ b/.github/workflows/nightlyrelease.yml @@ -39,7 +39,6 @@ jobs: push: true branch: dev token: ${{ secrets.PAT }} - name: Nightly Release to PowerShell Gallery publish-docker: runs-on: ubuntu-latest needs: [ build ] From 5dda0253af4f6d99d515ad4f764c73addbfbd6ef Mon Sep 17 00:00:00 2001 From: Aleks Date: Fri, 1 Apr 2022 10:58:13 +0200 Subject: [PATCH 38/70] removing unused file --- docker/publish.ps1 | 1 - 1 file changed, 1 deletion(-) delete mode 100644 docker/publish.ps1 diff --git a/docker/publish.ps1 b/docker/publish.ps1 deleted file mode 100644 index 3b47ed418..000000000 --- a/docker/publish.ps1 +++ /dev/null @@ -1 +0,0 @@ -docker image list \ No newline at end of file From 53ead61355c921c2f533416e65f7e5a764b0f3f6 Mon Sep 17 00:00:00 2001 From: Aleks Date: Fri, 1 Apr 2022 10:59:28 +0200 Subject: [PATCH 39/70] removing unused file --- docker/build-module-in-linux.ps1 | 75 -------------------------------- 1 file changed, 75 deletions(-) delete mode 100644 docker/build-module-in-linux.ps1 diff --git a/docker/build-module-in-linux.ps1 b/docker/build-module-in-linux.ps1 deleted file mode 100644 index 93e022f5f..000000000 --- a/docker/build-module-in-linux.ps1 +++ /dev/null @@ -1,75 +0,0 @@ -cd /home/powershell - -$versionFileContents = (Get-Content ./version.txt -Raw).Trim() -$versionFileContents -$versionObject = [System.Management.Automation.SemanticVersion]::Parse($versionFileContents) -$buildVersion = $versionObject.Patch + 1; -$version = "$($versionObject.Major).$($versionObject.Minor).$buildVersion" -dotnet build ./src/Commands/PnP.PowerShell.csproj --nologo --configuration Release --no-incremental -p:VersionPrefix=$version -p:VersionSuffix=nightly - -$documentsFolder = [environment]::getfolderpath("mydocuments"); -$destinationFolder = "$documentsFolder/.local/share/powershell/Modules/PnP.PowerShell" -$corePath = "$destinationFolder/Core" -$commonPath = "$destinationFolder/Common" -$frameworkPath = "$destinationFolder/Framework" -$assemblyExceptions = @("System.Memory.dll"); -Write-Host "Creating target folders: $destinationFolder" -ForegroundColor Yellow -New-Item -Path $destinationFolder -ItemType Directory -Force | Out-Null -New-Item -Path "$destinationFolder\Core" -ItemType Directory -Force | Out-Null -New-Item -Path "$destinationFolder\Common" -ItemType Directory -Force | Out-Null -Write-Host "Copying files to $destinationFolder" -ForegroundColor Yellow - -$commonFiles = [System.Collections.Generic.Hashset[string]]::new() -Copy-Item -Path "./resources/*.ps1xml" -Destination "$destinationFolder" -Get-ChildItem -Path "./src/ALC/bin/Release/netstandard2.0" | Where-Object { $_.Extension -in '.dll', '.pdb' } | Foreach-Object { if (!$assemblyExceptions.Contains($_.Name)) { [void]$commonFiles.Add($_.Name) }; Copy-Item -LiteralPath $_.FullName -Destination $commonPath } -Get-ChildItem -Path "./src/Commands/bin/Release/netcoreapp3.1" | Where-Object { $_.Extension -in '.dll', '.pdb' -and -not $commonFiles.Contains($_.Name) } | Foreach-Object { Copy-Item -LiteralPath $_.FullName -Destination $corePath } - -Write-Host "Generating PnP.PowerShell.psd1" -ForegroundColor Yellow -# Load the Module in a new PowerShell session -$scriptBlock = { - $documentsFolder = [environment]::getfolderpath("mydocuments"); - $destinationFolder = "$documentsFolder/.local/share/powershell/Modules/PnP.PowerShell" - Import-Module -Name "$destinationFolder/Core/PnP.PowerShell.dll" -DisableNameChecking - Write-Host "Getting cmdlet info" -ForegroundColor Yellow - $cmdlets = Get-Command -Module PnP.PowerShell | ForEach-Object { "`"$_`"" } - $cmdlets -Join "," -} - -Write-Host "Starting job to retrieve cmdlet names" -ForegroundColor Yellow -$cmdletsString = Start-ThreadJob -ScriptBlock $scriptBlock | Receive-Job -Wait - -Write-Host "Writing PSD1" -ForegroundColor Yellow -$manifest = "@{ - NestedModules = if (`$PSEdition -eq 'Core') - { - 'Core/PnP.PowerShell.dll' - } - else - { - 'Framework/PnP.PowerShell.dll' - } - ModuleVersion = '$version' - Description = 'Microsoft 365 Patterns and Practices PowerShell Cmdlets' - GUID = '0b0430ce-d799-4f3b-a565-f0dca1f31e17' - Author = 'Microsoft 365 Patterns and Practices' - CompanyName = 'Microsoft 365 Patterns and Practices' - CompatiblePSEditions = @(`"Core`",`"Desktop`") - PowerShellVersion = '5.1' - DotNetFrameworkVersion = '4.6.1' - ProcessorArchitecture = 'None' - FunctionsToExport = '*' - CmdletsToExport = @($cmdletsString) - VariablesToExport = '*' - AliasesToExport = '*' - FormatsToProcess = 'PnP.PowerShell.Format.ps1xml' - PrivateData = @{ - PSData = @{ - Tags = 'SharePoint','PnP','Teams','Planner' - Prerelease = 'nightly' - ProjectUri = 'https://aka.ms/sppnp' - IconUri = 'https://raw.githubusercontent.com/pnp/media/40e7cd8952a9347ea44e5572bb0e49622a102a12/parker/ms/300w/parker-ms-300.png' - } - } -}" -$manifest | Out-File "$destinationFolder/PnP.PowerShell.psd1" -Force -Import-Module -Name PnP.PowerShell From 1dd7300f500dc03695cd6e06f4cb7b2343524676 Mon Sep 17 00:00:00 2001 From: Aleks Date: Fri, 22 Apr 2022 09:53:04 +0200 Subject: [PATCH 40/70] removing old files --- docker/build.ps1 | 1 - docker/powershell/installModules.ps1 | 20 -------------------- docker/runlocal.ps1 | 1 - 3 files changed, 22 deletions(-) delete mode 100644 docker/build.ps1 delete mode 100644 docker/powershell/installModules.ps1 delete mode 100644 docker/runlocal.ps1 diff --git a/docker/build.ps1 b/docker/build.ps1 deleted file mode 100644 index cbb23ef33..000000000 --- a/docker/build.ps1 +++ /dev/null @@ -1 +0,0 @@ -docker build -t pnppowershell -f ./pnppowershell.dockerFile . --no-cache \ No newline at end of file diff --git a/docker/powershell/installModules.ps1 b/docker/powershell/installModules.ps1 deleted file mode 100644 index fd7099c93..000000000 --- a/docker/powershell/installModules.ps1 +++ /dev/null @@ -1,20 +0,0 @@ -$modules = @( - "PnP.PowerShell", - "Microsoft.PowerShell.SecretManagement", - "Microsoft.PowerShell.SecretStore" -) - -Set-PSRepository -Name "PSGallery" -InstallationPolicy Trusted -$ProgressPreference = "SilentlyContinue" - -foreach($module in $modules) -{ - Write-Host "Installing $module" - Install-Module -Name $module -AllowPrerelease | Out-Null -} - -Register-SecretVault -Name "SecretStore" -ModuleName "Microsoft.PowerShell.SecretStore" -DefaultVault -Set-SecretStoreConfiguration -Authentation None - -$userProfile = "Import-Module -Name PnP.PowerShell" -Set-Content -Path $PROFILE.AllUsersAllHosts -Value $userProfile -Force \ No newline at end of file diff --git a/docker/runlocal.ps1 b/docker/runlocal.ps1 deleted file mode 100644 index f9f1dfb9b..000000000 --- a/docker/runlocal.ps1 +++ /dev/null @@ -1 +0,0 @@ -docker run -it pnppowershell \ No newline at end of file From 58f50ba4d6a0a0f4259251cd9d92a92d7f42dac7 Mon Sep 17 00:00:00 2001 From: Aleks Date: Fri, 22 Apr 2022 09:54:07 +0200 Subject: [PATCH 41/70] new line at end of file --- docker/Publish-UnpublishedImage.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/Publish-UnpublishedImage.ps1 b/docker/Publish-UnpublishedImage.ps1 index 55f1183ca..fc259f547 100644 --- a/docker/Publish-UnpublishedImage.ps1 +++ b/docker/Publish-UnpublishedImage.ps1 @@ -35,4 +35,4 @@ $moduleVersions | % { docker push $DOCKER_USERNAME/$DOCKER_IMAGE_NAME`:$moduleVersion; docker push $DOCKER_USERNAME/$DOCKER_IMAGE_NAME`:latest; } -} \ No newline at end of file +} From fcae6966083376668a4da75ee7759bf04ec8fd76 Mon Sep 17 00:00:00 2001 From: Aleks Date: Fri, 22 Apr 2022 10:04:30 +0200 Subject: [PATCH 42/70] more documentation for manual publishing --- docker/README.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/docker/README.md b/docker/README.md index 736fa32ff..e039598e1 100644 --- a/docker/README.md +++ b/docker/README.md @@ -8,6 +8,17 @@ docker run --rm -it -v $(pwd):/home/powershell mcr.microsoft.com/dotnet/sdk:6.0 /home/powershell/docker/build-module-in-linux.ps1 ``` +# Publish manually + +1. Set "DOCKER_USERNAME" and "DOCKER_PASSWORD" variables + +2. Run + +```powershell +$securedPassword = ConvertTo-SecureString $DOCKER_PASSWORD -AsPlainText -Force +./docker/Publish-UnpublishedImage.ps1 PnP.PowerShell $DOCKER_USERNAME powershell $securedPassword +``` + # Publish with prereleases manually 1. Set "DOCKER_USERNAME" and "DOCKER_PASSWORD" variables From 2fc111fa3f0f6af0f6b9445b707fb103d088e051 Mon Sep 17 00:00:00 2001 From: Aleks Date: Fri, 22 Apr 2022 10:06:31 +0200 Subject: [PATCH 43/70] removing unneccessary (so far) documentation --- docker/README.md | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/docker/README.md b/docker/README.md index e039598e1..cc61e4c4d 100644 --- a/docker/README.md +++ b/docker/README.md @@ -1,13 +1,3 @@ -# Build module in Docker in Linux - -```bash -docker run --rm -it -v $(pwd):/home/powershell mcr.microsoft.com/dotnet/sdk:6.0 pwsh -``` - -```powershell -/home/powershell/docker/build-module-in-linux.ps1 -``` - # Publish manually 1. Set "DOCKER_USERNAME" and "DOCKER_PASSWORD" variables From 8c785ed1d6117d132541db69d138e060a8439c1c Mon Sep 17 00:00:00 2001 From: Aleks Date: Wed, 11 May 2022 08:48:06 +0200 Subject: [PATCH 44/70] publishing image for 5 platform --- .github/workflows/release.yml | 13 +++++++++-- docker/Publish-UnpublishedImage.ps1 | 36 ++++++++++++++++++++++------- docker/README.md | 15 ++++++++++-- docker/pnppowershell.dockerFile | 11 +++++++-- 4 files changed, 61 insertions(+), 14 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 8d2129030..071c93f89 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -5,7 +5,16 @@ on: schedule: - cron: '30 3 * * *' jobs: - publish-docker: + publish-docker-windows: + runs-on: windows-latest + steps: + - uses: actions/checkout@v2 + - name: Build and Publish All + shell: pwsh + run: | + $securedPassword = ConvertTo-SecureString "${{ secrets.DOCKER_PASSWORD }}" -AsPlainText -Force + ./docker/Publish-UnpublishedImage.ps1 PnP.PowerShell ${{ secrets.DOCKER_USERNAME }} powershell $securedPassword "pnppowershell-windows.dockerFile" "nanoserver-1809,nanoserver-20h2,nanoserver-ltsc2022" + publish-docker-linux: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 @@ -13,4 +22,4 @@ jobs: shell: pwsh run: | $securedPassword = ConvertTo-SecureString "${{ secrets.DOCKER_PASSWORD }}" -AsPlainText -Force - ./docker/Publish-UnpublishedImage.ps1 PnP.PowerShell ${{ secrets.DOCKER_USERNAME }} powershell $securedPassword + ./docker/Publish-UnpublishedImage.ps1 PnP.PowerShell ${{ secrets.DOCKER_USERNAME }} powershell $securedPassword "pnppowershell.dockerFile" "alpine-3.14,arm32v7-ubuntu-bionic" diff --git a/docker/Publish-UnpublishedImage.ps1 b/docker/Publish-UnpublishedImage.ps1 index fc259f547..7ddb8fceb 100644 --- a/docker/Publish-UnpublishedImage.ps1 +++ b/docker/Publish-UnpublishedImage.ps1 @@ -18,7 +18,22 @@ Param( Mandatory = $true, ValueFromPipeline = $false)] [Security.SecureString] - $DOCKER_PASSWORD + $DOCKER_PASSWORD, + [Parameter(Position = 4, + Mandatory = $false, + ValueFromPipeline = $false)] + [String] + $DOCKER_FILE_NAME = "pnppowershell.dockerFile", + [Parameter(Position = 5, + Mandatory = $false, + ValueFromPipeline = $false)] + [bool] + $SKIP_PUBLISHER_CHECK = $false, + [Parameter(Position = 6, + Mandatory = $false, + ValueFromPipeline = $false)] + [String] + $DOCKER_IMAGE_SUFFIX_ARRAY = "nanoserver-1809" ) $publishedImageVersions = (Invoke-RestMethod https://registry.hub.docker.com/v2/repositories/$DOCKER_USERNAME/$DOCKER_IMAGE_NAME/tags?page_size=10240).results | % { $_.name @@ -27,12 +42,17 @@ $moduleVersions = Find-Module $PS_MODULE_NAME -AllVersions; [array]::Reverse($moduleVersions); $moduleVersions | % { $moduleVersion = $_.Version; - if ( !( $publishedImageVersions -contains $moduleVersion ) ) { - docker build --build-arg "PNP_MODULE_VERSION=$moduleVersion" ./docker -f ./docker/pnppowershell.dockerFile --tag $DOCKER_USERNAME/$DOCKER_IMAGE_NAME`:$moduleVersion; - docker image tag $DOCKER_USERNAME/$DOCKER_IMAGE_NAME`:$moduleVersion $DOCKER_USERNAME/$DOCKER_IMAGE_NAME`:latest; - $plainStringPassword = [System.Net.NetworkCredential]::new("", $DOCKER_PASSWORD).Password; - docker login -u $DOCKER_USERNAME -p "$plainStringPassword"; - docker push $DOCKER_USERNAME/$DOCKER_IMAGE_NAME`:$moduleVersion; - docker push $DOCKER_USERNAME/$DOCKER_IMAGE_NAME`:latest; + $DOCKER_IMAGE_SUFFIX_ARRAY.Split( "," ) | % { + $baseImageSuffix = $_; + $imageVersion = "$moduleVersion-$baseImageSuffix"; + Write-Host "Checking $imageVersion" + if ( !( $publishedImageVersions -contains $imageVersion ) ) { + docker build --build-arg "PNP_MODULE_VERSION=$moduleVersion" --build-arg "BASE_IMAGE_SUFFIX=$baseImageSuffix" --build-arg "SKIP_PUBLISHER_CHECK=FALSE" ./docker -f ./docker/$DOCKER_FILE_NAME --tag $DOCKER_USERNAME/$DOCKER_IMAGE_NAME`:$imageVersion; + docker image tag $DOCKER_USERNAME/$DOCKER_IMAGE_NAME`:$imageVersion$DOCKER_USERNAME/$DOCKER_IMAGE_NAME`:latest; + $plainStringPassword = [System.Net.NetworkCredential]::new("", $DOCKER_PASSWORD).Password; + docker login -u $DOCKER_USERNAME -p "$plainStringPassword"; + docker push $DOCKER_USERNAME/$DOCKER_IMAGE_NAME`:$imageVersion; + docker push $DOCKER_USERNAME/$DOCKER_IMAGE_NAME`:latest; + } } } diff --git a/docker/README.md b/docker/README.md index cc61e4c4d..ddd5f55d8 100644 --- a/docker/README.md +++ b/docker/README.md @@ -1,4 +1,4 @@ -# Publish manually +# Publish manually in Windows 1. Set "DOCKER_USERNAME" and "DOCKER_PASSWORD" variables @@ -6,7 +6,18 @@ ```powershell $securedPassword = ConvertTo-SecureString $DOCKER_PASSWORD -AsPlainText -Force -./docker/Publish-UnpublishedImage.ps1 PnP.PowerShell $DOCKER_USERNAME powershell $securedPassword +./docker/Publish-UnpublishedImage.ps1 PnP.PowerShell $DOCKER_USERNAME powershell $securedPassword "pnppowershell-windows.dockerFile" $true "nanoserver-1809,nanoserver-20h2,nanoserver-ltsc2022" +``` + +# Publish manually in Linux + +1. Set "DOCKER_USERNAME" and "DOCKER_PASSWORD" variables + +2. Run + +```powershell +$securedPassword = ConvertTo-SecureString $DOCKER_PASSWORD -AsPlainText -Force +./docker/Publish-UnpublishedImage.ps1 PnP.PowerShell $DOCKER_USERNAME powershell $securedPassword "pnppowershell.dockerFile" $false "alpine-3.14,arm32v7-ubuntu-bionic" ``` # Publish with prereleases manually diff --git a/docker/pnppowershell.dockerFile b/docker/pnppowershell.dockerFile index b46b7e6c9..210218447 100644 --- a/docker/pnppowershell.dockerFile +++ b/docker/pnppowershell.dockerFile @@ -1,5 +1,12 @@ -FROM mcr.microsoft.com/powershell:7.2.2-alpine-3.14-20220318 +ARG BASE_IMAGE_SUFFIX=alpine-3.14 +ARG BASE_IMAGE=mcr.microsoft.com/powershell:lts-7.2-$BASE_IMAGE_SUFFIX +FROM $BASE_IMAGE SHELL ["pwsh", "-command"] +ARG SKIP_PUBLISHER_CHECK = "TRUE" ARG PNP_MODULE_VERSION -RUN Install-Module -Name PnP.PowerShell -RequiredVersion $env:PNP_MODULE_VERSION -Force -AllowPrerelease +RUN if ( $SKIP_PUBLISHER_CHECK ) { \ + Install-Module -Name PnP.PowerShell -RequiredVersion $env:PNP_MODULE_VERSION -Force -AllowPrerelease -SkipPublisherCheck \ + } else { \ + Install-Module -Name PnP.PowerShell -RequiredVersion $env:PNP_MODULE_VERSION -Force -AllowPrerelease \ + } From 648bef5f87d7e8e9f60b0606187b7ec1f2042b97 Mon Sep 17 00:00:00 2001 From: Aleks Date: Wed, 11 May 2022 08:51:43 +0200 Subject: [PATCH 45/70] fixing parameters in github actions --- .github/workflows/release.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 071c93f89..f543fe225 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -13,7 +13,7 @@ jobs: shell: pwsh run: | $securedPassword = ConvertTo-SecureString "${{ secrets.DOCKER_PASSWORD }}" -AsPlainText -Force - ./docker/Publish-UnpublishedImage.ps1 PnP.PowerShell ${{ secrets.DOCKER_USERNAME }} powershell $securedPassword "pnppowershell-windows.dockerFile" "nanoserver-1809,nanoserver-20h2,nanoserver-ltsc2022" + ./docker/Publish-UnpublishedImage.ps1 PnP.PowerShell ${{ secrets.DOCKER_USERNAME }} powershell $securedPassword "pnppowershell-windows.dockerFile" $true "nanoserver-1809,nanoserver-20h2,nanoserver-ltsc2022" publish-docker-linux: runs-on: ubuntu-latest steps: @@ -22,4 +22,4 @@ jobs: shell: pwsh run: | $securedPassword = ConvertTo-SecureString "${{ secrets.DOCKER_PASSWORD }}" -AsPlainText -Force - ./docker/Publish-UnpublishedImage.ps1 PnP.PowerShell ${{ secrets.DOCKER_USERNAME }} powershell $securedPassword "pnppowershell.dockerFile" "alpine-3.14,arm32v7-ubuntu-bionic" + ./docker/Publish-UnpublishedImage.ps1 PnP.PowerShell ${{ secrets.DOCKER_USERNAME }} powershell $securedPassword "pnppowershell.dockerFile" $false "alpine-3.14,arm32v7-ubuntu-bionic" From f30429151dc2440afe6bf553d60225734f1c9a30 Mon Sep 17 00:00:00 2001 From: Aleks Date: Wed, 11 May 2022 08:55:51 +0200 Subject: [PATCH 46/70] typo in space --- docker/Publish-UnpublishedImage.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/Publish-UnpublishedImage.ps1 b/docker/Publish-UnpublishedImage.ps1 index 7ddb8fceb..c4c529cae 100644 --- a/docker/Publish-UnpublishedImage.ps1 +++ b/docker/Publish-UnpublishedImage.ps1 @@ -48,7 +48,7 @@ $moduleVersions | % { Write-Host "Checking $imageVersion" if ( !( $publishedImageVersions -contains $imageVersion ) ) { docker build --build-arg "PNP_MODULE_VERSION=$moduleVersion" --build-arg "BASE_IMAGE_SUFFIX=$baseImageSuffix" --build-arg "SKIP_PUBLISHER_CHECK=FALSE" ./docker -f ./docker/$DOCKER_FILE_NAME --tag $DOCKER_USERNAME/$DOCKER_IMAGE_NAME`:$imageVersion; - docker image tag $DOCKER_USERNAME/$DOCKER_IMAGE_NAME`:$imageVersion$DOCKER_USERNAME/$DOCKER_IMAGE_NAME`:latest; + docker image tag $DOCKER_USERNAME/$DOCKER_IMAGE_NAME`:$imageVersion $DOCKER_USERNAME/$DOCKER_IMAGE_NAME`:latest; $plainStringPassword = [System.Net.NetworkCredential]::new("", $DOCKER_PASSWORD).Password; docker login -u $DOCKER_USERNAME -p "$plainStringPassword"; docker push $DOCKER_USERNAME/$DOCKER_IMAGE_NAME`:$imageVersion; From 22bbf90dd5d55ab129e275a720fbca7d77fe86d0 Mon Sep 17 00:00:00 2001 From: Aleks Date: Wed, 11 May 2022 09:13:06 +0200 Subject: [PATCH 47/70] sticking to 1 dockerfile --- .github/workflows/release.yml | 4 ++-- docker/Publish-UnpublishedImage.ps1 | 7 +------ docker/README.md | 4 ++-- 3 files changed, 5 insertions(+), 10 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index f543fe225..38138fde0 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -13,7 +13,7 @@ jobs: shell: pwsh run: | $securedPassword = ConvertTo-SecureString "${{ secrets.DOCKER_PASSWORD }}" -AsPlainText -Force - ./docker/Publish-UnpublishedImage.ps1 PnP.PowerShell ${{ secrets.DOCKER_USERNAME }} powershell $securedPassword "pnppowershell-windows.dockerFile" $true "nanoserver-1809,nanoserver-20h2,nanoserver-ltsc2022" + ./docker/Publish-UnpublishedImage.ps1 PnP.PowerShell ${{ secrets.DOCKER_USERNAME }} powershell $securedPassword $true "nanoserver-1809,nanoserver-20h2,nanoserver-ltsc2022" publish-docker-linux: runs-on: ubuntu-latest steps: @@ -22,4 +22,4 @@ jobs: shell: pwsh run: | $securedPassword = ConvertTo-SecureString "${{ secrets.DOCKER_PASSWORD }}" -AsPlainText -Force - ./docker/Publish-UnpublishedImage.ps1 PnP.PowerShell ${{ secrets.DOCKER_USERNAME }} powershell $securedPassword "pnppowershell.dockerFile" $false "alpine-3.14,arm32v7-ubuntu-bionic" + ./docker/Publish-UnpublishedImage.ps1 PnP.PowerShell ${{ secrets.DOCKER_USERNAME }} powershell $securedPassword $false "alpine-3.14,arm32v7-ubuntu-bionic" diff --git a/docker/Publish-UnpublishedImage.ps1 b/docker/Publish-UnpublishedImage.ps1 index c4c529cae..8689f163c 100644 --- a/docker/Publish-UnpublishedImage.ps1 +++ b/docker/Publish-UnpublishedImage.ps1 @@ -22,14 +22,9 @@ Param( [Parameter(Position = 4, Mandatory = $false, ValueFromPipeline = $false)] - [String] - $DOCKER_FILE_NAME = "pnppowershell.dockerFile", - [Parameter(Position = 5, - Mandatory = $false, - ValueFromPipeline = $false)] [bool] $SKIP_PUBLISHER_CHECK = $false, - [Parameter(Position = 6, + [Parameter(Position = 5, Mandatory = $false, ValueFromPipeline = $false)] [String] diff --git a/docker/README.md b/docker/README.md index ddd5f55d8..c4abd5c26 100644 --- a/docker/README.md +++ b/docker/README.md @@ -6,7 +6,7 @@ ```powershell $securedPassword = ConvertTo-SecureString $DOCKER_PASSWORD -AsPlainText -Force -./docker/Publish-UnpublishedImage.ps1 PnP.PowerShell $DOCKER_USERNAME powershell $securedPassword "pnppowershell-windows.dockerFile" $true "nanoserver-1809,nanoserver-20h2,nanoserver-ltsc2022" +./docker/Publish-UnpublishedImage.ps1 PnP.PowerShell $DOCKER_USERNAME powershell $securedPassword $true "nanoserver-1809,nanoserver-20h2,nanoserver-ltsc2022" ``` # Publish manually in Linux @@ -17,7 +17,7 @@ $securedPassword = ConvertTo-SecureString $DOCKER_PASSWORD -AsPlainText -Force ```powershell $securedPassword = ConvertTo-SecureString $DOCKER_PASSWORD -AsPlainText -Force -./docker/Publish-UnpublishedImage.ps1 PnP.PowerShell $DOCKER_USERNAME powershell $securedPassword "pnppowershell.dockerFile" $false "alpine-3.14,arm32v7-ubuntu-bionic" +./docker/Publish-UnpublishedImage.ps1 PnP.PowerShell $DOCKER_USERNAME powershell $securedPassword $false "alpine-3.14,arm32v7-ubuntu-bionic" ``` # Publish with prereleases manually From b7c01a8b6ab8abde1a68fb0c0bfc8aa8720d6e6b Mon Sep 17 00:00:00 2001 From: Aleks Date: Wed, 11 May 2022 10:56:39 +0200 Subject: [PATCH 48/70] altering installation user --- .github/workflows/release.yml | 4 ++-- docker/Publish-UnpublishedImage.ps1 | 9 +++++++-- docker/README.md | 4 ++-- docker/pnppowershell.dockerFile | 11 +++++++---- 4 files changed, 18 insertions(+), 10 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 38138fde0..4803e56c5 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -13,7 +13,7 @@ jobs: shell: pwsh run: | $securedPassword = ConvertTo-SecureString "${{ secrets.DOCKER_PASSWORD }}" -AsPlainText -Force - ./docker/Publish-UnpublishedImage.ps1 PnP.PowerShell ${{ secrets.DOCKER_USERNAME }} powershell $securedPassword $true "nanoserver-1809,nanoserver-20h2,nanoserver-ltsc2022" + ./docker/Publish-UnpublishedImage.ps1 PnP.PowerShell ${{ secrets.DOCKER_USERNAME }} powershell $securedPassword "ContainerAdministrator" $true "nanoserver-1809,nanoserver-20h2,nanoserver-ltsc2022" publish-docker-linux: runs-on: ubuntu-latest steps: @@ -22,4 +22,4 @@ jobs: shell: pwsh run: | $securedPassword = ConvertTo-SecureString "${{ secrets.DOCKER_PASSWORD }}" -AsPlainText -Force - ./docker/Publish-UnpublishedImage.ps1 PnP.PowerShell ${{ secrets.DOCKER_USERNAME }} powershell $securedPassword $false "alpine-3.14,arm32v7-ubuntu-bionic" + ./docker/Publish-UnpublishedImage.ps1 PnP.PowerShell ${{ secrets.DOCKER_USERNAME }} powershell $securedPassword "root" $false "alpine-3.14,arm32v7-ubuntu-bionic" diff --git a/docker/Publish-UnpublishedImage.ps1 b/docker/Publish-UnpublishedImage.ps1 index 8689f163c..539a23033 100644 --- a/docker/Publish-UnpublishedImage.ps1 +++ b/docker/Publish-UnpublishedImage.ps1 @@ -22,9 +22,14 @@ Param( [Parameter(Position = 4, Mandatory = $false, ValueFromPipeline = $false)] + [String] + $DOCKER_INSTALL_USER = "ContainerAdministrator", + [Parameter(Position = 5, + Mandatory = $false, + ValueFromPipeline = $false)] [bool] $SKIP_PUBLISHER_CHECK = $false, - [Parameter(Position = 5, + [Parameter(Position = 6, Mandatory = $false, ValueFromPipeline = $false)] [String] @@ -42,7 +47,7 @@ $moduleVersions | % { $imageVersion = "$moduleVersion-$baseImageSuffix"; Write-Host "Checking $imageVersion" if ( !( $publishedImageVersions -contains $imageVersion ) ) { - docker build --build-arg "PNP_MODULE_VERSION=$moduleVersion" --build-arg "BASE_IMAGE_SUFFIX=$baseImageSuffix" --build-arg "SKIP_PUBLISHER_CHECK=FALSE" ./docker -f ./docker/$DOCKER_FILE_NAME --tag $DOCKER_USERNAME/$DOCKER_IMAGE_NAME`:$imageVersion; + docker build --build-arg "PNP_MODULE_VERSION=$moduleVersion" --build-arg "BASE_IMAGE_SUFFIX=$baseImageSuffix" --build-arg "INSTALL_USER=$DOCKER_INSTALL_USER" --build-arg "SKIP_PUBLISHER_CHECK=$SKIP_PUBLISHER_CHECK" ./docker -f ./docker/pnppowershell.dockerFile --tag $DOCKER_USERNAME/$DOCKER_IMAGE_NAME`:$imageVersion; docker image tag $DOCKER_USERNAME/$DOCKER_IMAGE_NAME`:$imageVersion $DOCKER_USERNAME/$DOCKER_IMAGE_NAME`:latest; $plainStringPassword = [System.Net.NetworkCredential]::new("", $DOCKER_PASSWORD).Password; docker login -u $DOCKER_USERNAME -p "$plainStringPassword"; diff --git a/docker/README.md b/docker/README.md index c4abd5c26..df53f4033 100644 --- a/docker/README.md +++ b/docker/README.md @@ -6,7 +6,7 @@ ```powershell $securedPassword = ConvertTo-SecureString $DOCKER_PASSWORD -AsPlainText -Force -./docker/Publish-UnpublishedImage.ps1 PnP.PowerShell $DOCKER_USERNAME powershell $securedPassword $true "nanoserver-1809,nanoserver-20h2,nanoserver-ltsc2022" +./docker/Publish-UnpublishedImage.ps1 PnP.PowerShell $DOCKER_USERNAME powershell $securedPassword "ContainerAdministrator" $true "nanoserver-1809,nanoserver-20h2,nanoserver-ltsc2022" ``` # Publish manually in Linux @@ -17,7 +17,7 @@ $securedPassword = ConvertTo-SecureString $DOCKER_PASSWORD -AsPlainText -Force ```powershell $securedPassword = ConvertTo-SecureString $DOCKER_PASSWORD -AsPlainText -Force -./docker/Publish-UnpublishedImage.ps1 PnP.PowerShell $DOCKER_USERNAME powershell $securedPassword $false "alpine-3.14,arm32v7-ubuntu-bionic" +./docker/Publish-UnpublishedImage.ps1 PnP.PowerShell $DOCKER_USERNAME powershell $securedPassword $false "root" "alpine-3.14,arm32v7-ubuntu-bionic" ``` # Publish with prereleases manually diff --git a/docker/pnppowershell.dockerFile b/docker/pnppowershell.dockerFile index 210218447..350ca3084 100644 --- a/docker/pnppowershell.dockerFile +++ b/docker/pnppowershell.dockerFile @@ -3,10 +3,13 @@ ARG BASE_IMAGE=mcr.microsoft.com/powershell:lts-7.2-$BASE_IMAGE_SUFFIX FROM $BASE_IMAGE SHELL ["pwsh", "-command"] -ARG SKIP_PUBLISHER_CHECK = "TRUE" +ARG INSTALL_USER="ContainerAdministrator" +USER $INSTALL_USER ARG PNP_MODULE_VERSION -RUN if ( $SKIP_PUBLISHER_CHECK ) { \ - Install-Module -Name PnP.PowerShell -RequiredVersion $env:PNP_MODULE_VERSION -Force -AllowPrerelease -SkipPublisherCheck \ +ARG SKIP_PUBLISHER_CHECK="TRUE" +RUN if ( $env:SKIP_PUBLISHER_CHECK ) { \ + Write-Host "SKIP_PUBLISHER_CHECK"; \ + Install-Module -Name PnP.PowerShell -RequiredVersion $env:PNP_MODULE_VERSION -Force -AllowPrerelease -SkipPublisherCheck; \ } else { \ - Install-Module -Name PnP.PowerShell -RequiredVersion $env:PNP_MODULE_VERSION -Force -AllowPrerelease \ + Install-Module -Name PnP.PowerShell -RequiredVersion $env:PNP_MODULE_VERSION -Force -AllowPrerelease; \ } From 20888fd22a34c19c91f230d494866d211e363232 Mon Sep 17 00:00:00 2001 From: Aleks Date: Wed, 11 May 2022 12:11:35 +0200 Subject: [PATCH 49/70] 3 platforms for Windows is default --- docker/Publish-UnpublishedImage.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/Publish-UnpublishedImage.ps1 b/docker/Publish-UnpublishedImage.ps1 index 539a23033..5995002a8 100644 --- a/docker/Publish-UnpublishedImage.ps1 +++ b/docker/Publish-UnpublishedImage.ps1 @@ -33,7 +33,7 @@ Param( Mandatory = $false, ValueFromPipeline = $false)] [String] - $DOCKER_IMAGE_SUFFIX_ARRAY = "nanoserver-1809" + $DOCKER_IMAGE_SUFFIX_ARRAY = "nanoserver-1809,nanoserver-20h2,nanoserver-ltsc2022" ) $publishedImageVersions = (Invoke-RestMethod https://registry.hub.docker.com/v2/repositories/$DOCKER_USERNAME/$DOCKER_IMAGE_NAME/tags?page_size=10240).results | % { $_.name From dc1dcfe4398127ee95801deb4bca8f1a544e0db1 Mon Sep 17 00:00:00 2001 From: Aleks Date: Wed, 11 May 2022 12:16:16 +0200 Subject: [PATCH 50/70] fixed string comparison --- docker/pnppowershell.dockerFile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/pnppowershell.dockerFile b/docker/pnppowershell.dockerFile index 350ca3084..585cefd75 100644 --- a/docker/pnppowershell.dockerFile +++ b/docker/pnppowershell.dockerFile @@ -7,7 +7,7 @@ ARG INSTALL_USER="ContainerAdministrator" USER $INSTALL_USER ARG PNP_MODULE_VERSION ARG SKIP_PUBLISHER_CHECK="TRUE" -RUN if ( $env:SKIP_PUBLISHER_CHECK ) { \ +RUN if ( $env:SKIP_PUBLISHER_CHECK -eq "True" ) { \ Write-Host "SKIP_PUBLISHER_CHECK"; \ Install-Module -Name PnP.PowerShell -RequiredVersion $env:PNP_MODULE_VERSION -Force -AllowPrerelease -SkipPublisherCheck; \ } else { \ From 2a3c3e7e2e35acea44aa37f967b5b91069cf3be7 Mon Sep 17 00:00:00 2001 From: Aleks Date: Wed, 11 May 2022 12:18:21 +0200 Subject: [PATCH 51/70] removing unnecessary quotes --- docker/pnppowershell.dockerFile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docker/pnppowershell.dockerFile b/docker/pnppowershell.dockerFile index 585cefd75..9389e9298 100644 --- a/docker/pnppowershell.dockerFile +++ b/docker/pnppowershell.dockerFile @@ -3,10 +3,10 @@ ARG BASE_IMAGE=mcr.microsoft.com/powershell:lts-7.2-$BASE_IMAGE_SUFFIX FROM $BASE_IMAGE SHELL ["pwsh", "-command"] -ARG INSTALL_USER="ContainerAdministrator" +ARG INSTALL_USER=ContainerAdministrator USER $INSTALL_USER ARG PNP_MODULE_VERSION -ARG SKIP_PUBLISHER_CHECK="TRUE" +ARG SKIP_PUBLISHER_CHECK=TRUE RUN if ( $env:SKIP_PUBLISHER_CHECK -eq "True" ) { \ Write-Host "SKIP_PUBLISHER_CHECK"; \ Install-Module -Name PnP.PowerShell -RequiredVersion $env:PNP_MODULE_VERSION -Force -AllowPrerelease -SkipPublisherCheck; \ From b91081aef4e2326a104f5efd9d74f065239bdcce Mon Sep 17 00:00:00 2001 From: Aleks Date: Wed, 11 May 2022 12:31:53 +0200 Subject: [PATCH 52/70] fixed logical comparison --- docker/pnppowershell.dockerFile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/pnppowershell.dockerFile b/docker/pnppowershell.dockerFile index 9389e9298..28fe6302b 100644 --- a/docker/pnppowershell.dockerFile +++ b/docker/pnppowershell.dockerFile @@ -7,7 +7,7 @@ ARG INSTALL_USER=ContainerAdministrator USER $INSTALL_USER ARG PNP_MODULE_VERSION ARG SKIP_PUBLISHER_CHECK=TRUE -RUN if ( $env:SKIP_PUBLISHER_CHECK -eq "True" ) { \ +RUN if ( $env:SKIP_PUBLISHER_CHECK -eq $true ) { \ Write-Host "SKIP_PUBLISHER_CHECK"; \ Install-Module -Name PnP.PowerShell -RequiredVersion $env:PNP_MODULE_VERSION -Force -AllowPrerelease -SkipPublisherCheck; \ } else { \ From 05b0cfc591698ee57b617df4762227e10f2c308f Mon Sep 17 00:00:00 2001 From: Aleks Date: Wed, 11 May 2022 13:57:33 +0200 Subject: [PATCH 53/70] specifying platform for building --- docker/Publish-UnpublishedImage.ps1 | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/docker/Publish-UnpublishedImage.ps1 b/docker/Publish-UnpublishedImage.ps1 index 5995002a8..e75d052ee 100644 --- a/docker/Publish-UnpublishedImage.ps1 +++ b/docker/Publish-UnpublishedImage.ps1 @@ -47,7 +47,18 @@ $moduleVersions | % { $imageVersion = "$moduleVersion-$baseImageSuffix"; Write-Host "Checking $imageVersion" if ( !( $publishedImageVersions -contains $imageVersion ) ) { - docker build --build-arg "PNP_MODULE_VERSION=$moduleVersion" --build-arg "BASE_IMAGE_SUFFIX=$baseImageSuffix" --build-arg "INSTALL_USER=$DOCKER_INSTALL_USER" --build-arg "SKIP_PUBLISHER_CHECK=$SKIP_PUBLISHER_CHECK" ./docker -f ./docker/pnppowershell.dockerFile --tag $DOCKER_USERNAME/$DOCKER_IMAGE_NAME`:$imageVersion; + $platform = switch ( $baseImageSuffix ) { + "alpine-3.14" { + "linux/amd64" + } + "arm32v7-ubuntu-bionic" { + "linux/arm/v7" + } + default { "Windows" } + } + $platform + if ( $baseImageSuffix -eq "alpine-3.14" ) {} + docker build --platform=$platform --build-arg "PNP_MODULE_VERSION=$moduleVersion" --build-arg "BASE_IMAGE_SUFFIX=$baseImageSuffix" --build-arg "INSTALL_USER=$DOCKER_INSTALL_USER" --build-arg "SKIP_PUBLISHER_CHECK=$SKIP_PUBLISHER_CHECK" ./docker -f ./docker/pnppowershell.dockerFile --tag $DOCKER_USERNAME/$DOCKER_IMAGE_NAME`:$imageVersion; docker image tag $DOCKER_USERNAME/$DOCKER_IMAGE_NAME`:$imageVersion $DOCKER_USERNAME/$DOCKER_IMAGE_NAME`:latest; $plainStringPassword = [System.Net.NetworkCredential]::new("", $DOCKER_PASSWORD).Password; docker login -u $DOCKER_USERNAME -p "$plainStringPassword"; From e6bcb170b947cd6b5734e208f52fd0aa8cfd3630 Mon Sep 17 00:00:00 2001 From: Aleks Date: Wed, 11 May 2022 18:00:10 +0200 Subject: [PATCH 54/70] using buildx for arm32v7-ubuntu-bionic --- .github/workflows/release.yml | 4 ++++ docker/Publish-UnpublishedImage.ps1 | 15 ++++----------- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 4803e56c5..5e72fcb1a 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -18,6 +18,10 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 + - name: Set up QEMU + uses: docker/setup-qemu-action@v1 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 - name: Build and Publish All shell: pwsh run: | diff --git a/docker/Publish-UnpublishedImage.ps1 b/docker/Publish-UnpublishedImage.ps1 index e75d052ee..e88f0a928 100644 --- a/docker/Publish-UnpublishedImage.ps1 +++ b/docker/Publish-UnpublishedImage.ps1 @@ -47,18 +47,11 @@ $moduleVersions | % { $imageVersion = "$moduleVersion-$baseImageSuffix"; Write-Host "Checking $imageVersion" if ( !( $publishedImageVersions -contains $imageVersion ) ) { - $platform = switch ( $baseImageSuffix ) { - "alpine-3.14" { - "linux/amd64" - } - "arm32v7-ubuntu-bionic" { - "linux/arm/v7" - } - default { "Windows" } + if ( $baseImageSuffix -eq "arm32v7-ubuntu-bionic" ) { + docker buildx build --platform linux/arm/v7 --build-arg "PNP_MODULE_VERSION=$moduleVersion" --build-arg "BASE_IMAGE_SUFFIX=$baseImageSuffix" --build-arg "INSTALL_USER=$DOCKER_INSTALL_USER" --build-arg "SKIP_PUBLISHER_CHECK=$SKIP_PUBLISHER_CHECK" ./docker -f ./docker/pnppowershell.dockerFile --tag $DOCKER_USERNAME/$DOCKER_IMAGE_NAME`:$imageVersion; + } else { + docker build --platform=$platform --build-arg "PNP_MODULE_VERSION=$moduleVersion" --build-arg "BASE_IMAGE_SUFFIX=$baseImageSuffix" --build-arg "INSTALL_USER=$DOCKER_INSTALL_USER" --build-arg "SKIP_PUBLISHER_CHECK=$SKIP_PUBLISHER_CHECK" ./docker -f ./docker/pnppowershell.dockerFile --tag $DOCKER_USERNAME/$DOCKER_IMAGE_NAME`:$imageVersion; } - $platform - if ( $baseImageSuffix -eq "alpine-3.14" ) {} - docker build --platform=$platform --build-arg "PNP_MODULE_VERSION=$moduleVersion" --build-arg "BASE_IMAGE_SUFFIX=$baseImageSuffix" --build-arg "INSTALL_USER=$DOCKER_INSTALL_USER" --build-arg "SKIP_PUBLISHER_CHECK=$SKIP_PUBLISHER_CHECK" ./docker -f ./docker/pnppowershell.dockerFile --tag $DOCKER_USERNAME/$DOCKER_IMAGE_NAME`:$imageVersion; docker image tag $DOCKER_USERNAME/$DOCKER_IMAGE_NAME`:$imageVersion $DOCKER_USERNAME/$DOCKER_IMAGE_NAME`:latest; $plainStringPassword = [System.Net.NetworkCredential]::new("", $DOCKER_PASSWORD).Password; docker login -u $DOCKER_USERNAME -p "$plainStringPassword"; From b07ee24a0cb5dd286ff25290987c2046b7708471 Mon Sep 17 00:00:00 2001 From: Aleks Date: Wed, 11 May 2022 18:11:35 +0200 Subject: [PATCH 55/70] buildx debug output --- docker/Publish-UnpublishedImage.ps1 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docker/Publish-UnpublishedImage.ps1 b/docker/Publish-UnpublishedImage.ps1 index e88f0a928..097204124 100644 --- a/docker/Publish-UnpublishedImage.ps1 +++ b/docker/Publish-UnpublishedImage.ps1 @@ -48,9 +48,10 @@ $moduleVersions | % { Write-Host "Checking $imageVersion" if ( !( $publishedImageVersions -contains $imageVersion ) ) { if ( $baseImageSuffix -eq "arm32v7-ubuntu-bionic" ) { + Write-Host "Using buildx --platform linux/arm/v7"; docker buildx build --platform linux/arm/v7 --build-arg "PNP_MODULE_VERSION=$moduleVersion" --build-arg "BASE_IMAGE_SUFFIX=$baseImageSuffix" --build-arg "INSTALL_USER=$DOCKER_INSTALL_USER" --build-arg "SKIP_PUBLISHER_CHECK=$SKIP_PUBLISHER_CHECK" ./docker -f ./docker/pnppowershell.dockerFile --tag $DOCKER_USERNAME/$DOCKER_IMAGE_NAME`:$imageVersion; } else { - docker build --platform=$platform --build-arg "PNP_MODULE_VERSION=$moduleVersion" --build-arg "BASE_IMAGE_SUFFIX=$baseImageSuffix" --build-arg "INSTALL_USER=$DOCKER_INSTALL_USER" --build-arg "SKIP_PUBLISHER_CHECK=$SKIP_PUBLISHER_CHECK" ./docker -f ./docker/pnppowershell.dockerFile --tag $DOCKER_USERNAME/$DOCKER_IMAGE_NAME`:$imageVersion; + docker build --build-arg "PNP_MODULE_VERSION=$moduleVersion" --build-arg "BASE_IMAGE_SUFFIX=$baseImageSuffix" --build-arg "INSTALL_USER=$DOCKER_INSTALL_USER" --build-arg "SKIP_PUBLISHER_CHECK=$SKIP_PUBLISHER_CHECK" ./docker -f ./docker/pnppowershell.dockerFile --tag $DOCKER_USERNAME/$DOCKER_IMAGE_NAME`:$imageVersion; } docker image tag $DOCKER_USERNAME/$DOCKER_IMAGE_NAME`:$imageVersion $DOCKER_USERNAME/$DOCKER_IMAGE_NAME`:latest; $plainStringPassword = [System.Net.NetworkCredential]::new("", $DOCKER_PASSWORD).Password; From b67fc3116a89662733830a67b5db411f3b12c307 Mon Sep 17 00:00:00 2001 From: Aleks Date: Wed, 11 May 2022 18:41:02 +0200 Subject: [PATCH 56/70] buildx build --load --- docker/Publish-UnpublishedImage.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/Publish-UnpublishedImage.ps1 b/docker/Publish-UnpublishedImage.ps1 index 097204124..862c19ba9 100644 --- a/docker/Publish-UnpublishedImage.ps1 +++ b/docker/Publish-UnpublishedImage.ps1 @@ -49,7 +49,7 @@ $moduleVersions | % { if ( !( $publishedImageVersions -contains $imageVersion ) ) { if ( $baseImageSuffix -eq "arm32v7-ubuntu-bionic" ) { Write-Host "Using buildx --platform linux/arm/v7"; - docker buildx build --platform linux/arm/v7 --build-arg "PNP_MODULE_VERSION=$moduleVersion" --build-arg "BASE_IMAGE_SUFFIX=$baseImageSuffix" --build-arg "INSTALL_USER=$DOCKER_INSTALL_USER" --build-arg "SKIP_PUBLISHER_CHECK=$SKIP_PUBLISHER_CHECK" ./docker -f ./docker/pnppowershell.dockerFile --tag $DOCKER_USERNAME/$DOCKER_IMAGE_NAME`:$imageVersion; + docker buildx build --load --platform linux/arm/v7 --build-arg "PNP_MODULE_VERSION=$moduleVersion" --build-arg "BASE_IMAGE_SUFFIX=$baseImageSuffix" --build-arg "INSTALL_USER=$DOCKER_INSTALL_USER" --build-arg "SKIP_PUBLISHER_CHECK=$SKIP_PUBLISHER_CHECK" ./docker -f ./docker/pnppowershell.dockerFile --tag $DOCKER_USERNAME/$DOCKER_IMAGE_NAME`:$imageVersion; } else { docker build --build-arg "PNP_MODULE_VERSION=$moduleVersion" --build-arg "BASE_IMAGE_SUFFIX=$baseImageSuffix" --build-arg "INSTALL_USER=$DOCKER_INSTALL_USER" --build-arg "SKIP_PUBLISHER_CHECK=$SKIP_PUBLISHER_CHECK" ./docker -f ./docker/pnppowershell.dockerFile --tag $DOCKER_USERNAME/$DOCKER_IMAGE_NAME`:$imageVersion; } From 91ccc10caccf23b4e93613e560aea11bf5909fca Mon Sep 17 00:00:00 2001 From: Aleks Date: Thu, 12 May 2022 12:44:28 +0200 Subject: [PATCH 57/70] removing arm image --- .github/workflows/release.yml | 6 +----- docker/Publish-UnpublishedImage.ps1 | 7 +------ 2 files changed, 2 insertions(+), 11 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 5e72fcb1a..8e3ccc3b6 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -18,12 +18,8 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - - name: Set up QEMU - uses: docker/setup-qemu-action@v1 - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v1 - name: Build and Publish All shell: pwsh run: | $securedPassword = ConvertTo-SecureString "${{ secrets.DOCKER_PASSWORD }}" -AsPlainText -Force - ./docker/Publish-UnpublishedImage.ps1 PnP.PowerShell ${{ secrets.DOCKER_USERNAME }} powershell $securedPassword "root" $false "alpine-3.14,arm32v7-ubuntu-bionic" + ./docker/Publish-UnpublishedImage.ps1 PnP.PowerShell ${{ secrets.DOCKER_USERNAME }} powershell $securedPassword "root" $false "alpine-3.14" diff --git a/docker/Publish-UnpublishedImage.ps1 b/docker/Publish-UnpublishedImage.ps1 index 862c19ba9..5995002a8 100644 --- a/docker/Publish-UnpublishedImage.ps1 +++ b/docker/Publish-UnpublishedImage.ps1 @@ -47,12 +47,7 @@ $moduleVersions | % { $imageVersion = "$moduleVersion-$baseImageSuffix"; Write-Host "Checking $imageVersion" if ( !( $publishedImageVersions -contains $imageVersion ) ) { - if ( $baseImageSuffix -eq "arm32v7-ubuntu-bionic" ) { - Write-Host "Using buildx --platform linux/arm/v7"; - docker buildx build --load --platform linux/arm/v7 --build-arg "PNP_MODULE_VERSION=$moduleVersion" --build-arg "BASE_IMAGE_SUFFIX=$baseImageSuffix" --build-arg "INSTALL_USER=$DOCKER_INSTALL_USER" --build-arg "SKIP_PUBLISHER_CHECK=$SKIP_PUBLISHER_CHECK" ./docker -f ./docker/pnppowershell.dockerFile --tag $DOCKER_USERNAME/$DOCKER_IMAGE_NAME`:$imageVersion; - } else { - docker build --build-arg "PNP_MODULE_VERSION=$moduleVersion" --build-arg "BASE_IMAGE_SUFFIX=$baseImageSuffix" --build-arg "INSTALL_USER=$DOCKER_INSTALL_USER" --build-arg "SKIP_PUBLISHER_CHECK=$SKIP_PUBLISHER_CHECK" ./docker -f ./docker/pnppowershell.dockerFile --tag $DOCKER_USERNAME/$DOCKER_IMAGE_NAME`:$imageVersion; - } + docker build --build-arg "PNP_MODULE_VERSION=$moduleVersion" --build-arg "BASE_IMAGE_SUFFIX=$baseImageSuffix" --build-arg "INSTALL_USER=$DOCKER_INSTALL_USER" --build-arg "SKIP_PUBLISHER_CHECK=$SKIP_PUBLISHER_CHECK" ./docker -f ./docker/pnppowershell.dockerFile --tag $DOCKER_USERNAME/$DOCKER_IMAGE_NAME`:$imageVersion; docker image tag $DOCKER_USERNAME/$DOCKER_IMAGE_NAME`:$imageVersion $DOCKER_USERNAME/$DOCKER_IMAGE_NAME`:latest; $plainStringPassword = [System.Net.NetworkCredential]::new("", $DOCKER_PASSWORD).Password; docker login -u $DOCKER_USERNAME -p "$plainStringPassword"; From f80ce939209554c60246778a7120c2a486a44d99 Mon Sep 17 00:00:00 2001 From: Aleks Date: Thu, 12 May 2022 14:27:10 +0200 Subject: [PATCH 58/70] keeping 3 platforms --- .github/workflows/release.yml | 15 ++++++++++++--- docker/Publish-UnpublishedImage.ps1 | 2 +- docker/README.md | 2 +- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 8e3ccc3b6..7f22680de 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -5,15 +5,24 @@ on: schedule: - cron: '30 3 * * *' jobs: - publish-docker-windows: - runs-on: windows-latest + publish-docker-windows-2022: + runs-on: windows-2022 steps: - uses: actions/checkout@v2 - name: Build and Publish All shell: pwsh run: | $securedPassword = ConvertTo-SecureString "${{ secrets.DOCKER_PASSWORD }}" -AsPlainText -Force - ./docker/Publish-UnpublishedImage.ps1 PnP.PowerShell ${{ secrets.DOCKER_USERNAME }} powershell $securedPassword "ContainerAdministrator" $true "nanoserver-1809,nanoserver-20h2,nanoserver-ltsc2022" + ./docker/Publish-UnpublishedImage.ps1 PnP.PowerShell ${{ secrets.DOCKER_USERNAME }} powershell $securedPassword "ContainerAdministrator" $true "nanoserver-ltsc2022" + publish-docker-windows-2019: + runs-on: windows-2019 + steps: + - uses: actions/checkout@v2 + - name: Build and Publish All + shell: pwsh + run: | + $securedPassword = ConvertTo-SecureString "${{ secrets.DOCKER_PASSWORD }}" -AsPlainText -Force + ./docker/Publish-UnpublishedImage.ps1 PnP.PowerShell ${{ secrets.DOCKER_USERNAME }} powershell $securedPassword "ContainerAdministrator" $true "nanoserver-1809" publish-docker-linux: runs-on: ubuntu-latest steps: diff --git a/docker/Publish-UnpublishedImage.ps1 b/docker/Publish-UnpublishedImage.ps1 index 5995002a8..b9a2520bd 100644 --- a/docker/Publish-UnpublishedImage.ps1 +++ b/docker/Publish-UnpublishedImage.ps1 @@ -33,7 +33,7 @@ Param( Mandatory = $false, ValueFromPipeline = $false)] [String] - $DOCKER_IMAGE_SUFFIX_ARRAY = "nanoserver-1809,nanoserver-20h2,nanoserver-ltsc2022" + $DOCKER_IMAGE_SUFFIX_ARRAY = "nanoserver-ltsc2022" ) $publishedImageVersions = (Invoke-RestMethod https://registry.hub.docker.com/v2/repositories/$DOCKER_USERNAME/$DOCKER_IMAGE_NAME/tags?page_size=10240).results | % { $_.name diff --git a/docker/README.md b/docker/README.md index df53f4033..a675a6db8 100644 --- a/docker/README.md +++ b/docker/README.md @@ -6,7 +6,7 @@ ```powershell $securedPassword = ConvertTo-SecureString $DOCKER_PASSWORD -AsPlainText -Force -./docker/Publish-UnpublishedImage.ps1 PnP.PowerShell $DOCKER_USERNAME powershell $securedPassword "ContainerAdministrator" $true "nanoserver-1809,nanoserver-20h2,nanoserver-ltsc2022" +./docker/Publish-UnpublishedImage.ps1 PnP.PowerShell $DOCKER_USERNAME powershell $securedPassword "ContainerAdministrator" $true "nanoserver-1809" ``` # Publish manually in Linux From cf2abc5d34894b9730edbe23d309e9124524f990 Mon Sep 17 00:00:00 2001 From: Aleks Date: Thu, 12 May 2022 14:58:26 +0200 Subject: [PATCH 59/70] publishing latest for only linux --- docker/Publish-UnpublishedImage.ps1 | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/docker/Publish-UnpublishedImage.ps1 b/docker/Publish-UnpublishedImage.ps1 index b9a2520bd..c75b3fc02 100644 --- a/docker/Publish-UnpublishedImage.ps1 +++ b/docker/Publish-UnpublishedImage.ps1 @@ -48,11 +48,13 @@ $moduleVersions | % { Write-Host "Checking $imageVersion" if ( !( $publishedImageVersions -contains $imageVersion ) ) { docker build --build-arg "PNP_MODULE_VERSION=$moduleVersion" --build-arg "BASE_IMAGE_SUFFIX=$baseImageSuffix" --build-arg "INSTALL_USER=$DOCKER_INSTALL_USER" --build-arg "SKIP_PUBLISHER_CHECK=$SKIP_PUBLISHER_CHECK" ./docker -f ./docker/pnppowershell.dockerFile --tag $DOCKER_USERNAME/$DOCKER_IMAGE_NAME`:$imageVersion; - docker image tag $DOCKER_USERNAME/$DOCKER_IMAGE_NAME`:$imageVersion $DOCKER_USERNAME/$DOCKER_IMAGE_NAME`:latest; $plainStringPassword = [System.Net.NetworkCredential]::new("", $DOCKER_PASSWORD).Password; docker login -u $DOCKER_USERNAME -p "$plainStringPassword"; docker push $DOCKER_USERNAME/$DOCKER_IMAGE_NAME`:$imageVersion; - docker push $DOCKER_USERNAME/$DOCKER_IMAGE_NAME`:latest; + if ( $baseImageSuffix -eq "alpine-3.14") { + docker image tag $DOCKER_USERNAME/$DOCKER_IMAGE_NAME`:$imageVersion $DOCKER_USERNAME/$DOCKER_IMAGE_NAME`:latest; + docker push $DOCKER_USERNAME/$DOCKER_IMAGE_NAME`:latest; + } } } } From 6478344a0e0407631c4cc279bbf65106ba432470 Mon Sep 17 00:00:00 2001 From: Aleks Date: Thu, 12 May 2022 16:17:51 +0200 Subject: [PATCH 60/70] nightly release for 3 platforms --- .github/workflows/nightlyrelease.yml | 51 ++++++++++++++++------------ 1 file changed, 30 insertions(+), 21 deletions(-) diff --git a/.github/workflows/nightlyrelease.yml b/.github/workflows/nightlyrelease.yml index f6c9493ee..2e99c4718 100644 --- a/.github/workflows/nightlyrelease.yml +++ b/.github/workflows/nightlyrelease.yml @@ -20,26 +20,35 @@ jobs: with: ref: dev token: ${{ secrets.PAT }} - - name: Build and Publish Module - env: - POWERSHELLGALLERY_API_KEY: ${{ secrets.POWERSHELLGALLERY_API_KEY }} - shell: pwsh + publish-docker-windows-2022: + runs-on: windows-2022 + needs: [ build ] + steps: + - uses: actions/checkout@v2 + - name: Build an image run: | - ./build/Build-Nightly.ps1 - - name: Set variables - shell: pwsh + VERSION=$(cat ./version.txt)-nightly + docker build --build-arg "PNP_MODULE_VERSION=$VERSION" --build-arg "BASE_IMAGE_SUFFIX=nanoserver-ltsc2022" --build-arg "INSTALL_USER=ContainerAdministrator" --build-arg "SKIP_PUBLISHER_CHECK=True" ./docker -f ./docker/pnppowershell.dockerFile --tag ${{ secrets.DOCKER_USERNAME }}/powershell:$VERSION-nanoserver-ltsc2022; + - name: Push the image run: | - $version = Get-Content version.txt -raw - "BUILDVERSION=$version" | Out-File $env:GITHUB_ENV -Encoding utf8 -Append - - name: Add & Commit - uses: EndBug/add-and-commit@v6 - with: - message: 'Nightly publish to PowerShell Gallery' - tag: '${{env.BUILDVERSION}}-nightly --force' - push: true - branch: dev - token: ${{ secrets.PAT }} - publish-docker: + VERSION=$(cat ./version.txt)-nightly + docker login -u ${{ secrets.DOCKER_USERNAME }} -p '${{ secrets.DOCKER_PASSWORD }}' + docker push ${{ secrets.DOCKER_USERNAME }}/powershell:$VERSION-nanoserver-ltsc2022 + publish-docker-windows-2019: + runs-on: windows-2019 + needs: [ build ] + steps: + - uses: actions/checkout@v2 + - name: Build an image + run: | + VERSION=$(cat ./version.txt)-nightly + docker build --build-arg "PNP_MODULE_VERSION=$VERSION" --build-arg "BASE_IMAGE_SUFFIX=nanoserver-1809" --build-arg "INSTALL_USER=ContainerAdministrator" --build-arg "SKIP_PUBLISHER_CHECK=True" ./docker -f ./docker/pnppowershell.dockerFile --tag ${{ secrets.DOCKER_USERNAME }}/powershell:$VERSION-nanoserver-1809; + - name: Push the image + run: | + VERSION=$(cat ./version.txt)-nightly + docker login -u ${{ secrets.DOCKER_USERNAME }} -p '${{ secrets.DOCKER_PASSWORD }}' + docker push ${{ secrets.DOCKER_USERNAME }}/powershell:$VERSION-nanoserver-1809 + publish-docker-linux: runs-on: ubuntu-latest needs: [ build ] steps: @@ -47,14 +56,14 @@ jobs: - name: Build an image run: | VERSION=$(cat ./version.txt)-nightly - docker build --build-arg "PNP_MODULE_VERSION=$VERSION" ./docker -f ./docker/pnppowershell.dockerFile --tag ${{ secrets.DOCKER_USERNAME }}/powershell:$VERSION + docker build --build-arg "PNP_MODULE_VERSION=$VERSION" --build-arg "BASE_IMAGE_SUFFIX=alpine-3.14" --build-arg "INSTALL_USER=root" --build-arg "SKIP_PUBLISHER_CHECK=False" ./docker -f ./docker/pnppowershell.dockerFile --tag ${{ secrets.DOCKER_USERNAME }}/powershell:$VERSION-alpine-3.14; - name: Tag the image run: | VERSION=$(cat ./version.txt)-nightly - docker image tag ${{ secrets.DOCKER_USERNAME }}/powershell:$VERSION ${{ secrets.DOCKER_USERNAME }}/powershell:nightly + docker image tag ${{ secrets.DOCKER_USERNAME }}/powershell:$VERSION-alpine-3.14 ${{ secrets.DOCKER_USERNAME }}/powershell:nightly - name: Push the image run: | VERSION=$(cat ./version.txt)-nightly docker login -u ${{ secrets.DOCKER_USERNAME }} -p '${{ secrets.DOCKER_PASSWORD }}' - docker push ${{ secrets.DOCKER_USERNAME }}/powershell:$VERSION + docker push ${{ secrets.DOCKER_USERNAME }}/powershell:$VERSION-alpine-3.14 docker push ${{ secrets.DOCKER_USERNAME }}/powershell:nightly From f531593d9b3e75bd7708837cbd80cc497788c458 Mon Sep 17 00:00:00 2001 From: Aleks Date: Thu, 12 May 2022 16:23:50 +0200 Subject: [PATCH 61/70] replacing with a fake job --- .github/workflows/nightlyrelease.yml | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/.github/workflows/nightlyrelease.yml b/.github/workflows/nightlyrelease.yml index 2e99c4718..2c0320e0c 100644 --- a/.github/workflows/nightlyrelease.yml +++ b/.github/workflows/nightlyrelease.yml @@ -10,16 +10,8 @@ jobs: runs-on: windows-latest steps: - - name: Setup .NET Core - uses: actions/setup-dotnet@v1 - with: - dotnet-version: | - 3.1.301 - 5.x - - uses: actions/checkout@v2 - with: - ref: dev - token: ${{ secrets.PAT }} + - shell: pwsh + run: Write-Host "hi" publish-docker-windows-2022: runs-on: windows-2022 needs: [ build ] From 051a63c1511d3389a8724361ffbd42a137aed239 Mon Sep 17 00:00:00 2001 From: Aleks Date: Thu, 12 May 2022 16:29:26 +0200 Subject: [PATCH 62/70] using PS syntax for Windows builder --- .github/workflows/nightlyrelease.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/nightlyrelease.yml b/.github/workflows/nightlyrelease.yml index 2c0320e0c..3828ac238 100644 --- a/.github/workflows/nightlyrelease.yml +++ b/.github/workflows/nightlyrelease.yml @@ -19,11 +19,11 @@ jobs: - uses: actions/checkout@v2 - name: Build an image run: | - VERSION=$(cat ./version.txt)-nightly + $VERSION=$(cat ./version.txt)-nightly docker build --build-arg "PNP_MODULE_VERSION=$VERSION" --build-arg "BASE_IMAGE_SUFFIX=nanoserver-ltsc2022" --build-arg "INSTALL_USER=ContainerAdministrator" --build-arg "SKIP_PUBLISHER_CHECK=True" ./docker -f ./docker/pnppowershell.dockerFile --tag ${{ secrets.DOCKER_USERNAME }}/powershell:$VERSION-nanoserver-ltsc2022; - name: Push the image run: | - VERSION=$(cat ./version.txt)-nightly + $VERSION=$(cat ./version.txt)-nightly docker login -u ${{ secrets.DOCKER_USERNAME }} -p '${{ secrets.DOCKER_PASSWORD }}' docker push ${{ secrets.DOCKER_USERNAME }}/powershell:$VERSION-nanoserver-ltsc2022 publish-docker-windows-2019: @@ -33,11 +33,11 @@ jobs: - uses: actions/checkout@v2 - name: Build an image run: | - VERSION=$(cat ./version.txt)-nightly + $VERSION=$(cat ./version.txt)-nightly docker build --build-arg "PNP_MODULE_VERSION=$VERSION" --build-arg "BASE_IMAGE_SUFFIX=nanoserver-1809" --build-arg "INSTALL_USER=ContainerAdministrator" --build-arg "SKIP_PUBLISHER_CHECK=True" ./docker -f ./docker/pnppowershell.dockerFile --tag ${{ secrets.DOCKER_USERNAME }}/powershell:$VERSION-nanoserver-1809; - name: Push the image run: | - VERSION=$(cat ./version.txt)-nightly + $VERSION=$(cat ./version.txt)-nightly docker login -u ${{ secrets.DOCKER_USERNAME }} -p '${{ secrets.DOCKER_PASSWORD }}' docker push ${{ secrets.DOCKER_USERNAME }}/powershell:$VERSION-nanoserver-1809 publish-docker-linux: From a78076b9088ecc29afeaa28cc4a12d958bb43cef Mon Sep 17 00:00:00 2001 From: Aleks Date: Thu, 12 May 2022 16:34:15 +0200 Subject: [PATCH 63/70] fixing more PS syntax in pipeline --- .github/workflows/nightlyrelease.yml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/nightlyrelease.yml b/.github/workflows/nightlyrelease.yml index 3828ac238..94140abee 100644 --- a/.github/workflows/nightlyrelease.yml +++ b/.github/workflows/nightlyrelease.yml @@ -19,13 +19,13 @@ jobs: - uses: actions/checkout@v2 - name: Build an image run: | - $VERSION=$(cat ./version.txt)-nightly - docker build --build-arg "PNP_MODULE_VERSION=$VERSION" --build-arg "BASE_IMAGE_SUFFIX=nanoserver-ltsc2022" --build-arg "INSTALL_USER=ContainerAdministrator" --build-arg "SKIP_PUBLISHER_CHECK=True" ./docker -f ./docker/pnppowershell.dockerFile --tag ${{ secrets.DOCKER_USERNAME }}/powershell:$VERSION-nanoserver-ltsc2022; + $VERSION="$(cat ./version.txt)-nightly" + docker build --build-arg "PNP_MODULE_VERSION=$VERSION" --build-arg "BASE_IMAGE_SUFFIX=nanoserver-ltsc2022" --build-arg "INSTALL_USER=ContainerAdministrator" --build-arg "SKIP_PUBLISHER_CHECK=True" ./docker -f ./docker/pnppowershell.dockerFile --tag "${{ secrets.DOCKER_USERNAME }}/powershell:$VERSION-nanoserver-ltsc2022"; - name: Push the image run: | - $VERSION=$(cat ./version.txt)-nightly + $VERSION="$(cat ./version.txt)-nightly" docker login -u ${{ secrets.DOCKER_USERNAME }} -p '${{ secrets.DOCKER_PASSWORD }}' - docker push ${{ secrets.DOCKER_USERNAME }}/powershell:$VERSION-nanoserver-ltsc2022 + docker push "${{ secrets.DOCKER_USERNAME }}/powershell:$VERSION-nanoserver-ltsc2022" publish-docker-windows-2019: runs-on: windows-2019 needs: [ build ] @@ -33,13 +33,13 @@ jobs: - uses: actions/checkout@v2 - name: Build an image run: | - $VERSION=$(cat ./version.txt)-nightly - docker build --build-arg "PNP_MODULE_VERSION=$VERSION" --build-arg "BASE_IMAGE_SUFFIX=nanoserver-1809" --build-arg "INSTALL_USER=ContainerAdministrator" --build-arg "SKIP_PUBLISHER_CHECK=True" ./docker -f ./docker/pnppowershell.dockerFile --tag ${{ secrets.DOCKER_USERNAME }}/powershell:$VERSION-nanoserver-1809; + $VERSION="$(cat ./version.txt)-nightly" + docker build --build-arg "PNP_MODULE_VERSION=$VERSION" --build-arg "BASE_IMAGE_SUFFIX=nanoserver-1809" --build-arg "INSTALL_USER=ContainerAdministrator" --build-arg "SKIP_PUBLISHER_CHECK=True" ./docker -f ./docker/pnppowershell.dockerFile --tag "${{ secrets.DOCKER_USERNAME }}/powershell:$VERSION-nanoserver-1809"; - name: Push the image run: | - $VERSION=$(cat ./version.txt)-nightly + $VERSION="$(cat ./version.txt)-nightly" docker login -u ${{ secrets.DOCKER_USERNAME }} -p '${{ secrets.DOCKER_PASSWORD }}' - docker push ${{ secrets.DOCKER_USERNAME }}/powershell:$VERSION-nanoserver-1809 + docker push "${{ secrets.DOCKER_USERNAME }}/powershell:$VERSION-nanoserver-1809" publish-docker-linux: runs-on: ubuntu-latest needs: [ build ] From cb7c5b18afd6346d992b1ef431e401e08bbf531e Mon Sep 17 00:00:00 2001 From: Aleks Date: Thu, 12 May 2022 16:41:08 +0200 Subject: [PATCH 64/70] returning back the module publishing steps --- .github/workflows/nightlyrelease.yml | 31 ++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/.github/workflows/nightlyrelease.yml b/.github/workflows/nightlyrelease.yml index 94140abee..f647794d7 100644 --- a/.github/workflows/nightlyrelease.yml +++ b/.github/workflows/nightlyrelease.yml @@ -10,8 +10,35 @@ jobs: runs-on: windows-latest steps: - - shell: pwsh - run: Write-Host "hi" + - name: Setup .NET Core + uses: actions/setup-dotnet@v1 + with: + dotnet-version: | + 3.1.301 + 5.x + - uses: actions/checkout@v2 + with: + ref: dev + token: ${{ secrets.PAT }} + - name: Build and Publish Module + env: + POWERSHELLGALLERY_API_KEY: ${{ secrets.POWERSHELLGALLERY_API_KEY }} + shell: pwsh + run: | + ./build/Build-Nightly.ps1 + - name: Set variables + shell: pwsh + run: | + $version = Get-Content version.txt -raw + "BUILDVERSION=$version" | Out-File $env:GITHUB_ENV -Encoding utf8 -Append + - name: Add & Commit + uses: EndBug/add-and-commit@v6 + with: + message: 'Nightly publish to PowerShell Gallery' + tag: '${{env.BUILDVERSION}}-nightly --force' + push: true + branch: dev + token: ${{ secrets.PAT }} publish-docker-windows-2022: runs-on: windows-2022 needs: [ build ] From bd4a0c7c2b27e7d35b15fd2787346054cf9a9e81 Mon Sep 17 00:00:00 2001 From: Aleksandr SaPozhkov Date: Thu, 12 May 2022 21:31:29 +0200 Subject: [PATCH 65/70] installing module for all the users * outputting module list after installing * installing module for all the users * installing for all users in Linux --- docker/pnppowershell.dockerFile | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/docker/pnppowershell.dockerFile b/docker/pnppowershell.dockerFile index 28fe6302b..e98fcbb0f 100644 --- a/docker/pnppowershell.dockerFile +++ b/docker/pnppowershell.dockerFile @@ -9,7 +9,8 @@ ARG PNP_MODULE_VERSION ARG SKIP_PUBLISHER_CHECK=TRUE RUN if ( $env:SKIP_PUBLISHER_CHECK -eq $true ) { \ Write-Host "SKIP_PUBLISHER_CHECK"; \ - Install-Module -Name PnP.PowerShell -RequiredVersion $env:PNP_MODULE_VERSION -Force -AllowPrerelease -SkipPublisherCheck; \ + Install-Module -Name PnP.PowerShell -RequiredVersion $env:PNP_MODULE_VERSION -Force -AllowPrerelease -Scope AllUsers -SkipPublisherCheck; \ } else { \ - Install-Module -Name PnP.PowerShell -RequiredVersion $env:PNP_MODULE_VERSION -Force -AllowPrerelease; \ + Install-Module -Name PnP.PowerShell -RequiredVersion $env:PNP_MODULE_VERSION -Force -AllowPrerelease -Scope AllUsers; \ } + \ No newline at end of file From 73967df21c298e1f141a8db5eed800d4ad0d6863 Mon Sep 17 00:00:00 2001 From: Aleks Date: Fri, 13 May 2022 00:22:45 +0200 Subject: [PATCH 66/70] removing arm image from docu --- docker/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/README.md b/docker/README.md index a675a6db8..5affcb5f4 100644 --- a/docker/README.md +++ b/docker/README.md @@ -17,7 +17,7 @@ $securedPassword = ConvertTo-SecureString $DOCKER_PASSWORD -AsPlainText -Force ```powershell $securedPassword = ConvertTo-SecureString $DOCKER_PASSWORD -AsPlainText -Force -./docker/Publish-UnpublishedImage.ps1 PnP.PowerShell $DOCKER_USERNAME powershell $securedPassword $false "root" "alpine-3.14,arm32v7-ubuntu-bionic" +./docker/Publish-UnpublishedImage.ps1 PnP.PowerShell $DOCKER_USERNAME powershell $securedPassword $false "root" "alpine-3.14" ``` # Publish with prereleases manually From f3aa083f1d08ac287975a0b35a826e2a0a18157b Mon Sep 17 00:00:00 2001 From: Aleks Date: Fri, 13 May 2022 00:23:54 +0200 Subject: [PATCH 67/70] more user documentation --- docker/README.md | 34 +++++++++++++++++--- docker/hub.docker.md | 75 ++++++++++++++++++++++++++++++++++++++++++++ pages/index.md | 12 +++++++ 3 files changed, 116 insertions(+), 5 deletions(-) create mode 100644 docker/hub.docker.md diff --git a/docker/README.md b/docker/README.md index 5affcb5f4..32dd74e1f 100644 --- a/docker/README.md +++ b/docker/README.md @@ -20,7 +20,31 @@ $securedPassword = ConvertTo-SecureString $DOCKER_PASSWORD -AsPlainText -Force ./docker/Publish-UnpublishedImage.ps1 PnP.PowerShell $DOCKER_USERNAME powershell $securedPassword $false "root" "alpine-3.14" ``` -# Publish with prereleases manually +# Publish with prereleases manually in Windows + +1. Set "DOCKER_USERNAME" and "DOCKER_PASSWORD" variables + +2. Run + +```PowerShell +$VERSION="$(cat ./version.txt)-nightly" +docker build --build-arg "PNP_MODULE_VERSION=$VERSION" --build-arg "BASE_IMAGE_SUFFIX=nanoserver-ltsc2022" --build-arg "INSTALL_USER=ContainerAdministrator" --build-arg "SKIP_PUBLISHER_CHECK=True" ./docker -f ./docker/pnppowershell.dockerFile --tag "$DOCKER_USERNAME/powershell:$VERSION-nanoserver-ltsc2022"; +$VERSION="$(cat ./version.txt)-nightly" +docker login -u $DOCKER_USERNAME -p "$DOCKER_PASSWORD" +docker push "$DOCKER_USERNAME/powershell:$VERSION-nanoserver-ltsc2022" +``` + +or + +```PowerShell +$VERSION="$(cat ./version.txt)-nightly" +docker build --build-arg "PNP_MODULE_VERSION=$VERSION" --build-arg "BASE_IMAGE_SUFFIX=nanoserver-1809" --build-arg "INSTALL_USER=ContainerAdministrator" --build-arg "SKIP_PUBLISHER_CHECK=True" ./docker -f ./docker/pnppowershell.dockerFile --tag "$DOCKER_USERNAME/powershell:$VERSION-nanoserver-1809"; +$VERSION="$(cat ./version.txt)-nightly" +docker login -u $DOCKER_USERNAME -p "$DOCKER_PASSWORD" +docker push "$DOCKER_USERNAME/powershell:$VERSION-nanoserver-1809" +``` + +# Publish with prereleases manually in Linux 1. Set "DOCKER_USERNAME" and "DOCKER_PASSWORD" variables @@ -28,10 +52,10 @@ $securedPassword = ConvertTo-SecureString $DOCKER_PASSWORD -AsPlainText -Force ```bash VERSION=$(cat ./version.txt)-nightly -docker build --build-arg "PNP_MODULE_VERSION=$VERSION" ./docker -f ./docker/pnppowershell-prerelease.dockerFile --tag $DOCKER_USERNAME/powershell:$VERSION -docker image tag $DOCKER_USERNAME/powershell:$VERSION $DOCKER_USERNAME/powershell:nightly -docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD -docker push $DOCKER_USERNAME/powershell:$VERSION +docker build --build-arg "PNP_MODULE_VERSION=$VERSION" --build-arg "BASE_IMAGE_SUFFIX=alpine-3.14" --build-arg "INSTALL_USER=root" --build-arg "SKIP_PUBLISHER_CHECK=False" ./docker -f ./docker/pnppowershell.dockerFile --tag $DOCKER_USERNAME/powershell:$VERSION-alpine-3.14; +docker image tag $DOCKER_USERNAME/powershell:$VERSION-alpine-3.14 $DOCKER_USERNAME/powershell:nightly +docker login -u $DOCKER_USERNAME -p "$DOCKER_PASSWORD" +docker push $DOCKER_USERNAME/powershell:$VERSION-alpine-3.14 docker push $DOCKER_USERNAME/powershell:nightly ``` diff --git a/docker/hub.docker.md b/docker/hub.docker.md new file mode 100644 index 000000000..9344d00f9 --- /dev/null +++ b/docker/hub.docker.md @@ -0,0 +1,75 @@ +# PnP.Powershell + +## Featured tags + +### Latest + +* latest: The latest stable image + + * alpine-3.14 + * `docker pull pnp/powershell` or `docker pull pnp/powershell:latest` + +### Nightly + +* nightly: The latest night image + + * alpine-3.14 + * `docker pull pnp/powershell:nightly` + +## About this image + +**PnP PowerShell** is a .NET Core 3.1 / .NET Framework 4.6.1 based PowerShell Module providing over 600 cmdlets that work with Microsoft 365 environments such as SharePoint Online, Microsoft Teams, Microsoft Project, Security & Compliance, Azure Active Directory, and more. + +## Usage examples + +### Windows-container + +Starting an isolated container with PnP.PowerShell module installed: + +``` +docker run --rm -it asapozhkov/powershell:1.10.0-nanoserver-1809 +``` + +Starting a PnP.PowerShell container with the current directory mounted: + +```PowerShell +docker run --rm -it -v ${PWD}:c:/app -w c:/app asapozhkov/powershell:1.10.0-nanoserver-1809 +``` + +### Linux-container + +Starting an isolated container with PnP.PowerShell module installed: + +``` +docker run --rm -it asapozhkov/powershell +``` + +Starting a PnP.PowerShell container with the current directory mounted: + +```bash +docker run --rm -it -v ${PWD}:/home -w /home asapozhkov/powershell +``` + +## Tag explanation + +Tags names mean the following: + +`(-nightly)-` + +Currently supported platforms: + +* nanoserver-ltsc2022 +* nanoserver-1809 +* alpine-3.14 + +Tag name examples: + +* 1.8.0-nanoserver-ltsc2022 +* 1.9.0-nanoserver-ltsc2022 +* 1.10.0-nanoserver-1809 +* 1.10.0-alpine-3.14 +* 1.10.26-nightly-nanoserver-ltsc2022 + +## Feedback + +* To give feedback for PnP.PowerShell or for how the images are built, file an issue at [PnP/PowerShell](https://github.com/pnp/powershell/issues/new/choose) diff --git a/pages/index.md b/pages/index.md index f104e492b..8a28887d1 100644 --- a/pages/index.md +++ b/pages/index.md @@ -19,6 +19,18 @@ To install a nightly build of PnP PowerShell: Install-Module -Name PnP.PowerShell -AllowPrerelease -SkipPublisherCheck -AllowClobber ``` +To use PnP.PowerShell in a Windows container: + +``` +docker run -it pnp/powershell:1.10.0-nanoserver-1809 +``` + +To use PnP.PowerShell in a Linux container: + +``` +docker run -it pnp/powershell +``` + See the [articles](/powershell/articles) section for more information on authentication and configuration. All [cmdlets](/powershell/cmdlets/Add-PnPAlert.html) have been documented too. # I've found a bug, where do I need to log an issue or create a PR From a2145529dcef45015fe499c8d73c698ec1667b9c Mon Sep 17 00:00:00 2001 From: Aleks Date: Fri, 13 May 2022 00:24:11 +0200 Subject: [PATCH 68/70] removed unused space in the dockerfile --- docker/pnppowershell.dockerFile | 1 - 1 file changed, 1 deletion(-) diff --git a/docker/pnppowershell.dockerFile b/docker/pnppowershell.dockerFile index e98fcbb0f..1c3144156 100644 --- a/docker/pnppowershell.dockerFile +++ b/docker/pnppowershell.dockerFile @@ -13,4 +13,3 @@ RUN if ( $env:SKIP_PUBLISHER_CHECK -eq $true ) { \ } else { \ Install-Module -Name PnP.PowerShell -RequiredVersion $env:PNP_MODULE_VERSION -Force -AllowPrerelease -Scope AllUsers; \ } - \ No newline at end of file From cb4240db5d6bc350e24d08f31b257f2e1564f266 Mon Sep 17 00:00:00 2001 From: Aleks Date: Fri, 13 May 2022 00:28:14 +0200 Subject: [PATCH 69/70] reference to the PS gallery for versions --- docker/hub.docker.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docker/hub.docker.md b/docker/hub.docker.md index 9344d00f9..26f9e2ab7 100644 --- a/docker/hub.docker.md +++ b/docker/hub.docker.md @@ -70,6 +70,8 @@ Tag name examples: * 1.10.0-alpine-3.14 * 1.10.26-nightly-nanoserver-ltsc2022 +To find the version numbers please visit https://www.powershellgallery.com/packages/PnP.PowerShell + ## Feedback * To give feedback for PnP.PowerShell or for how the images are built, file an issue at [PnP/PowerShell](https://github.com/pnp/powershell/issues/new/choose) From d5e91cd8365d0ffb12ffd105f9c998ad039a9563 Mon Sep 17 00:00:00 2001 From: Aleks Date: Fri, 20 May 2022 08:53:08 +0200 Subject: [PATCH 70/70] correcting the pnp organization name in Docker --- docker/hub.docker.md | 4 ++-- pages/index.md | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docker/hub.docker.md b/docker/hub.docker.md index 26f9e2ab7..54a7117dc 100644 --- a/docker/hub.docker.md +++ b/docker/hub.docker.md @@ -7,14 +7,14 @@ * latest: The latest stable image * alpine-3.14 - * `docker pull pnp/powershell` or `docker pull pnp/powershell:latest` + * `docker pull m365pnp/powershell` or `docker pull m365pnp/powershell:latest` ### Nightly * nightly: The latest night image * alpine-3.14 - * `docker pull pnp/powershell:nightly` + * `docker pull m365pnp/powershell:nightly` ## About this image diff --git a/pages/index.md b/pages/index.md index 8a28887d1..6c21d105e 100644 --- a/pages/index.md +++ b/pages/index.md @@ -22,13 +22,13 @@ Install-Module -Name PnP.PowerShell -AllowPrerelease -SkipPublisherCheck -AllowC To use PnP.PowerShell in a Windows container: ``` -docker run -it pnp/powershell:1.10.0-nanoserver-1809 +docker run -it m365pnp/powershell:1.10.0-nanoserver-1809 ``` To use PnP.PowerShell in a Linux container: ``` -docker run -it pnp/powershell +docker run -it m365pnp/powershell ``` See the [articles](/powershell/articles) section for more information on authentication and configuration. All [cmdlets](/powershell/cmdlets/Add-PnPAlert.html) have been documented too.