SEMANTIC VERSIONING
IMPLEMENTATION
VARIATIONS
DANIEL ROGATCHEVSKY
DevOps Architect @ Cyberbit
AUTOMATIC VERSIONING
• When do we need human readable versioning?
• Continuous Deployment (not necessary)
• Continuous Delivery (required)
• CI and workstation
• Software versioning*
• Schemas: sequence, change significance, degree of compatibility,
development stage, date of release
• Package and provider native: Python, Debian, Apple, Windows
*Wikipedia - Software versioning
SEMVER REVIEW - HTTPS://SEMVER.ORG
• RFC. Engineers love RFC. SemVer is not.
• Long story short:
• MAJOR.MINOR.PATCH triple – requires single source of truth
• – pre-release – release candidates
• + metadata – usually a commit hash
• Examples:
• 1.2.3-{{BUILD_ID}} – release candidate for POC or
sales
• 1.2.3-PR{{PR_ID}}-{{BUILD_ID}} – PR, extended testing + QA
• 1.2.3+{{SHORT_COMMIT_HASH}} – feature branch, minimal testing,
disposable
AUTOMATIC VERSIONING IN CI
JIRA
• Issue
• Epic
• Release
• Create branch
BITBUCKET
• Hooks
• Push
• PR
• Merge
• Branch
permissions
• Merge policies
JENKINS
• Shared Library
• Bitbucket Project
• Multibranch
Pipeline
ARTIFACTORY
• DevRCRelease
• Rich metadata
AUTOMATIC VERSIONING – JENKINS SHARED
LIBRARY
BASE_VERSION – triple, requires single source of truth
• version.txt – let business unit to decide
• JIRA
• Major – API version
• Minor – branch name  issue ID  target release
• Patch – branch name  issue ID  sprint number
• Calculate*
• Major – API version
• Minor – number of commits in source branch
(from master root to develop parent in master )
• Patch – number of commits in new source branch
(from develop parent in master to feature head)
*A better versioning scheme - Shalom Yerushalmy
1
2
1
2
1
2
4
5
7
AUTOMATIC VERSIONING – JSL
BUILD_TYPE
• Cause from Bitbucket hook* or trigger
• Branch type from Bitbucket hook
- regex based on JIRA naming
Examples
• 1.6.6+pd5hqf - feature push
• 1.6.6-PR-5492-5 - PR to release #5492 , 4th improvement
• 1.6.6-445 - RC for 1.6.6 with 444 issues resolved
• 1.6.6-445-customer_tag
enum BuildType implements Serializable{
FEATURE_PUSH(100,""),
EXPERIMENTAL_FEATURE_PUSH(101,""),
USER_MANUAL(102,""),
FEATURE_TAG_PUSH(102,""),
RELEASE_PUSH(200,""),
RELEASE_TAG_PUSH(201,""),
PR_TO_FEATURE(300,""),
PR_TO_RELEASE(301,""),
SCHEDULED_MINIMAL(400,""),
SCHEDULED_FULL(401,"")
*BranchEventCause
AUTOMATIC VERSIONING – JSL VERSION
HELPER
/**
* Implementation of Semantic Versioning 2.0 https://semver.org/
*/
class VersionHelper implements Serializable, Comparable<VersionHelper> {
VersionHelper(script, String str)
VersionHelper(script, int major, int minor, int patch, String
preRelease, String metadata)
private boolean isVersionTripletLegal(String major, String minor,
String patch)
private String[] extractVersionTriplet(String str)
private String extractMetadata(String str)
private String extractPreRelease(String str)
int compareTo(VersionHelper v2)
int compareTripple (VersionHelper v2)
int comparePreRelease (VersionHelper v2)
int compareCommits(VersionHelper v2)
private String mostRecentVersion( List versions )
AUTOMATIC VERSIONING IN CD – MONO
EVERYTHING
JENKINS
• Shared Library
• Artifact SemVer
• BUILD_TYPE
• Dependencies (hash)
• Extra parameters
BITBUCKET
• Deployment
procedure associated
with the artifact
version
ARTIFACTORY
• Artifact
• Metadata
Deliver
y
AUTOMATIC VERSIONING IN CD – MULTI &
MICRO
• Dedicated repo for deployment configuration and offline release
• Default dynamic dependencies
• Last successful nightly build
• Last successful RC build
• More complicated dependencies
• Time based
• From hotfix/feature branches
curl -X POST 
http://artifactory.mydomain.com/artifactory/api/search/aql 
-H 'Accept: */*' 
-H 'Authorization: Basic ABCdefghigklmn123=' 
-H 'Content-Type: text/plain' 
-H 'Host: artifactory.mydomain.com' 
-H 'accept-encoding: gzip, deflate' 
-d 'items.find(
{
"repo":{"$eq":"my_docker_repo"},
"name":{"$match":"manifest.json"},
"path":{"$match":"*my_microservice*"},
"created":{"$gt":"2019-05-12"},
"@docker.label.job.name" : {"$eq" : "~git-organization/git-
repo/branch"},
"@docker.label.qa_approved" : {"$eq" : "true"}
}
).include("*", "property.*")'
LESSONS LEARNED
• JSL
• Back to bash
• Release notes
• QA

Semantic versioning implementation variations

