This document describes how to build, test, and release makemigrations.
- Go 1.21 or later
- Git
- Make (optional, but recommended)
- Python 3 and pip (for bumpversion - optional, for automated releases)
pip install bumpversion# Go linting and security tools
go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
go install golang.org/x/vuln/cmd/govulncheck@latest
go install github.com/securecodewarrior/gosec/v2/cmd/gosec@latestmake buildmake testmake dev # format, vet, lint, test, build| Target | Description |
|---|---|
make build |
Build for current platform |
make release-build |
Build for all platforms |
make test |
Run tests |
make test-coverage |
Run tests with coverage report |
make clean |
Clean build artifacts |
make deps |
Get dependencies |
make deps-update |
Update dependencies |
make fmt |
Format code |
make lint |
Run linter |
make vet |
Run go vet |
make security |
Run security checks |
make install |
Install locally |
make dev |
Development workflow |
make ci |
CI workflow |
make run ARGS="--help" |
Build and run |
make version |
Show version info |
make bump-patch |
Bump patch version |
make bump-minor |
Bump minor version |
make bump-major |
Bump major version |
make bump-*-dry |
Preview version bumps |
go build -ldflags="-s -w" -o makemigrations .# Linux
GOOS=linux GOARCH=amd64 go build -o makemigrations-linux-amd64 .
# macOS
GOOS=darwin GOARCH=amd64 go build -o makemigrations-darwin-amd64 .
# Windows
GOOS=windows GOARCH=amd64 go build -o makemigrations-windows-amd64.exe .VERSION=$(git describe --tags --always --dirty)
BUILD_DATE=$(date -u +%Y-%m-%dT%H:%M:%SZ)
GIT_COMMIT=$(git rev-parse --short HEAD)
go build \
-ldflags="-s -w \
-X github.com/ocomsoft/makemigrations/internal/version.Version=$VERSION \
-X github.com/ocomsoft/makemigrations/internal/version.BuildDate=$BUILD_DATE \
-X github.com/ocomsoft/makemigrations/internal/version.GitCommit=$GIT_COMMIT" \
-o makemigrations .go test -v ./...go test -v -race -coverprofile=coverage.out ./...
go tool cover -html=coverage.out -o coverage.htmlgo test -v ./cmd
go test -v ./internal/yamlgo fmt ./...# Install golangci-lint if not already installed
go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
# Run linter
golangci-lint rungo vet ./...# Install security tools
go install golang.org/x/vuln/cmd/govulncheck@latest
go install github.com/securecodewarrior/gosec/v2/cmd/gosec@latest
# Run checks
govulncheck ./...
gosec ./...-
Bump version automatically:
# Preview what will change make bump-patch-dry # or bump-minor-dry, bump-major-dry # Actually bump the version make bump-patch # or bump-minor, bump-major # Push to trigger release git push origin main --tags
-
Alternative using script directly:
# Preview changes ./scripts/bump-version.sh minor --dry-run # Bump version ./scripts/bump-version.sh minor # Push to trigger release git push origin main --tags
- Go to GitHub Actions:
- Navigate to "Bump Version" workflow
- Click "Run workflow"
- Select version part (patch/minor/major)
- Optionally create prerelease
- Click "Run workflow"
- Create and push a tag:
git tag v1.0.0 git push origin v1.0.0
GitHub Actions will automatically:
- Run tests
- Build for all platforms
- Generate checksums
- Create a GitHub release
- Upload binaries
-
Update version and create tag:
# Update version in internal/version/version.go if needed git tag v1.0.0 git push origin v1.0.0 -
Build release binaries:
make release-build
-
Create release on GitHub:
- Go to GitHub releases page
- Create new release
- Upload files from
dist/directory - Include
checksums.txt
The build system supports the following platforms:
| OS | Architecture | Binary Name |
|---|---|---|
| Linux | amd64 | makemigrations-linux-amd64 |
| Linux | arm64 | makemigrations-linux-arm64 |
| macOS | amd64 (Intel) | makemigrations-darwin-amd64 |
| macOS | arm64 (Apple Silicon) | makemigrations-darwin-arm64 |
| Windows | amd64 | makemigrations-windows-amd64.exe |
| Windows | arm64 | makemigrations-windows-arm64.exe |
- Runs on every push to main/develop
- Runs tests and builds for all platforms
- Includes linting and security checks
- Triggers on tag push (v*)
- Builds for all platforms
- Creates GitHub release with binaries
- Generates checksums and release notes
- Runs weekly and on pushes
- Vulnerability scanning with govulncheck
- Security analysis with gosec
- Runs weekly
- Updates Go dependencies
- Creates PR with changes
Version information is embedded at build time using Go's ldflags:
Version: Git tag or commit hashBuildDate: Build timestamp (ISO 8601)GitCommit: Short git commit hash
Check version:
./makemigrations version
./makemigrations version --build-info
./makemigrations version --format jsonModule not found:
go mod download
go mod tidyBuild fails on older Go versions:
- Ensure Go 1.21+ is installed
- Check
go.modfor minimum version
Cross-compilation issues:
# Clear module cache
go clean -modcache
# Rebuild
make clean
make buildTests fail:
# Run with verbose output
go test -v ./...
# Run specific test
go test -v ./cmd -run TestSpecificFunctionCoverage reports:
make test-coverage
# Open coverage.html in browser- Fork the repository
- Create feature branch
- Run tests:
make test - Run CI checks:
make ci - Submit pull request
The CI workflow will automatically run tests and builds for all platforms.