Inspect hosted assets against build manifests

This commit is contained in:
2026-10-05 19:56:32 +00:00
parent 717d6d0d04
commit 692a503c26
9 changed files with 695 additions and 13 deletions

39
delivery_assets.go Normal file
View File

@@ -0,0 +1,39 @@
package releasekit
import (
"fmt"
"os"
"path/filepath"
"gitea.maximumdirect.net/eric/ReleaseKit/internal/gitea"
)
func declaredBuildAssets(result BuildResult) ([]gitea.ExpectedAsset, error) {
assets := make([]gitea.ExpectedAsset, 0, len(result.Artifacts)+1)
for _, artifact := range result.Artifacts {
if filepath.Base(artifact.Path) != artifact.Filename {
return nil, fmt.Errorf("build artifact path %q does not end with filename %q", artifact.Path, artifact.Filename)
}
info, err := os.Stat(artifact.Path)
if err != nil {
return nil, fmt.Errorf("inspect build artifact %q: %w", artifact.Filename, err)
}
if !info.Mode().IsRegular() {
return nil, fmt.Errorf("build artifact %q is not a regular file", artifact.Filename)
}
assets = append(assets, gitea.ExpectedAsset{
Filename: artifact.Filename,
SHA256: artifact.SHA256,
Size: info.Size(),
Path: artifact.Path,
})
}
manifest, err := gitea.BuildManifest(assets)
if err != nil {
return nil, fmt.Errorf("build checksum manifest: %w", err)
}
if manifest.Filename != "" {
assets = append(assets, manifest)
}
return assets, nil
}