2022-11-26 18:00:00+00:00

In continuous integration pipelines, deploying software updates requires updating build versions and tagging source code. Doing this manually is time-consuming and can lead to merge conflicts or missing tags. Writing automated Release Scripts ensures that versions follow Semantic Versioning (SemVer) rules, tags are applied correctly, and release logs are generated automatically.

By scripting shell utilities, we can automate patch and minor version increments on code commits.


1. Automated SemVer Tagging Script

We write a bash script that parses the current git tags, increments the patch or minor version, and pushes the new tag to the repository:

#!/bin/bash
# release.sh
set -euo pipefail

# Fetch latest tags
git fetch --tags

# Get current version tag (e.g. v1.2.3)
CURRENT_VERSION=$(git describe --tags --abbrev=0 2>/dev/null || echo "v0.0.0")
echo "Current Version: $CURRENT_VERSION"

# Strip 'v' prefix
VERSION_NUM=${CURRENT_VERSION#v}
IFS='.' read -r major minor patch <<< "$VERSION_NUM"

# Increment patch version by default
NEW_PATCH=$((patch + 1))
NEW_VERSION="v$major.$minor.$NEW_PATCH"

echo "New Version: $NEW_VERSION"

# Apply git tag and push
git tag -a "$NEW_VERSION" -m "Release version $NEW_VERSION"
git push origin "$NEW_VERSION"

2. Updating Package Configurations

Before creating the tag, the release script updates local config files (such as package.json or setup.py), committing the changes automatically to keep version files in sync.

Conventional Commits & Automated Changelog Tagging in Git Pipelines

Parse commit prefixes (feat:, fix:, BREAKING CHANGE:) to compute semantic version bumps, generate release notes, and push immutable container tags automatically.


About the Author — Hire Freelance Programmer Aldian Fazrihady

Aldian Fazrihady is a Top-Rated Senior Freelance Programmer, Freelance Full Stack Developer, and AI Application Engineer with 15+ years of production software engineering experience and Google Cloud Professional Cloud Architect & Data Engineer certifications. He specializes in building custom LLM & autonomous AI agents, RAG pipelines, Next.js/React PWAs, Python (Django/FastAPI), Go microservices, and serverless cloud infrastructure on Google Cloud Run and AWS.

Hire Aldian Fazrihady on Upwork | Book 1-Day Programming Service ($100 USD via Polar) | View Live AI Portfolio | Portfolio Directory | Send a Direct Message

Related Engineering Articles

Freelance Programmer Specializations & Category Hubs