Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .textlintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"/-\\w+\\b/g", // FIXME: PowerShell Cmdlets/function parameter names
"/\\b\\w+[./]\\w+\\b/g", // paths // FIXME: (Note: Does not work for \ in paths)
"about_CommonParameters",
"about_Execution_Policies",
"about_Preference_Variables",
"CIDR",
"Containers[\\s\\.\\-]ToolKit/gi",
Expand Down
32 changes: 32 additions & 0 deletions Containers-Toolkit.nuspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?xml version="1.0" encoding="utf-8"?>
<package>
<metadata>
<id>Containers-Toolkit</id>
<version>0.0.0</version>
<authors>Microsoft Corporation</authors>
<requireLicenseAcceptance>true</requireLicenseAcceptance>
<!-- <icon>icon.png</icon> -->
<projectUrl>https://github.com/microsoft/containers-toolkit.git</projectUrl>
<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.

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

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.

Note that the HostNetworkingService module is available only when the Hyper-V Windows feature is enabled.</description>
<releaseNotes>
</releaseNotes>
<copyright>(c) Microsoft Corporation. All rights reserved.</copyright>
<tags>Containerd Buildkit nerdctl CNI WindowsContainers ContainerTools</tags>
<dependencies>
</dependencies>
<repository type="git" url="https://github.com/microsoft/containers-toolkit.git" branch="main" />
<license type="file">LICENSE.txt</license>
<readme>README.md</readme>
</metadata>
<files>
<file src="LICENSE.txt" target="" />
<file src="README.md" target="" />
</files>
</package>
53 changes: 49 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
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.

Configurations done with these functions are default configurations that allow you to get started with interacting with the tools. Further configurations may be necessary.

