CI/CD Versioning Script
CI/CD Integration with Versioning API
Overview
This documentation provides guidelines for integrating the Versioning Tools API into your Continuous Integration and Continuous Deployment (CI/CD) pipeline. The objective is to automate version management for your application, ensuring consistent and traceable versioning across all releases.
Prerequisites
Before integrating the Versioning API with your CI/CD pipeline, ensure the following:
Access to Versioning Tools API: You should have a valid API key from the Versioning Tools platform.
CI/CD Platform: A working CI/CD setup (e.g., Jenkins, GitLab CI, GitHub Actions, Azure Pipelines).
Git Repository: A Git repository with a defined branching strategy (e.g.,
main
,develop
,feature/*
,release/*
).
API Endpoints
The following Versioning API endpoints are relevant for CI/CD integration:
Create or Retrieve Next Version
POST
/v1/SemVer/{serviceId}
Parameters:
serviceId
(string),identifier
(optional for branch-based differentiation)
Get Current Version
GET
/v1/SemVer/{serviceId}
Version History
GET
/v1/SemVer/{serviceId}/history
CI/CD Integration Approaches
1. Automating Version Bumping
This approach automatically increments the semantic version (major, minor, or patch) during the CI/CD pipeline based on the type of change detected (e.g., feature, bug fix, breaking change).
Workflow
Analyze Commits (Optional):
Use a script to parse commit messages and determine the type of version bump required (major, minor, or patch).
Call Versioning API:
Based on the analysis, trigger the Versioning API to generate the next version.
Apply Version:
Use the generated version to tag the release and update any relevant files (e.g.,
package.json
,setup.py
).
Build and Deploy:
Build and deploy the application using the new version.
Example: GitHub Actions
2. Versioning Based on Release Branches
This approach ties versioning directly to specific Git branches (e.g., main
, release/*
).
Workflow
Trigger on Specific Branches:
Configure the CI/CD pipeline to trigger on push events to the
release/*
ormain
branches.
Determine Version Type:
Assign different version types based on the branch. For example,
release/*
triggers a minor version bump, whilemain
triggers a patch bump.
Call Versioning API:
Automate the version bump based on the branch.
Build, Tag, and Deploy:
The pipeline builds the application, tags the release with the new version, and deploys.
Example: GitLab CI/CD
3. Version Rollback on Deployment Failure
In the event of a failed deployment, the CI/CD pipeline can trigger a rollback to the last stable version using the Versioning API.
Workflow
Monitor Deployment:
After deployment, monitor the deployment status.
Trigger Rollback on Failure:
If deployment fails, retrieve the last stable version using the
history
endpoint of the Versioning API.
Re-Deploy:
Deploy the last stable version to revert to a known good state.
Example: Azure Pipelines
Last updated