What is semantic versioning (SemVer) and how does it relate to Git tags?
Answer
Semantic versioning (SemVer) is a versioning convention that encodes meaning into the version number: MAJOR.MINOR.PATCH (e.g., 2.4.1). Rules: increment MAJOR (2→3) for breaking changes — incompatible API changes; increment MINOR (2.4→2.5) for new backward-compatible features; increment PATCH (2.4.1→2.4.2) for backward-compatible bug fixes. Pre-release: 2.5.0-alpha.1, 2.5.0-rc.1. Build metadata: 2.5.0+build.123. Git tags are the mechanism for marking specific commits as version releases: git tag -a v2.4.1 -m "Release 2.4.1 - Fix login timeout"; git push origin v2.4.1. GitHub creates release packages from tags. Automation: semantic-release npm package analyzes Conventional Commit messages and automatically: determines the next version number; creates the Git tag; generates a changelog; publishes to npm. Integration: CI/CD pipelines trigger on tag creation (on: push: tags: ["v*"] in GitHub Actions) to automatically build and deploy. Consumers use ~ (patch updates) and ^ (minor updates) in package.json, trusting SemVer semantics for safe upgrades.