| | | 1 | | package domain |
| | | 2 | | |
| | | 3 | | // ReleaseMode defines whether the repository is released as a whole or per-project. |
| | | 4 | | type ReleaseMode string |
| | | 5 | | |
| | | 6 | | const ( |
| | | 7 | | // ReleaseModeRepo performs a single release for the entire repository. |
| | | 8 | | ReleaseModeRepo ReleaseMode = "repo" |
| | | 9 | | // ReleaseModeIndependent versions and releases each project independently. |
| | | 10 | | ReleaseModeIndependent ReleaseMode = "independent" |
| | | 11 | | ) |
| | | 12 | | |
| | | 13 | | // ProjectType describes how a project was discovered. |
| | | 14 | | type ProjectType string |
| | | 15 | | |
| | | 16 | | const ( |
| | | 17 | | // ProjectTypeGoWorkspace indicates the project was discovered via a go.work file. |
| | | 18 | | ProjectTypeGoWorkspace ProjectType = "go-workspace" |
| | | 19 | | // ProjectTypeGoModule indicates the project was discovered by finding a go.mod file. |
| | | 20 | | ProjectTypeGoModule ProjectType = "go-module" |
| | | 21 | | // ProjectTypeConfigured indicates the project was defined explicitly in the release config. |
| | | 22 | | ProjectTypeConfigured ProjectType = "configured" |
| | | 23 | | // ProjectTypeRoot indicates the project is at the repository root (no path prefix on tags). |
| | | 24 | | ProjectTypeRoot ProjectType = "root" |
| | | 25 | | // ProjectTypeCmdService indicates the project is a deployable binary under cmd/<name>. |
| | | 26 | | ProjectTypeCmdService ProjectType = "cmd-service" |
| | | 27 | | // ProjectTypeCmdLibrary indicates the project is a shared library package (e.g. pkg/<name>) |
| | | 28 | | // imported by one or more cmd services in a single-module monorepo. |
| | | 29 | | ProjectTypeCmdLibrary ProjectType = "cmd-library" |
| | | 30 | | ) |
| | | 31 | | |
| | | 32 | | // String returns the string representation of the release mode. |
| | | 33 | | func (m ReleaseMode) String() string { |
| | | 34 | | return string(m) |
| | | 35 | | } |
| | | 36 | | |
| | | 37 | | // String returns the string representation of the project type. |
| | | 38 | | func (pt ProjectType) String() string { |
| | | 39 | | return string(pt) |
| | | 40 | | } |
| | | 41 | | |
| | | 42 | | // Project represents a versioned unit within a repository. |
| | | 43 | | type Project struct { |
| | | 44 | | Name string |
| | | 45 | | // Path is the relative path from the repository root (e.g. "services/auth-server"). |
| | | 46 | | // It should always be a relative path; IsRoot handles ".", "", and "/" defensively. |
| | | 47 | | Path string |
| | | 48 | | Type ProjectType |
| | | 49 | | ModulePath string // Go module path if applicable |
| | | 50 | | Dependencies []string // names of projects this depends on |
| | | 51 | | TagPrefix string // e.g. "myproject/" for tags like "myproject/v1.2.3" |
| | | 52 | | ChangelogFile string // per-project changelog filename, relative to the project's path; empty means use global |
| | | 53 | | } |
| | | 54 | | |
| | | 55 | | // IsRoot returns true if this project represents the repository root. |
| | | 56 | | // The "/" case is defensive — Path should always be a relative path ("." or ""), |
| | | 57 | | // but we guard against an absolute-path misuse rather than silently misbehaving. |
| | 5 | 58 | | func (p Project) IsRoot() bool { |
| | 5 | 59 | | return p.Path == "." || p.Path == "" || p.Path == "/" |
| | 5 | 60 | | } |