c4efe4453b
- ✅ - ✅ - ✅
246 lines
6.0 KiB
Markdown
246 lines
6.0 KiB
Markdown
# Release Workflow
|
|
|
|
Panduan rilis: commit perubahan, naikan versi, push. Konsisten dengan pola history repo (single feature commit + version commit terpisah).
|
|
|
|
---
|
|
|
|
## Aturan versi (semver untuk 0.x)
|
|
|
|
Project masih `0.x.y` — API belum stabil, semver yang dipakai:
|
|
|
|
| Tipe perubahan | Bump | Contoh |
|
|
|---|---|---|
|
|
| **MAJOR** `0.x.y → 1.0.0` | hanya saat siap rilis publik / API stabil | nanti |
|
|
| **MINOR** `0.11.0 → 0.12.0` | fitur baru, breaking change, schema/migration baru, removal API | midtrans-only flow, structured itinerary |
|
|
| **PATCH** `0.10.2 → 0.10.3` | bugfix, dependency upgrade, copy/UI tweaks tanpa schema | upgrade lib vulnerability, fix hydration |
|
|
|
|
**Aturan praktis:** kalau perlu jalankan `prisma migrate deploy` setelah pull → minor. Kalau cuma `git pull && pm2 restart` → patch.
|
|
|
|
---
|
|
|
|
## Pre-flight check (wajib sebelum commit)
|
|
|
|
```bash
|
|
# 1. Type check (filter cache stale Next.js)
|
|
npx tsc --noEmit 2>&1 | grep -v "\.next"
|
|
|
|
# 2. Lint
|
|
npm run lint
|
|
|
|
# 3. (Opsional) test seed kalau ubah schema/seed
|
|
npm run seed
|
|
```
|
|
|
|
Kalau ada error di TS atau ESLint, **jangan commit**. Fix dulu.
|
|
|
|
---
|
|
|
|
## Standard flow (rekomendasi)
|
|
|
|
Pola dari history repo: **1 commit fitur** + **1 commit versi** terpisah.
|
|
|
|
### 1. Verify status
|
|
|
|
```bash
|
|
git status
|
|
git diff --stat
|
|
```
|
|
|
|
Pastikan tidak ada file sensitif (`.env`, `*.key`, upload KYC, `app/generated/prisma/`) ter-track.
|
|
|
|
### 2. Stage perubahan
|
|
|
|
Default — semua perubahan logis:
|
|
|
|
```bash
|
|
git add -A
|
|
```
|
|
|
|
Kalau ada file yang sengaja dipisah commit-nya, pakai selective:
|
|
|
|
```bash
|
|
git add path/to/file1 path/to/file2
|
|
```
|
|
|
|
### 3. Commit fitur
|
|
|
|
Pakai pesan singkat, lowercase, deskriptif. Pola history:
|
|
|
|
- ✅ `midtrans-only payment + reconcile, structured itinerary items, admin roadmap`
|
|
- ✅ `add payment and integration with midtrans`
|
|
- ✅ `create public layout and admin and fix escrow and refund`
|
|
- ✅ `chore: remove generated prisma client from repository`
|
|
|
|
Prefix `chore:`, `fix:` boleh dipakai tapi tidak wajib. Yang penting: deskriptif & ringkas.
|
|
|
|
```bash
|
|
git commit -m "deskripsi singkat perubahan utama"
|
|
```
|
|
|
|
### 4. Bump versi
|
|
|
|
Edit manual `package.json` di field `"version"`, atau pakai npm:
|
|
|
|
```bash
|
|
# Bump tanpa auto-commit & tag (kita commit manual)
|
|
npm version 0.12.0 --no-git-tag-version
|
|
```
|
|
|
|
`--no-git-tag-version` penting — repo ini **tidak pakai git tag**, cuma commit dengan pesan = nomor versi.
|
|
|
|
### 5. Commit versi (terpisah)
|
|
|
|
```bash
|
|
git add package.json
|
|
git commit -m "0.12.0"
|
|
```
|
|
|
|
Pesan = nomor versi saja, tanpa prefix/kata lain. Konsisten dengan history (`0.11.0`, `0.10.3`, `0.10.2`, ...).
|
|
|
|
### 6. Push
|
|
|
|
```bash
|
|
git push origin main
|
|
```
|
|
|
|
---
|
|
|
|
## Post-deploy actions
|
|
|
|
Setelah merge ke main + auto-deploy / `git pull` di server:
|
|
|
|
### Wajib kalau ada migration baru
|
|
|
|
```bash
|
|
# Cek dulu migration belum applied
|
|
npx prisma migrate status
|
|
|
|
# Apply
|
|
npx prisma migrate deploy
|
|
|
|
# Restart PM2 supaya Prisma client re-load
|
|
pm2 restart setrip --update-env
|
|
```
|
|
|
|
### Wajib kalau ubah field di env
|
|
|
|
```bash
|
|
# Edit .env di server, lalu
|
|
pm2 restart setrip --update-env
|
|
```
|
|
|
|
### Opsional — seed (hanya untuk dev/staging, JANGAN production)
|
|
|
|
```bash
|
|
npm run seed
|
|
```
|
|
|
|
⚠️ **Production**: seed wipe seluruh data. Jangan dijalankan di production.
|
|
|
|
---
|
|
|
|
## Skenario umum
|
|
|
|
### A. Bug fix kecil (patch)
|
|
|
|
```bash
|
|
npx tsc --noEmit 2>&1 | grep -v "\.next" && npm run lint
|
|
|
|
git add path/to/fix
|
|
git commit -m "fix: deskripsi bug"
|
|
|
|
npm version patch --no-git-tag-version # 0.11.0 → 0.11.1
|
|
git add package.json
|
|
git commit -m "0.11.1"
|
|
|
|
git push origin main
|
|
```
|
|
|
|
### B. Fitur baru tanpa schema change (minor)
|
|
|
|
Sama dengan A, ganti `patch` jadi `minor`:
|
|
|
|
```bash
|
|
npm version minor --no-git-tag-version # 0.11.0 → 0.12.0
|
|
```
|
|
|
|
### C. Fitur baru DENGAN schema/migration (minor)
|
|
|
|
```bash
|
|
# 1. Buat migration
|
|
npx prisma migrate dev --name nama_migration
|
|
|
|
# 2. Smoke test
|
|
npm run seed
|
|
npx tsc --noEmit 2>&1 | grep -v "\.next"
|
|
|
|
# 3. Commit fitur + migration sekaligus
|
|
git add -A
|
|
git commit -m "deskripsi fitur"
|
|
|
|
# 4. Bump versi minor
|
|
npm version minor --no-git-tag-version
|
|
git add package.json
|
|
git commit -m "$(node -p "require('./package.json').version")"
|
|
|
|
git push origin main
|
|
|
|
# 5. Di production, setelah git pull:
|
|
npx prisma migrate deploy
|
|
pm2 restart setrip --update-env
|
|
```
|
|
|
|
### D. Multiple perubahan logis di branch yang sama (split commits)
|
|
|
|
Pisahkan jadi commit kecil per topik supaya history bersih:
|
|
|
|
```bash
|
|
# Commit 1: foundation (mis. schema + service)
|
|
git add prisma/ server/
|
|
git commit -m "add X service"
|
|
|
|
# Commit 2: UI yang konsumsi
|
|
git add features/ app/
|
|
git commit -m "wire X to UI"
|
|
|
|
# Commit 3: docs
|
|
git add docs/ *.md
|
|
git commit -m "docs: X usage guide"
|
|
|
|
# Commit 4: version bump
|
|
npm version minor --no-git-tag-version
|
|
git add package.json
|
|
git commit -m "$(node -p "require('./package.json').version")"
|
|
|
|
git push origin main
|
|
```
|
|
|
|
---
|
|
|
|
## Kesalahan umum & cara recovery
|
|
|
|
| Kesalahan | Recovery |
|
|
|---|---|
|
|
| Commit pesan typo, **belum push** | `git commit --amend -m "pesan baru"` |
|
|
| Commit pesan typo, **sudah push** | jangan amend (force-push hilangin history kolaborator). Bikin commit baru `git commit --allow-empty -m "fix: pesan sebelumnya typo"` atau biarkan |
|
|
| Lupa bump versi sebelum push | bikin commit versi baru di atasnya — bukan amend |
|
|
| Bump versi salah angka (mis. 0.12.0 padahal harusnya patch 0.11.1) | revisi `package.json`, bikin commit baru `chore: revert version to 0.11.1` |
|
|
| Commit termasuk file sensitif (`.env`, upload) | jangan push. `git reset --soft HEAD~1`, un-stage file sensitif, tambah ke `.gitignore`, commit ulang |
|
|
| Sudah push dengan file sensitif | rotate secret yang ke-leak, lalu pakai `git filter-repo` atau hubungi maintainer git history |
|
|
|
|
---
|
|
|
|
## Cheatsheet (one-liner)
|
|
|
|
Untuk update biasa (fitur kecil tanpa schema):
|
|
|
|
```bash
|
|
npx tsc --noEmit 2>&1 | grep -v "\.next" && npm run lint && \
|
|
git add -A && git commit -m "deskripsi" && \
|
|
npm version minor --no-git-tag-version && \
|
|
git add package.json && git commit -m "$(node -p "require('./package.json').version")" && \
|
|
git push origin main
|
|
```
|
|
|
|
Ganti `minor` → `patch` untuk bug fix. Jangan jalankan kalau ada step yang minta keputusan manual (mis. conflict, migration baru).
|