Skip to content

Commit eb08965

Browse files
committed
feat(dagger): update release job to work with ttl.sh
1 parent 9a86603 commit eb08965

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

dagger/forge.go

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import (
55
"dagger/kv-2/internal/dagger"
66
"fmt"
77
"strings"
8+
9+
"github.com/google/uuid"
810
)
911

1012
// Run all pull request checks.
@@ -30,22 +32,32 @@ func (m *Kv2) Release(
3032
ctx context.Context,
3133
tag string,
3234
registry string,
35+
// +optional
36+
// +default="kv2"
3337
imageName string,
38+
// +optional
3439
username string,
40+
// +optional
3541
password *dagger.Secret,
36-
) error {
42+
) (string, error) {
3743
source := dag.Git("https://github.com/hugginsio/kv2.git", dagger.GitOpts{KeepGitDir: true}).Tag(tag).Tree()
3844
serverContainer := m.BuildServerContainer(ctx, source).
39-
WithLabel("org.opencontainers.image.version", tag).
40-
WithRegistryAuth(registry, username, password)
45+
WithLabel("org.opencontainers.image.version", tag)
46+
47+
if registry == "ttl.sh" {
48+
imageName = uuid.NewString()
49+
tag = "30m"
50+
} else {
51+
serverContainer = serverContainer.WithRegistryAuth(registry, username, password)
52+
}
4153

4254
if _, err := serverContainer.Publish(ctx, fmt.Sprintf("%s/%s:%s", registry, imageName, tag)); err != nil {
43-
return err
55+
return "", err
4456
}
4557

4658
if _, err := serverContainer.Publish(ctx, fmt.Sprintf("%s/%s:latest", registry, imageName)); err != nil {
47-
return err
59+
return "", err
4860
}
4961

50-
return nil
62+
return fmt.Sprintf("Successfully released %s/%s:%s", registry, imageName, tag), nil
5163
}

0 commit comments

Comments
 (0)