HOWTO: Use SemVer and Repackaging in Your CI/CD Pipelines
  • 07 Jan 2022
  • 4 Minutes to read
  • Dark
  • PDF

HOWTO: Use SemVer and Repackaging in Your CI/CD Pipelines

  • Dark
  • PDF

How to Use SemVer and Repackaging in Your CI/CD Pipelines

ProGet's repackaging feature helps you create stable packages from prerelease as part of your CI/CD pipeline. This is done by creating a new package from an existing package, using completely identical contents while changing the version number and tracking the change.

This is done with Semantic Versioning's prerelease labels. For example, a continuous integration (CI) server would create build 8 of a package as 1.0.0-ci.8. This would then be tested, approved, and eventually repackaged as a release candidate as 1.0.0-rc.8. After that package is tested, a stable version, 1.0.0, will be created for use in production applications.

This article will walk you through a common scenario of repackaging an in-house NuGet package. Although much of this process should be automated with a CI/CD tool like BuildMaster, we'll demonstrate the concepts manually.

Step 1: Create a -ci Package

A "-ci package" is created through continuous integration, and is the first stage of a package. You can create any package you like but for the purposes of this example, we'll create a NuGet package manually using the NuGet package explorer (NPE).

This step should be automated by your build/CI server.

Once we've opened the package explorer, we'll select create a new package, add in our content, and enter all applicable or appropriate details, metadata.

NuGet Package Explorer Create TkyConvert-ci

Note that the version has -ci.8 at the end. The - signifies the package is a "prerelease package", -ci means it's from a CI server, and -ci.8 means it's the 8th CI build. The 8 could just as easily be a timestamp, or whatever is easiest for your build server to generate.

To finish creating our package, we'll click on File > Export

Step 2: Upload/Push

Now that we have a prerelease package, we can upload it to our ProGet feed. This step would also typically be done by your CI server. But since we manually created the package, we will manually upload it.

This step should be automated by your build/CI server.

To upload your package, navigate to your feed and click on "Add a package". A popup will appear prompting to select how we’d like to add the package. For the purposes of this example, we’ll upload files using the browser, since this is the simplest way.

ProGet Popup TkyConvert Upload

Step 3: Test and Verify Your -ci Package

Now that we’ve uploaded our -ci package, it needs to go through testing. Testing will look different from team to team. But generally, this round of testing will solely focus on the package in question and ensure that the package meets specs.

Note: Why -ci and -rc?

-ci and -rc the prerelease tags we generally recommend, but you're free to use any naming convention that works for you. By simply adding a - to your version number, Semantic Version will treat that package as a prerelease. While naming convention can be whatever you’d like, we suggest your pipeline follows alphabetical sorting eg: Alpha > Beta > QA > Technical Preview

ProGet and most other systems sort ascending alphabetically, and teams generally want the most recent package at the top.

After your testing is completed and your package is ready for the next environment, you can move onto repackaging it.

Step 4: Repackage to a -rc Package

Now that we have our -ci package verified, we can repackage it into a release candidate (-rc) This step is often automated as part of the CI/CD pipeline, but for this example we'll do it manually.

This step may be automated by a CI/CD tool. See the Repackaging API for more details.

To repackage, simply navigate to the package and click "repackage"

ProGet TkyConvert 1.0.0-ci Pre-Release Package Page

In the popup, we can select our target feed. While it’s possible to repackage to a separate feed (promoting your package at the same time), for this example we’ll repackage to the same feed and simply change the version to: 1.0.0-rc.8.

ProGet Repackage Popup -ci to -rc

Step 5: Test and Verify -rc

A -rc (or release candidate) package is the final stage before a package reaches production. Here packages will be tested much more thoroughly. Again, this testing will change from team to team.

Not every -ci package is turned into an -rc package and only one -rc package can become stable. It’s not uncommon for teams to re-do steps 1-5 multiple times before ever making it to step 6.

After the package passes your regression tests, scenario tests, etc, it’s ready for production. To create a stable package suitable for production, we need to repackage one final time.

Step 6: Repackage to Release

Now that we’ve confirmed our -rc package is ready for production, we need to repackage it one more time to remove the prerelease tag.

This step may be automated by a CI/CD tool. See the Repackaging API for more details.

After successfully repackaging TkyConvert 1.0.0-rc.8in the exact same way as step 4 you'll have a stable version of the package.

ProGet Repackage Popup -rc to Stable

This stable package is ready for use in your production environments! Reviewing the package overview page will reveal that the package is no longer considered a prerelease.

Tky Convert ci to rc to Stable Overview

(Optional) Step 7: Review History

ProGet annual and enterprise users are able to see a package history that outlines what actions were taken by whom.

To view this history, navigate to the "History" tab on the package:

ProGet TkyConvert1.0.0 Repackage History

Free users will only be able to see the action taken and the date NOT the user and where the package was promoted to/from.

Advanced: Promotion

You can also use package promotion with prerelease packages and repackaging. This is best for stable packages you want to keep separate from prerelease packages. You can also use package promotion to create a package approval workflow to ensure that only approved and verified packages are used in the right environments.

Was this article helpful?