|
| 1 | +## Creating a Containers-Toolkit release |
| 2 | + |
| 3 | +> [!IMPORTANT] |
| 4 | +> **It is recommended to test with pre-release versions before creating a final release.** |
| 5 | +> The PowerShell Gallery does not support permanent deletion of packages. If the module version already exists, you will need to increment the version number |
| 6 | +
|
| 7 | +### Create a GitHub tag |
| 8 | + |
| 9 | +1. Get the new module version: |
| 10 | + |
| 11 | + To choose the new version, you can use the [Semantic Versioning](https://semver.org/) scheme. The version number is in the format `X.Y.Z`, where: |
| 12 | + - `X` is the *major* version number. Indicates significant **changes that may break backward compatibility** with previous versions (e.g., 1.0.0 to 2.0.0). |
| 13 | + - `Y` is the *minor* version number. Represents **new features/ functionality** that are backward compatible (e.g., 1.0.0 to 1.1.0). |
| 14 | + - `Z` is the *patch* version number. Refers to **bug fixes or minor changes** that do not affect functionality or compatibility (e.g., 1.0.0 to 1.0.1). |
| 15 | + |
| 16 | + ```PowerShell |
| 17 | + $NEW_VERSION = "<new version>" # e.g. 1.0.0 |
| 18 | + ``` |
| 19 | +
|
| 20 | + If this is pre-release, concatenate the pre-release version to the module version. The pre-release version can be `-rc0`, `-beta0`, `-alpha0`, etc. |
| 21 | +
|
| 22 | + ```PowerShell |
| 23 | + $PRERELEASE_TAG = "<pre-release version>" # e.g. -rc0, -beta0, -alpha0 |
| 24 | + ``` |
| 25 | +
|
| 26 | + Get the release version and tag: |
| 27 | +
|
| 28 | + ```PowerShell |
| 29 | + $RELEASE_VERSION = "${NEW_VERSION}-${PRERELEASE_TAG}".TrimEnd("-") |
| 30 | + $RELEASE_TAG = "v${RELEASE_VERSION}" |
| 31 | + ``` |
| 32 | +
|
| 33 | + > [!IMPORTANT] |
| 34 | + > Ensure that the new version number is not already used in the [PowerShell Gallery][ctk-psg]. |
| 35 | + > If the version already exists, you will need to increment the version number. |
| 36 | + > The PowerShell Gallery does not support permanent deletion of packages. |
| 37 | + > Use the `Find-Module` command to check if the version already exists. |
| 38 | + > |
| 39 | + > ```PowerShell |
| 40 | + > Find-Module -Name containers-toolkit -AllowPrerelease -RequiredVersion "$RELEASE_VERSION" | Where-Object { $_.Version -eq $RELEASE_VERSION } |
| 41 | + > ``` |
| 42 | + > Alternatively, you can use the [build/hacks/get-newversion.ps1](../../hacks/get-newversion.ps1) script to get the new version number. |
| 43 | + > |
| 44 | + > ```PowerShell |
| 45 | + > $RELEASE_TAG = build/hacks/get-newversion.ps1 -Version $NEW_VERSION -Prerelease $PRERELEASE_TAG -ReleaseType "major" |
| 46 | + > ``` |
| 47 | +
|
| 48 | +
|
| 49 | +1. Create a new branch from the main branch. |
| 50 | +
|
| 51 | + ```bash |
| 52 | + $BRANCH_NAME = "release/$RELEASE_TAG" |
| 53 | + git checkout -b "$BRANCH_NAME" |
| 54 | + ``` |
| 55 | +
|
| 56 | +1. Cherry-pick the changes to a new branch from the main branch. The new branch name should be `release/X.Y.Z`, where `X.Y.Z` is the new version number. |
| 57 | +
|
| 58 | + - Identify the commit hashes you want to include. You can find them using: |
| 59 | +
|
| 60 | + ```bash |
| 61 | + git log |
| 62 | + ``` |
| 63 | +
|
| 64 | + - Cherry-pick the commits to the new branch. You can cherry-pick multiple commits at once by specifying their hashes separated by spaces. |
| 65 | +
|
| 66 | + ```bash |
| 67 | + git cherry-pick <commit_hash_1> <commit_hash_2> <commit_hash_3> |
| 68 | + ``` |
| 69 | +
|
| 70 | + - Resolve Any Conflicts (If Necessary) |
| 71 | +
|
| 72 | + If there are any conflicts during the cherry-pick process, Git will pause and allow you to resolve them. After resolving the conflicts, you can continue the cherry-pick process with: |
| 73 | +
|
| 74 | + ```bash |
| 75 | + git status # Identify conflicts |
| 76 | + # Resolve conflicts in your preferred editor |
| 77 | + git add . |
| 78 | + git cherry-pick --continue |
| 79 | + ``` |
| 80 | +
|
| 81 | +1. Update the module version in the README.md file |
| 82 | +
|
| 83 | + *NOTE: Only update the version number in the README.md file for the latest release and not for pre-releases._* |
| 84 | +
|
| 85 | +1. Create a tag and a release in GitHub. |
| 86 | +
|
| 87 | + ```bash |
| 88 | + git tag --sign "$RELEASE_TAG" -m "Release $RELEASE_TAG" |
| 89 | + git push upstream "$BRANCH_NAME" --tags |
| 90 | + ``` |
| 91 | +
|
| 92 | + > [!TIP] |
| 93 | + > To delete an existing tag, use the following command: |
| 94 | + > |
| 95 | + > ```bash |
| 96 | + > git tag --delete "$RELEASE_TAG" |
| 97 | + > git push upstream :refs/tags/"$RELEASE_TAG" |
| 98 | + > ``` |
| 99 | +
|
| 100 | +<!-- > [!NOTE] |
| 101 | +> <https://github.com/orgs/community/discussions/48462> |
| 102 | +> As of February 2025, GitHub does not have the option to only create a tag without creating a release. We therefore delete the release after creating the tag. |
| 103 | +
|
| 104 | +```bash |
| 105 | +gh release delete -y $RELEASE_TAG |
| 106 | +``` --> |
| 107 | +
|
| 108 | +### Create a release using the ADO release pipeline |
| 109 | +
|
| 110 | +Releases are created using the Containers-Toolkit ADO release pipeline. The release pipeline is triggered by the creation of a new release branch in GitHub. However, you can also create a [release manually](#manual-release). |
| 111 | +
|
| 112 | +#### Manual release |
| 113 | +
|
| 114 | +1. In the artifact section, select the `Default Branch` to use for the release. |
| 115 | +
|
| 116 | + *The branch created in step 2 should be selected.* |
| 117 | +
|
| 118 | + The release pipeline uses the branch name to determine the version number. The version number is derived from the branch name by removing the `release/` prefix. |
| 119 | +
|
| 120 | + For example: |
| 121 | +
|
| 122 | + | Branch Name | Version Number | |
| 123 | + |----------------------|----------------| |
| 124 | + | `release/v1.0.0` | `v1.0.0` | |
| 125 | + | `release/v1.0.0-rc0` | `v1.0.0-rc0` | |
| 126 | +
|
| 127 | +1. Create a new release. |
| 128 | +
|
| 129 | + This publishes the module to the [PowerShell Gallery][ctk-psg] and creates a new release in GitHub. |
| 130 | +
|
| 131 | + 1. Verify the PowerShell Gallery release: |
| 132 | +
|
| 133 | + ```PowerShell |
| 134 | + Find-Module -Name containers-toolkit -AllVersions -AllowPrerelease |
| 135 | + ``` |
| 136 | +
|
| 137 | + > [!IMPORTANT] |
| 138 | + > If the module has any issues, unlist the version in the [PowerShell Gallery][ctk-psg]. |
| 139 | +
|
| 140 | + 1. Go to the created release in GitHub and do the following: |
| 141 | + 1. update the release notes. |
| 142 | + 2. Verify that all files have been uploaded correctly and the scripts are signed. There should be three files: |
| 143 | + - *containers-toolkit-<RELEASE_TAG>.tar.gz* |
| 144 | + - *containers-toolkit-<RELEASE_TAG>.zip* |
| 145 | + - *containers-toolkit-<RELEASE_TAG>.SHA256* |
| 146 | + 3. By default, the release is marked as a draft. To publish the release: |
| 147 | + - Click on the **Edit** button. |
| 148 | + - If it is a pre-release, check the **Set as a pre-releasee** checkbox. |
| 149 | + - Finally, click on the **Publish release** button. |
| 150 | +
|
| 151 | +[ctk-psg]: https://www.powershellgallery.com/packages/containers-toolkit |
0 commit comments