feat: build runtime releases from pinned Git branch commits

This commit is contained in:
2026-10-14 14:25:27 +08:00
parent 9a71772771
commit 20635ffaec
23 changed files with 999 additions and 31 deletions
+12
View File
@@ -190,11 +190,23 @@ func (c *Client) Logs(ctx context.Context, id string) (string, error) {
}
func (c *Client) Build(ctx context.Context, tar io.Reader, version, tag string, onLog func(string)) (string, error) {
return c.build(ctx, tar, version, tag, nil, onLog)
}
func (c *Client) BuildRelease(ctx context.Context, tar io.Reader, version, tag, releaseID, repository, commit string, onLog func(string)) (string, error) {
return c.build(ctx, tar, version, tag, map[string]string{"dsh-mgr.release": releaseID, "dsh-mgr.source": repository, "dsh-mgr.commit": commit}, onLog)
}
func (c *Client) build(ctx context.Context, tar io.Reader, version, tag string, labels map[string]string, onLog func(string)) (string, error) {
args, err := json.Marshal(map[string]string{"DSH_VERSION": version})
if err != nil {
return "", err
}
query := url.Values{"t": {tag}, "buildargs": {string(args)}, "rm": {"1"}}
if labels != nil {
data, _ := json.Marshal(labels)
query.Set("labels", string(data))
}
resp, err := c.Stream(ctx, http.MethodPost, "/build?"+query.Encode(), tar, "application/x-tar")
if err != nil {
return "", err