Build & phát hành game client (Flutter)
Game không deploy lên VPS — chỉ cần Portal (§1–§7) đã chạy. Áp dụng cho
Drone Strike (nhánh online) và mọi game tạo từ template của SDK.
Yêu cầu trên máy build: Flutter stable, Android SDK (Xcode trên macOS
cho iOS), và SSH key đọc được gitlab.com:sdk4243540/game-portal-sdk
(pubspec.yaml lấy các package SDK từ đó theo tag).
Phiên bản SDK:
| Tag | Nội dung | Dùng cho |
|---|---|---|
v0.2.2 | API v2, profile/bảng xếp hạng, kinh tế kiểu cũ (client_reported) | Drone Strike hiện tại |
v0.3.0 | Thêm template meta-game (portal_ui, portal_ads), kinh tế do server giữ (PlayerStateStore, RunSession), cửa hàng Portal, portal_iap | Game mới (tgk create mặc định), Drone Strike khi chuyển chế độ server |
- Tạo file env (đã gitignore, không commit) từ file mẫu:
Terminal window cp env/prod.json.example env/prod.json{"PORTAL_BASE_URL": "https://portal.tinysoft.io.vn","PORTAL_API_KEY": "<Game Registry → API Key của game>","PLAY_GAMES_WEB_CLIENT_ID": "<web client id>.apps.googleusercontent.com"}PLAY_GAMES_WEB_CLIENT_IDphải là cùng client đã nhập trên Portal (§8.1 bước 4). ThiếuPORTAL_API_KEYthì app vẫn chạy nhưng tắt toàn bộ tính năng Portal. Game có quảng cáo thêm cácADMOB_*unit id (xemenv/prod.json.example). - Build:
Dev:
Terminal window flutter pub getflutter build appbundle --release --dart-define-from-file=env/prod.json # Google Playflutter build ipa --release --dart-define-from-file=env/prod.json # App Store (macOS)flutter run --dart-define-from-file=env/dev.jsonvới Portal local; trên thiết bị/emulator Android chạyadb reverse tcp:8000 tcp:8000để app gọi đượchttp://localhost:8000. Game từ template còn có--dart-define=PORTAL_MOCK=trueđể chạy không cần Portal. - Mua bằng tiền thật (game có IAP): sản phẩm trên Play Console phải trùng mã
với Catalog và flag
iapđã bật (§8.5). Test bằng license tester trên bản internal testing, không test được trên bản debug cài tay. - Phát hành theo staged rollout (5% → 20% → 100%); theo dõi Portal → Bất
thường kinh tế và log
/api/v2. - Nâng SDK: đổi
ref:sang tag mới trongpubspec.yaml(mọi package SDK và mụcdependency_overridescùng một tag) →flutter pub upgrade→ chạy lại test. ĐọcCHANGELOG.mdcủa SDK trước khi nâng:v0.3.0chỉ chấp nhận tiền tệGOLD/GEM.
Thêm game mới: trong repo SDK, cd packages/tgk && dart run tgk create ../../../<game_id> --game-id <game_id> --display-name "<Tên game>", rồi làm theo trang Hướng dẫn
thêm game trên Portal (/admin/onboarding) hoặc ONBOARDING_GAME.md trong
repo SDK. Game tạo từ template đã chạy chế độ server; khai báo game lên Portal
bằng tgk portal apply, rồi tạo giá bán trên Catalog.
Áp dụng cho Portal v1.2.2