Skip to content

Commit 74f2dd9

Browse files
committed
Update release pipeline
1 parent cb3edde commit 74f2dd9

14 files changed

+995
-130
lines changed

.textlintrc.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
"/-\\w+\\b/g", // FIXME: PowerShell Cmdlets/function parameter names
2121
"/\\b\\w+[./]\\w+\\b/g", // paths // FIXME: (Note: Does not work for \ in paths)
2222
"about_CommonParameters",
23+
"about_Execution_Policies",
2324
"about_Preference_Variables",
2425
"CIDR",
2526
"Containers[\\s\\.\\-]ToolKit/gi",

Containers-Toolkit.nuspec

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<package>
3+
<metadata>
4+
<id>Containers-Toolkit</id>
5+
<version>0.0.0</version>
6+
<authors>Microsoft Corporation</authors>
7+
<requireLicenseAcceptance>true</requireLicenseAcceptance>
8+
<!-- <icon>icon.png</icon> -->
9+
<projectUrl>https://github.com/microsoft/containers-toolkit.git</projectUrl>
10+
<description>The Containers-Toolkit module contains PowerShell functions for downloading, installing, and configuring Containerd, Buildkit, nerdctl, and Windows CNI plugins for container networks. It also allows you to get a list of the container tools and their installation statuses.
11+
12+
Configurations done with these functions are default configurations that allow you to get started with interacting with the tools. Further configurations may be necessary.
13+
You can find documentation for these functions here: [Containers-Toolkit Documentation](https://github.com/microsoft/containers-toolkit/tree/main/docs/command-reference.md)
14+
15+
This module requires the HNS module to execute the "Initialize-NatNetwork" command. The Host Networking Service (HNS) and the Host Compute Service (HCS) work together to create containers and attach endpoints to a network. The HNS module is necessary because the HostNetworkingService module does not include the "New-HNSNetwork" cmdlet.
16+
17+
Note that the HostNetworkingService module is available only when the Hyper-V Windows feature is enabled.</description>
18+
<releaseNotes>
19+
</releaseNotes>
20+
<copyright>(c) Microsoft Corporation. All rights reserved.</copyright>
21+
<tags>Containerd Buildkit nerdctl CNI WindowsContainers ContainerTools</tags>
22+
<dependencies>
23+
</dependencies>
24+
<repository type="git" url="https://github.com/microsoft/containers-toolkit.git" branch="main" />
25+
<license type="file">LICENSE.txt</license>
26+
<readme>README.md</readme>
27+
</metadata>
28+
<files>
29+
<file src="LICENSE.txt" target="" />
30+
<file src="README.md" target="" />
31+
</files>
32+
</package>

README.md

Lines changed: 49 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
Containers-Toolkit is a Windows PowerShell module for downloading, installing, and configuring Containerd, Buildkit, nerdctl, and Windows CNI plugins for container networks. It also allows you to get a list of the container tools and their installation statuses.
2727

2828
Configurations done with these functions are default configurations that allow you to get started with interacting with the tools. Further configurations may be necessary.
29+
2930
You can find documentation for these functions here: [Containers-Toolkit Documentation](https://github.com/microsoft/containers-toolkit/tree/main/docs/command-reference.md)
3031

3132
## Prerequisites
@@ -44,18 +45,62 @@ You can find documentation for these functions here: [Containers-Toolkit Documen
4445

4546
### Install Containers-Toolkit module from PowerShell Gallery
4647

47-
> COMING SOON: We are currently working on publishing this module to PS Gallery to make it easier to import the module
48+
```PowerShell
49+
Install-Module -Name containers-toolkit
50+
```
51+
52+
> [!TIP]
53+
> To find the latest version of the module, use:
54+
>
55+
> ```PowerShell
56+
> Find-Module -Name containers-toolkit -AllowPrerelease
57+
> ```
4858
4959
### Download signed source files
5060
51-
> Coming soon
61+
1. Download source files
62+
63+
```PowerShell
64+
$Version = "<VERSION>"
65+
Invoke-WebRequest -Uri "https://github.com/microsoft/containers-toolkit/releases/download/v$Version/containers-toolkit-v$Version.tar.gz" -OutFile "containers-toolkit.tar.gz"
66+
```
67+
68+
1. Verify the signature
69+
70+
```PowerShell
71+
$HASH_VALUE = "<HASH_VALUE>"
72+
(Get-FileHash -Algorithm SHA256 containers-toolkit.tar.gz).Hash -eq $HASH_VALUE
73+
```
74+
75+
1. Expand the tar file
76+
77+
```PowerShell
78+
$ModulePath = "$env:USERPROFILE\Documents\WindowsPowerShell\Modules"
79+
if (!(Test-Path -Path $ModulePath)) {
80+
New-Item -ItemType Directory -Path $ModulePath | Out-Null
81+
}
82+
tar.exe -xvf containers-toolkit.tar.gz -C $ModulePath
83+
Remove-Item -Path containers-toolkit.tar.gz -Force
84+
```
85+
86+
1. Unblock the files
87+
88+
```PowerShell
89+
Get-ChildItem -Path $ModulePath -Recurse | Unblock-File
90+
```
5291
5392
### Downloading the source code from Containers-Toolkit repository
5493
5594
To use the module, fork/clone the repository to your local machine and [setup your development environment](./CONTRIBUTING.md#setup-development-environment)
5695
5796
## Usage
5897
98+
> [!IMPORTANT]
99+
> All the Containers-Toolkit files, including \*.ps1, \*.psd1, \*.psm1, and \*.ps1xml, have been
100+
> code signed. This means that you will be able to run the module in a PowerShell session
101+
> where the execution policy is set to `AllSigned` or `RemoteSigned`.
102+
> To learn more about PowerShell execution policies, see [about_Execution_Policies](https://go.microsoft.com/fwlink/?LinkID=135170).
103+
59104
### Get the module details
60105
61106
```PowerShell
@@ -85,13 +130,13 @@ Get-Command -Module containers-toolkit
85130
Get-Help Install-Containerd
86131
```
87132
88-
2. List container tools (Containerd, BuildKit, and nerdctl) install status
133+
1. List container tools (Containerd, BuildKit, and nerdctl) install status
89134
90135
```PowerShell
91136
Show-ContainerTools
92137
```
93138
94-
3. Installs Containerd version 1.7.7 at 'C:\Test\Path\containerd' and adds 'C:\Test\Path\containerd' in the environment path.
139+
1. Installs Containerd version 1.7.7 at 'C:\Test\Path\containerd' and adds 'C:\Test\Path\containerd' in the environment path.
95140
96141
```powershell
97142
Install-Containerd -Version "1.7.7" -InstallPath 'C:\Test\Path\Containerd'

build/hacks/get-newversion.ps1

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
<#
2+
.SYNOPSIS
3+
Get the new version number for the release.
4+
5+
.DESCRIPTION
6+
Given a release version, this script will recursively check for a valid version number
7+
by checking the PowerShell Gallery.
8+
9+
.PARAMETER Version
10+
The version number to check for. This should be a valid semantic version number.
11+
Example: 1.2.3
12+
13+
.PARAMETER Prerelease
14+
The pre-release tag to check for. This should be a valid semantic version pre-release tag.
15+
Example: alpha2, beta0, rc0
16+
17+
.PARAMETER ReleaseType
18+
The type of release to check for. This should be one of the following:
19+
major, minor, patch
20+
21+
.PARAMETER MaxPrerelease
22+
The maximum number of pre-release tags to check for. This is used to limit the number of
23+
iterations when checking for a valid version number. Default is 20.
24+
For example, if the current version is 1.2.3-alpha2 and the next version is 1.2.3-alpha3,
25+
this will check for 20 pre-release tags: alpha3, alpha4, ..., alpha20.
26+
27+
When the maximum number of pre-release tags is reached, the script will stop checking and increment
28+
the version number based on the release type.
29+
30+
When MaxPrerelease is set to 0 (or less), the script will not check for pre-release tags and will
31+
increment the version number based on the release type.
32+
33+
.EXAMPLE
34+
.\get-newversion.ps1 -Version 1.2.3 -Prerelease alpha2 -ReleaseType minor
35+
36+
This will check for the next version number based on the provided version, pre-release tag, and release type.
37+
#>
38+
39+
[CmdletBinding()]
40+
param (
41+
[Parameter(Mandatory = $true)]
42+
[version]$Version,
43+
44+
[Parameter(Mandatory = $false)]
45+
[string]$Prerelease,
46+
47+
[Parameter(Mandatory = $true)]
48+
[ValidateSet("major", "minor", "patch")]
49+
[string]$ReleaseType,
50+
51+
[Parameter(Mandatory = $false)]
52+
[int]$MaxPrerelease = "20"
53+
)
54+
55+
$ErrorActionPreference = "Stop"
56+
57+
function Update-SemverTag($Semver, $ReleaseType) {
58+
switch ($ReleaseType) {
59+
"major" { return [version]::new($Semver.Major + 1, 0, 0) }
60+
"minor" { return [version]::new($Semver.Major, $Semver.Minor + 1, 0) }
61+
"patch" { return [version]::new($Semver.Major, $Semver.Minor, $Semver.Build + 1) }
62+
}
63+
}
64+
65+
function Get-PrereleaseValue($PrereleaseTag) {
66+
$match = [regex]::Match($PrereleaseTag, "(.*?)(\d+)$")
67+
return [int]$match.Groups[2].Value + 1
68+
}
69+
70+
function Update-Prerelease($PrereleaseTag) {
71+
$match = [regex]::Match("$PrereleaseTag", "(.*?)(\d+)$")
72+
$prefix = [string]$match.Groups[1].Value
73+
$number = [int]$match.Groups[2].Value
74+
return "$prefix" + "$($number + 1)"
75+
}
76+
77+
function Test-ModuleVersion($ModuleVersion) {
78+
$PublishedVersions = Find-Module -AllowPrerelease `
79+
-Name containers-toolkit `
80+
-RequiredVersion "$ModuleVersion" `
81+
-ErrorAction SilentlyContinue | Where-Object { $_.Version -eq $ModuleVersion }
82+
return $PublishedVersions
83+
}
84+
85+
while ($true) {
86+
$ModuleVersion = "${Version}-${Prerelease}".TrimEnd("-")
87+
Write-Host "Checking for module version: $ModuleVersion" -ForegroundColor Magenta
88+
89+
$PublishedVersions = Test-ModuleVersion $ModuleVersion
90+
if (-not $PublishedVersions) {
91+
Write-Host "Module version $ModuleVersion is not published." -ForegroundColor Magenta
92+
return $ModuleVersion
93+
}
94+
95+
# Find a pre-release tag that is not published
96+
while ($Prerelease -and ($MaxPrerelease -gt 0) -and ($PublishedVersions.Version -match "$Prerelease")) {
97+
$Prerelease = Update-Prerelease $Prerelease
98+
$ModuleVersion = "${Version}-${Prerelease}"
99+
100+
Write-Host "Incrementing pre-release tag: $ModuleVersion" -ForegroundColor Magenta
101+
$PublishedVersions = Test-ModuleVersion $ModuleVersion
102+
if (-not $PublishedVersions) {
103+
Write-Host "Module version $ModuleVersion is not published." -ForegroundColor Magenta
104+
return $ModuleVersion
105+
}
106+
107+
$MaxPrerelease -= 1
108+
}
109+
110+
$Version = Update-SemverTag $Version $ReleaseType
111+
}

build/hacks/release-notes-template.md

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -16,38 +16,36 @@ _Ongoing issue that are still being worked on._
1616

1717
## Quick start guide
1818

19+
> [!IMPORTANT]
20+
> All the Containers-Toolkit files, including `\*.ps1`, `\*.psd1`, `\*.psm1`, and `\*.ps1xml`, have been
21+
> code signed. This means that you will be able to run the module in a PowerShell session
22+
> where the execution policy is set to `AllSigned` or `RemoteSigned`.
23+
> To learn more about PowerShell execution policies, see [about_Execution_Policies](https://go.microsoft.com/fwlink/?LinkID=135170).
24+
1925
### Install from PowerShell Gallery
2026

2127
```PowerShell
22-
Install-Module -Name Containers-Toolkit -RequiredVersion "__NEW_VERSTION__"
28+
Install-Module -Name Containers-Toolkit -RequiredVersion "__MODULE_VERSION__" __ALLOW_PRERELEASE__
2329
```
2430

2531
If the module is already installed, update the module:
2632

2733
```PowerShell
28-
Update-Module -Name Containers-Toolkit -RequiredVersion "__NEW_VERSTION__"
34+
Update-Module -Name Containers-Toolkit -RequiredVersion "__MODULE_VERSION__" __ALLOW_PRERELEASE__
2935
```
3036

3137
### Download Source Files
3238

33-
1. Download source files
34-
1. Open a new terminal
35-
1. cd into the location of the downloaded files
36-
Example: If downloaded to the downloads folder:
37-
38-
```PowerShell
39-
cd "$env:USERPROFILE\Downloads\containers-toolkit"
40-
```
41-
42-
1. Unblock the files
39+
> **⚠️ Caution:**
40+
> For security, we recommend using the source files named `containers-toolkit-__RELEASE_TAG__.tar.gz`, as these contain signed scripts.
41+
> The default **Source.zip** and **Source.tar.gz** files generated by GitHub are not signed and should be avoided.
4342
44-
```PowerShell
45-
Get-ChildItem -Path . -Recurse | Unblock-File"
46-
```
43+
See instructions in the [Installing and importing Containers-Toolkit module](../../README.md#download-source-files) section.
4744

48-
1. Import the module
49-
50-
See instructions in the [Installing and importting Containers-Toolkit module](../../README.md#download-source-files) section
45+
```PowerShell
46+
Invoke-WebRequest -Uri "https://github.com/microsoft/containers-toolkit/releases/download/__RELEASE_TAG__/containers-toolkit-__RELEASE_TAG__.tar.gz" -OutFile "containers-toolkit.tar.gz"
47+
tar -xvf containers-toolkit.tar.gz -C $ENV:USERPROFILE\Documents\WindowsPowerShell\Modules
48+
```
5149

5250
## Visuals
5351

@@ -57,7 +55,7 @@ _Screenshots, Side-by-side comparisons, 30-second videos_
5755

5856
_**Update the discussoin link**_
5957

60-
For any questions or feedback on this release, see the discussion: [Containers.ToolKit v__NEW_VERSTION__](<LINK-TO-VERSION-DISCUSSION>)
58+
For any questions or feedback on this release, see the discussion: [Containers.ToolKit **__RELEASE_TAG__**](<LINK-TO-VERSION-DISCUSSION>)
6159

6260
## Release Authors
6361

0 commit comments

Comments
 (0)