You can find documentation for these functions here: [Containers-Toolkit Documentation](https://github.com/microsoft/containers-toolkit/tree/main/docs/command-reference.md)

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

### Install Containers-Toolkit module from PowerShell Gallery

> COMING SOON: We are currently working on publishing this module to PS Gallery to make it easier to import the module
```PowerShell
Install-Module -Name containers-toolkit
```

> [!TIP]
> To find the latest version of the module, use:
>
> ```PowerShell
> Find-Module -Name containers-toolkit -AllowPrerelease
> ```

### Download signed source files

> Coming soon
1. Download source files

```PowerShell
$Version = "<VERSION>"
Invoke-WebRequest -Uri "https://github.com/microsoft/containers-toolkit/releases/download/v$Version/containers-toolkit-v$Version.tar.gz" -OutFile "containers-toolkit.tar.gz"
```

1. Verify the signature

```PowerShell
$HASH_VALUE = "<HASH_VALUE>"
(Get-FileHash -Algorithm SHA256 containers-toolkit.tar.gz).Hash -eq $HASH_VALUE
```

1. Expand the tar file

```PowerShell
$ModulePath = "$env:USERPROFILE\Documents\WindowsPowerShell\Modules"
if (!(Test-Path -Path $ModulePath)) {
New-Item -ItemType Directory -Path $ModulePath | Out-Null
}
tar.exe -xvf containers-toolkit.tar.gz -C $ModulePath
Remove-Item -Path containers-toolkit.tar.gz -Force
```

1. Unblock the files

```PowerShell
Get-ChildItem -Path $ModulePath -Recurse | Unblock-File
```

### Downloading the source code from Containers-Toolkit repository

To use the module, fork/clone the repository to your local machine and [setup your development environment](./CONTRIBUTING.md#setup-development-environment)

## Usage

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

### Get the module details

```PowerShell
Expand Down Expand Up @@ -85,13 +130,13 @@ Get-Command -Module containers-toolkit
Get-Help Install-Containerd
```

2. List container tools (Containerd, BuildKit, and nerdctl) install status
1. List container tools (Containerd, BuildKit, and nerdctl) install status

```PowerShell
Show-ContainerTools
```

3. Installs Containerd version 1.7.7 at 'C:\Test\Path\containerd' and adds 'C:\Test\Path\containerd' in the environment path.
1. Installs Containerd version 1.7.7 at 'C:\Test\Path\containerd' and adds 'C:\Test\Path\containerd' in the environment path.

```powershell
Install-Containerd -Version "1.7.7" -InstallPath 'C:\Test\Path\Containerd'
Expand Down
111 changes: 111 additions & 0 deletions build/hacks/get-newversion.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
<#
.SYNOPSIS
Get the new version number for the release.

.DESCRIPTION
Given a release version, this script will recursively check for a valid version number
by checking the PowerShell Gallery.

.PARAMETER Version
The version number to check for. This should be a valid semantic version number.
Example: 1.2.3

.PARAMETER Prerelease
The pre-release tag to check for. This should be a valid semantic version pre-release tag.
Example: alpha2, beta0, rc0

.PARAMETER ReleaseType
The type of release to check for. This should be one of the following:
major, minor, patch

.PARAMETER MaxPrerelease
The maximum number of pre-release tags to check for. This is used to limit the number of
iterations when checking for a valid version number. Default is 20.
For example, if the current version is 1.2.3-alpha2 and the next version is 1.2.3-alpha3,
this will check for 20 pre-release tags: alpha3, alpha4, ..., alpha20.

When the maximum number of pre-release tags is reached, the script will stop checking and increment
the version number based on the release type.

When MaxPrerelease is set to 0 (or less), the script will not check for pre-release tags and will
increment the version number based on the release type.

.EXAMPLE
.\get-newversion.ps1 -Version 1.2.3 -Prerelease alpha2 -ReleaseType minor

This will check for the next version number based on the provided version, pre-release tag, and release type.
#>

[CmdletBinding()]
param (
[Parameter(Mandatory = $true)]
[version]$Version,

[Parameter(Mandatory = $false)]
[string]$Prerelease,

[Parameter(Mandatory = $true)]
[ValidateSet("major", "minor", "patch")]
[string]$ReleaseType,

[Parameter(Mandatory = $false)]
[int]$MaxPrerelease = "20"
)

$ErrorActionPreference = "Stop"

function Update-SemverTag($Semver, $ReleaseType) {
switch ($ReleaseType) {
"major" { return [version]::new($Semver.Major + 1, 0, 0) }
"minor" { return [version]::new($Semver.Major, $Semver.Minor + 1, 0) }
"patch" { return [version]::new($Semver.Major, $Semver.Minor, $Semver.Build + 1) }
}
}

function Get-PrereleaseValue($PrereleaseTag) {
$match = [regex]::Match($PrereleaseTag, "(.*?)(\d+)$")
return [int]$match.Groups[2].Value + 1
}

function Update-Prerelease($PrereleaseTag) {
$match = [regex]::Match("$PrereleaseTag", "(.*?)(\d+)$")
$prefix = [string]$match.Groups[1].Value
$number = [int]$match.Groups[2].Value
return "$prefix" + "$($number + 1)"
}

function Test-ModuleVersion($ModuleVersion) {
$PublishedVersions = Find-Module -AllowPrerelease `
-Name containers-toolkit `
-RequiredVersion "$ModuleVersion" `
-ErrorAction SilentlyContinue | Where-Object { $_.Version -eq $ModuleVersion }
return $PublishedVersions
}

while ($true) {
$ModuleVersion = "${Version}-${Prerelease}".TrimEnd("-")
Write-Host "Checking for module version: $ModuleVersion" -ForegroundColor Magenta

$PublishedVersions = Test-ModuleVersion $ModuleVersion
if (-not $PublishedVersions) {
Write-Host "Module version $ModuleVersion is not published." -ForegroundColor Magenta
return $ModuleVersion
}

# Find a pre-release tag that is not published
while ($Prerelease -and ($MaxPrerelease -gt 0) -and ($PublishedVersions.Version -match "$Prerelease")) {
$Prerelease = Update-Prerelease $Prerelease
$ModuleVersion = "${Version}-${Prerelease}"

Write-Host "Incrementing pre-release tag: $ModuleVersion" -ForegroundColor Magenta
$PublishedVersions = Test-ModuleVersion $ModuleVersion
if (-not $PublishedVersions) {
Write-Host "Module version $ModuleVersion is not published." -ForegroundColor Magenta
return $ModuleVersion
}

$MaxPrerelease -= 1
}

$Version = Update-SemverTag $Version $ReleaseType
}
36 changes: 17 additions & 19 deletions build/hacks/release-notes-template.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,38 +16,36 @@ _Ongoing issue that are still being worked on._

## Quick start guide

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

### Install from PowerShell Gallery

```PowerShell
Install-Module -Name Containers-Toolkit -RequiredVersion "__NEW_VERSTION__"
Install-Module -Name Containers-Toolkit -RequiredVersion "__MODULE_VERSION__" __ALLOW_PRERELEASE__
```

If the module is already installed, update the module:

```PowerShell
Update-Module -Name Containers-Toolkit -RequiredVersion "__NEW_VERSTION__"
Update-Module -Name Containers-Toolkit -RequiredVersion "__MODULE_VERSION__" __ALLOW_PRERELEASE__
```

### Download Source Files

1. Download source files
1. Open a new terminal
1. cd into the location of the downloaded files
Example: If downloaded to the downloads folder:

```PowerShell
cd "$env:USERPROFILE\Downloads\containers-toolkit"
```

1. Unblock the files
> **⚠️ Caution:**
> For security, we recommend using the source files named `containers-toolkit-__RELEASE_TAG__.tar.gz`, as these contain signed scripts.
> The default **Source.zip** and **Source.tar.gz** files generated by GitHub are not signed and should be avoided.

```PowerShell
Get-ChildItem -Path . -Recurse | Unblock-File"
```
See instructions in the [Installing and importing Containers-Toolkit module](../../README.md#download-source-files) section.

1. Import the module

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

## Visuals

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

_**Update the discussoin link**_

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

## Release Authors

Expand Down
Loading