Files
mdm-ordinis/RELEASE.md
T
Zimin A.N. 6805c70a6b ci: semantic-release automation for tag/changelog (Option D)
Закрывает эту тему окончательно. После merge в main CI анализирует
conventional commits с последнего tag'а, бампит package.json + CHANGELOG.md
и пушит git tag vX.Y.Z. Tag pipeline далее собирает images и ждёт
manual gate на trigger-deploy-prod.

Что добавил:
- ordinis-admin-ui/.releaserc.json — config (commit-analyzer, release-notes,
  changelog, npm[no-publish], git, gitlab). branches: ['main']. Маппинг
  conventional-commit types к bump levels.
- ordinis-admin-ui/package.json — devDeps: semantic-release@24.2 + 6 plugins.
- .gitlab-ci.yml — new 'release' stage + release job:
  - needs: trigger-deploy-staging (release ТОЛЬКО после зелёного staging)
  - image: node:22-alpine + pnpm@9.15.4
  - GL_TOKEN из CI variable GITLAB_TOKEN (semantic-release/gitlab требует
    именно GL_TOKEN env name)
  - allow_failure: true (нет релизных commits = OK, не блокирует pipeline)
- RELEASE.md — operator docs:
  - One-time setup: создать Project Access Token + GITLAB_TOKEN CI var
  - Commit conventions table (feat→minor, fix→patch, breaking→major)
  - Skip release (use chore: type или [skip ci])
  - Dry-run command для local validation

Prod safety: trigger-deploy-prod остаётся manual (when: manual). Автоматизация
ТОЛЬКО tag-создания, не deploy. Tag → CI runs → human кликает Deploy.

ACTION REQUIRED от user (one-time):
  1. GitLab → Settings → Access Tokens → создать Project Access Token
     scopes: write_repository + api, role: Maintainer
  2. GitLab → Settings → CI/CD → Variables → GITLAB_TOKEN (Masked, Protected)

Без этого release job будет fail'ить (но pipeline не покраснеет — allow_failure).
2026-05-11 14:51:03 +03:00

100 lines
3.2 KiB
Markdown

# Release Automation
Ordinis uses **semantic-release** для автоматического создания tag'ов на основе
conventional commits. После merge в `main` CI анализирует commits, решает
bump (patch/minor/major), генерирует `CHANGELOG.md` и пушит tag `vX.Y.Z`.
Tag pipeline далее собирает images и ждёт manual gate на `trigger-deploy-prod`.
Prod deploy остаётся под human control — semantic-release создаёт tag,
human кликает Deploy.
## One-time setup
1. **Create Project Access Token** (GitLab UI):
- `Settings → Access Tokens → Add new token`
- Name: `semantic-release`
- Role: `Maintainer`
- Scopes: `write_repository`, `api`
- Expiry: 1 год (renew annually)
2. **Add CI variable**:
- `Settings → CI/CD → Variables → Add variable`
- Key: `GITLAB_TOKEN`
- Value: (token из шага 1)
- Type: `Variable`
- Flags: `Masked` ✅, `Protected` ✅ (только main + tag pipelines)
После этого release job в `.gitlab-ci.yml` будет работать.
## Commit conventions
Conventional Commits (https://www.conventionalcommits.org/):
| Type | Bump | Section в CHANGELOG |
|------|------|---------------------|
| `feat:` | **minor** | ✨ Features |
| `fix:` | patch | 🐛 Fixes |
| `perf:` | patch | ⚡ Performance |
| `refactor:` | patch | ♻️ Refactoring |
| `revert:` | patch | ⏪ Reverts |
| `docs:` | none | 📝 Docs |
| `chore:` | none | hidden |
| `test:` | none | hidden |
| `style:` | none | hidden |
| `ci:` | none | hidden |
| `build:` | none | hidden |
**Breaking changes** — добавь `BREAKING CHANGE:` в footer commit message → major bump.
```
feat(api): drop legacy v1 endpoint
BREAKING CHANGE: /api/v1/* paths больше не поддерживаются.
Все клиенты должны мигрировать на /api/v2.
```
## Skip release for specific commit
Если хочешь смержить `feat:` или `fix:` но **не** делать release сейчас —
добавь `[skip ci]` в commit message ИЛИ используй non-release type
(`chore:`, `docs:`, etc).
```
chore(deps): bump axios 1.7 -> 1.8
```
## Loop prevention
Release job создаёт commit `chore(release): vX.Y.Z [skip ci]`. `[skip ci]`
стандартный GitLab marker, новый pipeline не триггерится. Версия package.json
+ CHANGELOG.md обновляются в этом коммите.
## Branch policy
Релизы создаются ТОЛЬКО с `main`. Feature branches (`feat/*`, `fix/*`) собираются
для staging но НЕ создают tag'и. Релиз = merge в main + успешный staging deploy +
наличие релизных commits.
## Local dry-run
Проверить что semantic-release решит сделать без push:
```bash
cd ordinis-admin-ui
pnpm install
npx semantic-release --dry-run --no-ci
```
Покажет следующую версию + preview CHANGELOG entries.
## Rollback
Если случайно зарелизили — удали tag:
```bash
git tag -d v1.3.1
git push origin :refs/tags/v1.3.1
```
GitLab Releases UI — удали release object отдельно.