@@ -34,30 +34,26 @@ func (m *HarborCli) PublishImageAndSign(
3434 }
3535 }
3636
37- return dag .Container ().From ("alpine:latest" ).WithDirectory ("dist" , buildDir ).
38- WithWorkdir ("dist" ).
39- WithExec ([]string {"find" , "." , "-type" , "f" }).Stdout (ctx )
40-
41- // imageAddrs, err := m.PublishImage(ctx, registry, registryUsername, strings.Split(imageTags, ","), buildDir, source, registryPassword)
42- // if err != nil {
43- // return "", err
44- // }
45- //
46- // _, err = m.Sign(
47- // ctx,
48- // githubToken,
49- // actionsIdTokenRequestUrl,
50- // actionsIdTokenRequestToken,
51- // registryUsername,
52- // registryPassword,
53- // imageAddrs[0],
54- // )
55- // if err != nil {
56- // return "", fmt.Errorf("failed to sign image: %w", err)
57- // }
58- //
59- // fmt.Printf("Signed image: %s\n", imageAddrs)
60- // return imageAddrs[0], nil
37+ imageAddrs , err := m .PublishImage (ctx , registry , registryUsername , strings .Split (imageTags , "," ), buildDir , source , registryPassword )
38+ if err != nil {
39+ return "" , err
40+ }
41+
42+ _ , err = m .Sign (
43+ ctx ,
44+ githubToken ,
45+ actionsIdTokenRequestUrl ,
46+ actionsIdTokenRequestToken ,
47+ registryUsername ,
48+ registryPassword ,
49+ imageAddrs [0 ],
50+ )
51+ if err != nil {
52+ return "" , fmt .Errorf ("failed to sign image: %w" , err )
53+ }
54+
55+ fmt .Printf ("Signed image: %s\n " , imageAddrs )
56+ return imageAddrs [0 ], nil
6157}
6258
6359func (m * HarborCli ) PublishImage (
@@ -134,9 +130,10 @@ func (m *HarborCli) PublishImage(
134130 ctr := dag .Container (dagger.ContainerOpts {Platform : dagger .Platform ("linux/" + arch )}).
135131 From ("alpine:latest" ).
136132 WithWorkdir ("/" ).
137- WithFile ("/harbor" , buildDir .File (filepath )).
133+ WithFile (". /harbor" , buildDir .File (filepath )).
138134 WithExec ([]string {"ls" , "-al" }).
139- WithExec ([]string {"/harbor" , "version" }).
135+ WithExec ([]string {"chmod" , "+x" , "/harbor" }).
136+ WithExec ([]string {"./harbor" , "version" }).
140137 // Add required metadata labels for ArtifactHub
141138 WithLabel ("org.opencontainers.image.created" , creationTime ).
142139 WithLabel ("org.opencontainers.image.description" , "Harbor CLI - A command-line interface for CNCF Harbor, the cloud native registry!" ).
0 commit comments