  • 1.
  • 2.
    AUTOMATIC VERSIONING • Whendo we need human readable versioning? • Continuous Deployment (not necessary) • Continuous Delivery (required) • CI and workstation • Software versioning* • Schemas: sequence, change significance, degree of compatibility, development stage, date of release • Package and provider native: Python, Debian, Apple, Windows *Wikipedia - Software versioning
  • 3.
    SEMVER REVIEW -HTTPS://SEMVER.ORG • RFC. Engineers love RFC. SemVer is not. • Long story short: • MAJOR.MINOR.PATCH triple – requires single source of truth • – pre-release – release candidates • + metadata – usually a commit hash • Examples: • 1.2.3-{{BUILD_ID}} – release candidate for POC or sales • 1.2.3-PR{{PR_ID}}-{{BUILD_ID}} – PR, extended testing + QA • 1.2.3+{{SHORT_COMMIT_HASH}} – feature branch, minimal testing, disposable
  • 4.
    AUTOMATIC VERSIONING INCI JIRA • Issue • Epic • Release • Create branch BITBUCKET • Hooks • Push • PR • Merge • Branch permissions • Merge policies JENKINS • Shared Library • Bitbucket Project • Multibranch Pipeline ARTIFACTORY • DevRCRelease • Rich metadata
  • 5.
    AUTOMATIC VERSIONING –JENKINS SHARED LIBRARY BASE_VERSION – triple, requires single source of truth • version.txt – let business unit to decide • JIRA • Major – API version • Minor – branch name  issue ID  target release • Patch – branch name  issue ID  sprint number • Calculate* • Major – API version • Minor – number of commits in source branch (from master root to develop parent in master ) • Patch – number of commits in new source branch (from develop parent in master to feature head) *A better versioning scheme - Shalom Yerushalmy 1 2 1 2 1 2 4 5 7
  • 6.
    AUTOMATIC VERSIONING –JSL BUILD_TYPE • Cause from Bitbucket hook* or trigger • Branch type from Bitbucket hook - regex based on JIRA naming Examples • 1.6.6+pd5hqf - feature push • 1.6.6-PR-5492-5 - PR to release #5492 , 4th improvement • 1.6.6-445 - RC for 1.6.6 with 444 issues resolved • 1.6.6-445-customer_tag enum BuildType implements Serializable{ FEATURE_PUSH(100,""), EXPERIMENTAL_FEATURE_PUSH(101,""), USER_MANUAL(102,""), FEATURE_TAG_PUSH(102,""), RELEASE_PUSH(200,""), RELEASE_TAG_PUSH(201,""), PR_TO_FEATURE(300,""), PR_TO_RELEASE(301,""), SCHEDULED_MINIMAL(400,""), SCHEDULED_FULL(401,"") *BranchEventCause
  • 7.
    AUTOMATIC VERSIONING –JSL VERSION HELPER /** * Implementation of Semantic Versioning 2.0 https://semver.org/ */ class VersionHelper implements Serializable, Comparable<VersionHelper> { VersionHelper(script, String str) VersionHelper(script, int major, int minor, int patch, String preRelease, String metadata) private boolean isVersionTripletLegal(String major, String minor, String patch) private String[] extractVersionTriplet(String str) private String extractMetadata(String str) private String extractPreRelease(String str) int compareTo(VersionHelper v2) int compareTripple (VersionHelper v2) int comparePreRelease (VersionHelper v2) int compareCommits(VersionHelper v2) private String mostRecentVersion( List versions )
  • 8.
    AUTOMATIC VERSIONING INCD – MONO EVERYTHING JENKINS • Shared Library • Artifact SemVer • BUILD_TYPE • Dependencies (hash) • Extra parameters BITBUCKET • Deployment procedure associated with the artifact version ARTIFACTORY • Artifact • Metadata Deliver y
  • 9.
    AUTOMATIC VERSIONING INCD – MULTI & MICRO • Dedicated repo for deployment configuration and offline release • Default dynamic dependencies • Last successful nightly build • Last successful RC build • More complicated dependencies • Time based • From hotfix/feature branches curl -X POST http://artifactory.mydomain.com/artifactory/api/search/aql -H 'Accept: */*' -H 'Authorization: Basic ABCdefghigklmn123=' -H 'Content-Type: text/plain' -H 'Host: artifactory.mydomain.com' -H 'accept-encoding: gzip, deflate' -d 'items.find( { "repo":{"$eq":"my_docker_repo"}, "name":{"$match":"manifest.json"}, "path":{"$match":"*my_microservice*"}, "created":{"$gt":"2019-05-12"}, "@docker.label.job.name" : {"$eq" : "~git-organization/git- repo/branch"}, "@docker.label.qa_approved" : {"$eq" : "true"} } ).include("*", "property.*")'
  • 10.
    LESSONS LEARNED • JSL •Back to bash • Release notes • QA