cli + tui to publish to leaflet (wip) & manage tasks, notes & watch/read lists 🍃
charm leaflet readability golang
at main 167 lines 2.9 kB view raw view rendered
1--- 2title: Building Noteleaf 3sidebar_label: Building 4sidebar_position: 1 5description: Build configurations and development workflows. 6--- 7 8# Building Noteleaf 9 10Noteleaf uses [Task](https://taskfile.dev) for build automation, providing consistent workflows across development, testing, and releases. 11 12## Prerequisites 13 14- Go 1.21 or later 15- [Task](https://taskfile.dev) (install via `brew install go-task/tap/go-task` on macOS) 16- Git (for version information) 17 18## Build Types 19 20### Development Build 21 22Quick build without version injection for local development: 23 24```sh 25task build 26``` 27 28Output: `./tmp/noteleaf` 29 30### Development Build with Version 31 32Build with git commit hash and development tools enabled: 33 34```sh 35task build:dev 36``` 37 38Version format: `git describe` output (e.g., `v0.1.0-15-g1234abc`) 39Output: `./tmp/noteleaf` 40 41### Release Candidate Build 42 43Build with `-rc` tag, excludes development tools: 44 45```sh 46git tag v1.0.0-rc1 47task build:rc 48``` 49 50Requirements: 51 52- Clean git tag with `-rc` suffix 53- Tag format: `v1.0.0-rc1`, `v2.1.0-rc2`, etc. 54 55### Production Build 56 57Build for release with strict validation: 58 59```sh 60git tag v1.0.0 61task build:prod 62``` 63 64Requirements: 65 66- Clean semver git tag (e.g., `v1.0.0`, `v2.1.3`) 67- No uncommitted changes 68- No prerelease suffix 69 70## Build Tags 71 72Production builds use the `prod` build tag to exclude development and seed commands: 73 74```go 75//go:build !prod 76``` 77 78Commands excluded from production: 79 80- `noteleaf dev` - Development utilities 81- `noteleaf seed` - Test data generation 82 83## Version Information 84 85Build process injects version metadata via ldflags: 86 87```go 88// internal/version/version.go 89var ( 90 Version = "dev" // Git tag or "dev" 91 Commit = "none" // Git commit hash 92 BuildDate = "unknown" // Build timestamp 93) 94``` 95 96View version information: 97 98```sh 99task version:show 100noteleaf version 101``` 102 103## Build Artifacts 104 105All binaries are built to `./tmp/` directory: 106 107``` 108tmp/ 109└── noteleaf # Binary for current platform 110``` 111 112## Development Workflow 113 114Full development cycle with linting and testing: 115 116```sh 117task dev 118``` 119 120Runs: 121 1221. Clean build artifacts 1232. Run linters (vet, fmt) 1243. Execute all tests 1254. Build binary 126 127## Manual Build 128 129Build directly with Go (bypasses Task automation): 130 131```sh 132go build -o ./tmp/noteleaf ./cmd 133``` 134 135With version injection: 136 137```sh 138go build -ldflags "-X github.com/stormlightlabs/noteleaf/internal/version.Version=v1.0.0" -o ./tmp/noteleaf ./cmd 139``` 140 141## Cross-Platform Builds 142 143Build for specific platforms: 144 145```sh 146# Linux 147GOOS=linux GOARCH=amd64 go build -o ./tmp/noteleaf-linux ./cmd 148 149# Windows 150GOOS=windows GOARCH=amd64 go build -o ./tmp/noteleaf.exe ./cmd 151 152# macOS (ARM) 153GOOS=darwin GOARCH=arm64 go build -o ./tmp/noteleaf-darwin-arm64 ./cmd 154``` 155 156## Clean Build 157 158Remove all build artifacts: 159 160```sh 161task clean 162``` 163 164Removes: 165 166- `./tmp/` directory 167- `coverage.out` and `coverage.html`