Give delivery facade ownership of builds

This commit is contained in:
2026-10-06 18:23:55 +00:00
parent c9afc8dd12
commit a67a00a733
9 changed files with 605 additions and 38 deletions

View File

@@ -2,6 +2,7 @@ package releasekit
import (
"context"
"io"
internalbuild "gitea.maximumdirect.net/eric/ReleaseKit/internal/build"
internaldelivery "gitea.maximumdirect.net/eric/ReleaseKit/internal/delivery"
@@ -39,13 +40,21 @@ type DeliveryAsset struct {
}
// DeliveryRequest identifies a local tagged checkout and its explicit Gitea
// destination. Build is nil for page-only delivery.
// destination. Build selects a managed build; Prebuilt supplies caller-owned
// build output instead. They cannot both be set. Either may be nil for
// page-only delivery when both are nil. Build with no targets, or an empty
// Prebuilt result, also performs page-only delivery.
type DeliveryRequest struct {
RepositoryDir string
Product string
Version string
Destination GiteaDestination
Build *BuildResult
// Build selects binaries to build in temporary storage outside the checkout.
Build *BuildSpec
// Prebuilt supplies an existing build whose files remain caller-owned.
Prebuilt *BuildResult
// Output receives progress from a managed build.
Output io.Writer
}
// DeliveryResult reports hosted content and the state reached by this
@@ -70,23 +79,28 @@ type DeliveryResult struct {
}
// Deliver verifies the selected local tag and hosted source, then creates or
// finds its release page and adds any missing declared build assets.
// finds its release page and adds any missing declared build assets. Build
// requests are compiled into temporary storage that Deliver removes on return.
// Prebuilt artifacts remain caller-owned and are not removed. Both paths
// validate source identity and artifact contents before hosted writes.
func Deliver(ctx context.Context, request DeliveryRequest) (DeliveryResult, error) {
result := DeliveryResult{Version: request.Version, State: DeliveryNotAttempted}
var build *internalbuild.Result
if request.Build != nil {
build = internalBuildResult(*request.Build)
}
destination := gitea.Destination{
BaseURL: request.Destination.BaseURL, Owner: request.Destination.Owner,
Repository: request.Destination.Repository, Token: request.Destination.Token,
}
var prebuilt *internalbuild.Result
if request.Prebuilt != nil {
prebuilt = internalBuildResult(*request.Prebuilt)
}
internalResult, err := internaldelivery.Deliver(ctx, internaldelivery.Request{
RepositoryDir: request.RepositoryDir,
Product: request.Product,
Version: request.Version,
Destination: destination,
Build: build,
Build: internalBuildSpec(request.Build),
Prebuilt: prebuilt,
Output: request.Output,
})
result.CandidateCommit = internalResult.CandidateCommit
result.ReleaseURL = internalResult.ReleaseURL