Simplified Strategy

Documentation: Simplified Strategy for Versioning with Versioning Tools API

Overview

This guide outlines a streamlined approach for managing and automating versioning using the Versioning Tools API. It shows how to retrieve the next version identifier and tag your Git repository based on the API's response. This process ensures consistent and automated version management for your projects.

Prerequisites

Before you start, ensure you have:

  1. API Access: An API key for the Versioning Tools platform.

  2. Git Repository: Your project’s source code managed in a Git repository.

  3. Git Installed: Git must be installed and configured on your local machine or CI/CD environment.

API Endpoints Overview

The Versioning Tools API provides several endpoints to manage semantic versions:

  1. Get Next Version Identifier:

    • POST /v1/SemVer/{serviceId}

    • Description: Retrieves the next semantic version for your service.

  2. Get Current Version:

    • GET /v1/SemVer/{serviceId}

    • Description: Retrieves the current semantic version for the specified service.

  3. Set Specific Version:

    • POST /v1/SemVer/{serviceId}/set/{semVer}

    • Description: Sets a specific version manually.

Simplified Strategy for Version Management

Step 1: Retrieve the Next Version Identifier

To get the next version identifier from the Versioning Tools API:

  1. Call the API: Use the POST method on the /v1/SemVer/{serviceId} endpoint to get the next version identifier.

    Example using curl:

    curl -X 'POST' \
      'https://api.versioning.tools/v1/SemVer/myServiceId?apiKey=YOUR_API_KEY' \
      -H 'accept: */*'

    Replace myServiceId with your service ID and YOUR_API_KEY with your API key. The response will provide the next semantic version (e.g., 1.2.0), which you can use to tag your Git repository.

  2. Use an Identifier (Optional): If you need to differentiate versions based on a specific context (e.g., branch name), you can include an identifier:

    curl -X 'POST' \
      'https://api.versioning.tools/v1/SemVer/myServiceId/identifier/develop?apiKey=YOUR_API_KEY' \
      -H 'accept: */*'

Step 2: Tag the Git Repository with the New Version

After obtaining the next version identifier, you can tag your Git repository:

  1. Tag the Current Commit: Use the git tag command to create a tag with the version you received from the API.

    git tag v1.2.0 -m "Release version 1.2.0"

    Replace v1.2.0 with the version returned by the API.

  2. Push the Tag to the Remote Repository: Push the newly created tag to your remote repository:

    git push origin v1.2.0

Step 3: Automate the Process (Optional)

To automate this process, you can include these steps in a CI/CD pipeline script. Here’s an example using a shell script:

#!/bin/bash

# Step 1: Get the next version from the API
NEXT_VERSION=$(curl -X 'POST' \
  'https://api.versioning.tools/v1/SemVer/myServiceId?apiKey=YOUR_API_KEY' \
  -H 'accept: */*')

# Step 2: Tag the current commit
git tag "v$NEXT_VERSION" -m "Release version $NEXT_VERSION"

# Step 3: Push the tag to the remote repository
git push origin "v$NEXT_VERSION"

Replace myServiceId and YOUR_API_KEY with your service ID and API key, respectively.


Last updated