LeadershipTechnical ManagerExecution and Process

Session 05 - Release Management

"Release early, release often - nhưng release có kiểm soát." - Pragmatic DevOps


1. Semantic Versioning (SemVer) Deep Dive

Format: MAJOR.MINOR.PATCH

PhầnKhi nào tăngVí dụ
MAJORBreaking changes - API không backward-compatible2.0.0 → đổi response schema
MINORThêm feature mới, backward-compatible2.1.0 → thêm endpoint mới
PATCHBug fix, không đổi API contract2.1.1 → fix null reference

Pre-release labels

1.0.0-alpha.1    → Nội bộ dev test
1.0.0-beta.1     → UAT / limited users
1.0.0-rc.1       → Release Candidate, sẵn sàng go-live
1.0.0            → Production

Thực chiến .NET: Dùng Directory.Build.props để quản lý version tập trung:

xml
<PropertyGroup>
  <VersionPrefix>2.3.0</VersionPrefix>
  <VersionSuffix>$(BUILD_SUFFIX)</VersionSuffix>
</PropertyGroup>

2. Release Train Model

Release Train là mô hình release theo lịch cố định (ví dụ mỗi 2 tuần), bất kể feature nào sẵn sàng thì đi cùng "chuyến tàu".

Cách hoạt động

Sprint 1        Sprint 2        Sprint 3
──────────┬─────────────┬──────────────┬──→
          │ Release 1.0 │ Release 1.1  │
          │ (Feature A) │ (Feature B,C)│

Ưu điểm:

  • Predictable cho stakeholders - biết trước ngày release
  • Giảm áp lực "phải ship ngay" cho từng feature
  • Dễ lập kế hoạch testing và deployment

Nhược điểm:

  • Feature chưa sẵn sàng phải chờ "chuyến tàu" kế tiếp
  • Cần Feature Flags để tách deployment khỏi release

3. Hotfix Process

Hotfix Rules

  1. Chỉ fix đúng bug - không "tiện tay" thêm feature
  2. Fast-track review - cần ít nhất 1 senior approve
  3. Rollback plan bắt buộc trước khi deploy
  4. Post-mortem trong 48h - tại sao bug lọt lên production?

4. Release Notes Automation

Conventional Commits → Auto Release Notes

feat: add payment retry mechanism
fix: resolve null reference in OrderService
docs: update API documentation for v2
perf: optimize database query for reports
BREAKING CHANGE: remove deprecated /api/v1/users endpoint

Tools:

  • GitVersion - tự động tính SemVer từ Git history
  • Versionize - generate CHANGELOG.md từ conventional commits
  • GitHub Actions - auto-create release với notes

Template Release Notes

markdown
## Release v2.3.0 - [Ngày phát hành]

### New Features
- [JIRA-123] Thêm chức năng retry payment tự động
- [JIRA-145] Dashboard mới cho admin

### Bug Fixes
- [JIRA-167] Fix lỗi timeout khi export report lớn
- [JIRA-172] Fix memory leak trong background job

### Breaking Changes
- Endpoint `/api/v1/users` đã bị xoá, dùng `/api/v2/users`

### Known Issues
- [JIRA-180] Performance chậm khi filter > 10k records (đang fix)

### Upgrade Notes
- Chạy migration script: `dotnet ef database update`
- Cập nhật environment variable: `PAYMENT_RETRY_COUNT=3`

5. Feature Freeze vs Continuous Delivery

Feature FreezeContinuous Delivery
Mô tảDừng thêm feature X ngày trước release, chỉ fix bugMỗi commit đều có thể deploy production
Phù hợpEnterprise, regulated industriesSaaS, startup, high-maturity team
Rủi roBottleneck cuối SprintCần automation test coverage cao
TestingManual + regression cuối giai đoạnAutomated testing liên tục

Khi nào dùng Feature Freeze?

  • Release lớn, nhiều team phụ thuộc nhau
  • Regulatory requirement (banking, healthcare)
  • Team chưa đủ mature cho CD

Khi nào dùng Continuous Delivery?

  • Microservices - mỗi service release độc lập
  • Test automation coverage > 80%
  • Feature flags đã sẵn sàng

6. Rollback Procedures

Rollback Decision Matrix

Tình huốngHành độngThời gian mục tiêu
Bug nhỏ, không ảnh hưởng core flowHotfix forward< 4 giờ
Bug nghiêm trọng, ảnh hưởng payment/authRollback ngay< 15 phút
Data corruptionRollback + restore backup< 1 giờ
Performance degradation > 50%Rollback ngay< 15 phút

Rollback Steps (Azure App Service / K8s)

bash
# Azure App Service - swap về slot trước đó
az webapp deployment slot swap \
  --resource-group myRG \
  --name myApp \
  --slot staging \
  --target-slot production

# Kubernetes - rollback deployment
kubectl rollout undo deployment/myapp -n production
kubectl rollout status deployment/myapp -n production

Database Rollback

  • Luôn có backward-compatible migration - thêm column trước, xoá column sau
  • Không bao giờ rename column trong 1 release - tách thành 2 releases
  • Sử dụng expand-contract pattern cho schema changes

7. Release Checklist Template

Pre-Release (T-3 ngày)

  • Tất cả feature branches đã merge vào release branch
  • Version number đã cập nhật (SemVer)
  • Release notes đã viết và review
  • Database migration scripts đã test trên staging
  • Performance test passed (response time, throughput)
  • Security scan passed (OWASP, dependency vulnerabilities)
  • API documentation cập nhật (Swagger/OpenAPI)

Release Day (T-0)

  • Backup database production trước khi deploy
  • Notify stakeholders về deployment window
  • Deploy lên staging → smoke test
  • Deploy lên production (blue-green hoặc canary)
  • Smoke test trên production (critical paths)
  • Monitor error rate, latency, CPU/memory trong 30 phút đầu
  • Confirm rollback plan sẵn sàng

Post-Release (T+1 ngày)

  • Monitor production 24h - kiểm tra error logs
  • Thu thập feedback từ users
  • Cập nhật JIRA/Azure DevOps - đóng release
  • Merge release branch về develop/main
  • Tag Git release: git tag -a v2.3.0 -m "Release 2.3.0"
  • Retrospective ngắn: release process có gì cần cải thiện?

Session tiếp theo: Session 06 - Risk Management sẽ đi sâu vào cách nhận diện và quản lý rủi ro trong dự án phần mềm.