52 lines
1.9 KiB
Go
52 lines
1.9 KiB
Go
package releasekit
|
|
|
|
import "go.maximumdirect.net/releasekit/internal/releaseidentity"
|
|
|
|
// PublicationMode selects the distribution contract for a source release.
|
|
type PublicationMode string
|
|
|
|
const (
|
|
// PublicationSource selects a general source release.
|
|
PublicationSource PublicationMode = "source"
|
|
// PublicationGoModule selects Go module publication and requires GoEnabled.
|
|
PublicationGoModule PublicationMode = "go-module"
|
|
)
|
|
|
|
// VersionFormat selects the grammar of a release identifier.
|
|
type VersionFormat string
|
|
|
|
const (
|
|
// VersionSemver selects stable semantic versions.
|
|
VersionSemver VersionFormat = "semver"
|
|
// VersionDate selects Gregorian dates with an optional revision.
|
|
VersionDate VersionFormat = "date"
|
|
// VersionYearMonth selects a year, month, and revision.
|
|
VersionYearMonth VersionFormat = "year-month"
|
|
)
|
|
|
|
// SourceSpec explicitly selects a source scope and its release capabilities.
|
|
// An empty Dir selects ModuleDir if supplied, otherwise the repository root.
|
|
// A nil VersionPrefix selects the format default; a nil TagPrefix derives the
|
|
// source tag prefix from the physical source directory.
|
|
type SourceSpec struct {
|
|
Dir string // repository-relative source directory.
|
|
GoEnabled bool // select Go module validation and build capabilities.
|
|
// Publication defaults to PublicationSource for an explicit selection.
|
|
Publication PublicationMode
|
|
// VersionFormat defaults to VersionSemver.
|
|
VersionFormat VersionFormat
|
|
// VersionPrefix may be "v" or ""; nil uses the selected format's default.
|
|
VersionPrefix *string
|
|
TagPrefix *string // nil derives the prefix; a pointer to "" removes it.
|
|
}
|
|
|
|
func internalSourceSpec(source *SourceSpec) *releaseidentity.SourceSpec {
|
|
if source == nil {
|
|
return nil
|
|
}
|
|
return &releaseidentity.SourceSpec{
|
|
Dir: source.Dir, GoEnabled: source.GoEnabled, Publication: string(source.Publication),
|
|
VersionFormat: string(source.VersionFormat), VersionPrefix: source.VersionPrefix, TagPrefix: source.TagPrefix,
|
|
}
|
|
}
|