Dart Deployment
This lesson covers production-ready deployment for Dart CLI, server, and web targets with repeatable CI/CD and rollback-safe releases.
Build Artifacts
Build once and deploy immutable artifacts. Never deploy directly from local unverified source.
# Verify quality gates
dart format --set-exit-if-changed .
dart analyze
dart test
# Compile executable (server/cli)
dart compile exe bin/server.dart -o build/server
# Compile web app
dart compile js web/main.dart -o build/main.js
Release Strategy
- Use semantic versioning and tag every production release.
- Promote the same artifact from staging to production.
- Store environment-specific secrets outside source control.
git tag v1.4.0
git push origin v1.4.0
CI/CD Pipeline
Automate lint, test, build, and deploy in one pipeline with manual approval gates for production.
name: dart-release
on:
push:
tags:
- 'v*'
jobs:
quality-and-build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dart-lang/setup-dart@v1
- run: dart pub get
- run: dart analyze
- run: dart test
- run: dart compile exe bin/server.dart -o build/server
Deploy Targets
Choose deployment by runtime profile:
- CLI tool: package binary and distribute through internal release registry.
- Server API: deploy executable behind reverse proxy/load balancer.
- Web build: publish static assets to CDN hosting.
Operations Checklist
- Define health endpoint and startup checks.
- Configure structured logging and metrics.
- Create rollback command and verify it in staging.
- Document incident ownership and escalation path.
Deployment Lab
- Compile a Dart executable and run smoke tests locally.
- Create a CI workflow that blocks deploy on failed analyze/test steps.
- Deploy to staging, validate logs, then promote to production.