Skip to content

Commit bbfa115

Browse files
authored
chore: fix release (#72)
1 parent c15a41b commit bbfa115

File tree

6 files changed

+166
-176
lines changed

6 files changed

+166
-176
lines changed

etc/scripts/workflows/release.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,16 @@ await $`${[
1414
"call",
1515
"--dir",
1616
workDirs.path,
17-
"--mode",
17+
"build-env",
18+
"with-env-variable",
19+
"--name",
20+
"MODE",
21+
"--value",
1822
$.env.MODE ?? "dev",
19-
"--gh-token",
23+
"with-secret-variable",
24+
"--name",
25+
"Gh_TOKEN",
26+
"--secret",
2027
"env:GH_TOKEN",
2128
"with-action",
2229
"--action",

etc/scripts/workflows/validate-pr.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ await $`${[
1515
"--dir",
1616
workDirs.path,
1717
"build-env",
18+
"with-env-variable",
19+
"--name",
20+
"MODE",
21+
"--value",
22+
"dev",
1823
"with-action",
1924
"--action",
2025
"test",

etc/templates/skeleton/etc/workflow-runtime/src/main.go

Lines changed: 1 addition & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -15,96 +15,15 @@
1515
package main
1616

1717
import (
18-
"context"
1918
"dagger/workflow_runtime/internal/dagger"
20-
"fmt"
2119
)
2220

2321
func New(
2422
// +required
2523
// +ignore=["node_modules/", ".moon/cache/", ".cache/"]
2624
dir *dagger.Directory,
27-
// +optional
28-
// +default="dev"
29-
mode string,
30-
// +optional
31-
ghToken *dagger.Secret,
3225
) *WorkflowRuntime {
3326
return &WorkflowRuntime{
34-
Dir: dir,
35-
Mode: mode,
36-
GhToken: ghToken,
27+
Dir: dir,
3728
}
3829
}
39-
40-
// Setup Proto
41-
func (m *WorkflowRuntime) BuildBaseEnv(ctx context.Context) *WorkflowRuntime {
42-
m.Con = dag.
43-
Container().
44-
From("ubuntu:plucky").
45-
// apt-get update && apt-get install -y curl git unzip gzip xz-utils
46-
WithExec([]string{"apt-get", "update"}).
47-
WithExec([]string{"apt-get", "install", "-y", "build-essential", "curl", "git", "unzip", "bash", "gzip", "xz-utils"}).
48-
// curl -fsSL https://moonrepo.dev/install/proto.sh | bash -s 0.35.3 --yes
49-
WithExec([]string{"bash", "-l", "-c", "curl -fsSL https://moonrepo.dev/install/proto.sh | bash -s 0.44.1 --yes"}).
50-
WithEnvVariable("PROTO_HOME", "/root/.proto", dagger.ContainerWithEnvVariableOpts{Expand: true}).
51-
WithEnvVariable("PATH", "$PATH:$PROTO_HOME/shims:$PROTO_HOME/bin", dagger.ContainerWithEnvVariableOpts{Expand: true})
52-
53-
return m
54-
}
55-
56-
func (m *WorkflowRuntime) BuildEnv(ctx context.Context) *WorkflowRuntime {
57-
source := dag.Directory().WithDirectory("/", m.Dir, dagger.DirectoryWithDirectoryOpts{
58-
Exclude: []string{"node_modules", ".cache", ".moon/cache"},
59-
})
60-
61-
m.Con = m.BuildBaseEnv(ctx).
62-
Con.
63-
WithWorkdir("/workspace").
64-
WithFile("/workspace/.prototools", m.Dir.File(".prototools")).
65-
// proto use
66-
WithExec([]string{"proto", "use"}).
67-
// rm .prototools
68-
WithoutFile("/workspace/.prototools").
69-
WithMountedDirectory("/workspace", source).
70-
// moon setup
71-
WithExec([]string{"moon", "setup"}).
72-
// yarn install --immutable
73-
WithExec([]string{"yarn", "install", "--immutable"})
74-
75-
m = m.setEnvs(ctx)
76-
77-
return m
78-
}
79-
80-
func (m *WorkflowRuntime) WithAction(ctx context.Context, action string) *WorkflowRuntime {
81-
m.Con = m.Con.WithExec([]string{"bash", "-l", "-c", fmt.Sprintf("./etc/scripts/actions/%s.ts", action)})
82-
83-
return m
84-
}
85-
86-
func (m *WorkflowRuntime) Container(ctx context.Context) *dagger.Container {
87-
return m.Con
88-
}
89-
90-
func (m *WorkflowRuntime) Stdout(ctx context.Context) (string, error) {
91-
stdout, err := m.Con.Stdout(ctx)
92-
if err != nil {
93-
return "", fmt.Errorf("failed to get stdout: %w", err)
94-
}
95-
return stdout, nil
96-
}
97-
98-
func (m *WorkflowRuntime) setEnvs(ctx context.Context) *WorkflowRuntime {
99-
m.Con = m.Con.
100-
WithEnvVariable("MODE", m.Mode)
101-
102-
if m.GhToken != nil {
103-
tokenString, _ := m.GhToken.Plaintext(ctx)
104-
105-
m.Con = m.Con.
106-
WithEnvVariable("GH_TOKEN", tokenString)
107-
}
108-
109-
return m
110-
}
Lines changed: 75 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,80 @@
11
package main
22

3-
import "dagger/workflow_runtime/internal/dagger"
3+
import (
4+
"context"
5+
"dagger/workflow_runtime/internal/dagger"
6+
"fmt"
7+
)
48

59
type WorkflowRuntime struct {
6-
Dir *dagger.Directory
7-
Mode string
8-
GhToken *dagger.Secret
9-
Con *dagger.Container
10+
Dir *dagger.Directory
11+
Con *dagger.Container
12+
}
13+
14+
// Setup Proto
15+
func (m *WorkflowRuntime) BuildBaseEnv(ctx context.Context) *WorkflowRuntime {
16+
m.Con = dag.
17+
Container().
18+
From("ubuntu:plucky").
19+
// apt-get update && apt-get install -y curl git unzip gzip xz-utils
20+
WithExec([]string{"apt-get", "update"}).
21+
WithExec([]string{"apt-get", "install", "-y", "build-essential", "curl", "git", "unzip", "bash", "gzip", "xz-utils"}).
22+
// curl -fsSL https://moonrepo.dev/install/proto.sh | bash -s 0.35.3 --yes
23+
WithExec([]string{"bash", "-l", "-c", "curl -fsSL https://moonrepo.dev/install/proto.sh | bash -s 0.44.1 --yes"}).
24+
WithEnvVariable("PROTO_HOME", "/root/.proto", dagger.ContainerWithEnvVariableOpts{Expand: true}).
25+
WithEnvVariable("PATH", "$PATH:$PROTO_HOME/shims:$PROTO_HOME/bin", dagger.ContainerWithEnvVariableOpts{Expand: true})
26+
27+
return m
28+
}
29+
30+
func (m *WorkflowRuntime) BuildEnv(ctx context.Context) *WorkflowRuntime {
31+
source := dag.Directory().WithDirectory("/", m.Dir, dagger.DirectoryWithDirectoryOpts{
32+
Exclude: []string{"node_modules", ".cache", ".moon/cache"},
33+
})
34+
35+
m.Con = m.BuildBaseEnv(ctx).
36+
Con.
37+
WithWorkdir("/workspace").
38+
WithFile("/workspace/.prototools", m.Dir.File(".prototools")).
39+
// proto use
40+
WithExec([]string{"proto", "use"}).
41+
// rm .prototools
42+
WithoutFile("/workspace/.prototools").
43+
WithMountedDirectory("/workspace", source).
44+
// moon setup
45+
WithExec([]string{"moon", "setup"}).
46+
// yarn install --immutable
47+
WithExec([]string{"yarn", "install", "--immutable"})
48+
49+
return m
50+
}
51+
52+
func (m *WorkflowRuntime) WithAction(ctx context.Context, action string) *WorkflowRuntime {
53+
m.Con = m.Con.WithExec([]string{"bash", "-l", "-c", fmt.Sprintf("./etc/scripts/actions/%s.ts", action)})
54+
55+
return m
56+
}
57+
58+
func (m *WorkflowRuntime) Container(ctx context.Context) *dagger.Container {
59+
return m.Con
60+
}
61+
62+
func (m *WorkflowRuntime) Stdout(ctx context.Context) (string, error) {
63+
stdout, err := m.Con.Stdout(ctx)
64+
if err != nil {
65+
return "", fmt.Errorf("failed to get stdout: %w", err)
66+
}
67+
return stdout, nil
68+
}
69+
70+
func (m *WorkflowRuntime) WithEnvVariable(name, value string) *WorkflowRuntime {
71+
m.Con = m.Con.WithEnvVariable(name, value)
72+
73+
return m
74+
}
75+
76+
func (m *WorkflowRuntime) WithSecretVariable(name string, secret *dagger.Secret) *WorkflowRuntime {
77+
m.Con = m.Con.WithSecretVariable(name, secret)
78+
79+
return m
1080
}

etc/workflow-runtime/src/main.go

Lines changed: 1 addition & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -15,96 +15,15 @@
1515
package main
1616

1717
import (
18-
"context"
1918
"dagger/workflow_runtime/internal/dagger"
20-
"fmt"
2119
)
2220

2321
func New(
2422
// +required
2523
// +ignore=["node_modules/", ".moon/cache/", ".cache/"]
2624
dir *dagger.Directory,
27-
// +optional
28-
// +default="dev"
29-
mode string,
30-
// +optional
31-
ghToken *dagger.Secret,
3225
) *WorkflowRuntime {
3326
return &WorkflowRuntime{
34-
Dir: dir,
35-
Mode: mode,
36-
GhToken: ghToken,
27+
Dir: dir,
3728
}
3829
}
39-
40-
// Setup Proto
41-
func (m *WorkflowRuntime) BuildBaseEnv(ctx context.Context) *WorkflowRuntime {
42-
m.Con = dag.
43-
Container().
44-
From("ubuntu:plucky").
45-
// apt-get update && apt-get install -y curl git unzip gzip xz-utils
46-
WithExec([]string{"apt-get", "update"}).
47-
WithExec([]string{"apt-get", "install", "-y", "build-essential", "curl", "git", "unzip", "bash", "gzip", "xz-utils"}).
48-
// curl -fsSL https://moonrepo.dev/install/proto.sh | bash -s 0.35.3 --yes
49-
WithExec([]string{"bash", "-l", "-c", "curl -fsSL https://moonrepo.dev/install/proto.sh | bash -s 0.44.1 --yes"}).
50-
WithEnvVariable("PROTO_HOME", "/root/.proto", dagger.ContainerWithEnvVariableOpts{Expand: true}).
51-
WithEnvVariable("PATH", "$PATH:$PROTO_HOME/shims:$PROTO_HOME/bin", dagger.ContainerWithEnvVariableOpts{Expand: true})
52-
53-
return m
54-
}
55-
56-
func (m *WorkflowRuntime) BuildEnv(ctx context.Context) *WorkflowRuntime {
57-
source := dag.Directory().WithDirectory("/", m.Dir, dagger.DirectoryWithDirectoryOpts{
58-
Exclude: []string{"node_modules", ".cache", ".moon/cache"},
59-
})
60-
61-
m.Con = m.BuildBaseEnv(ctx).
62-
Con.
63-
WithWorkdir("/workspace").
64-
WithFile("/workspace/.prototools", m.Dir.File(".prototools")).
65-
// proto use
66-
WithExec([]string{"proto", "use"}).
67-
// rm .prototools
68-
WithoutFile("/workspace/.prototools").
69-
WithMountedDirectory("/workspace", source).
70-
// moon setup
71-
WithExec([]string{"moon", "setup"}).
72-
// yarn install --immutable
73-
WithExec([]string{"yarn", "install", "--immutable"})
74-
75-
m = m.setEnvs(ctx)
76-
77-
return m
78-
}
79-
80-
func (m *WorkflowRuntime) WithAction(ctx context.Context, action string) *WorkflowRuntime {
81-
m.Con = m.Con.WithExec([]string{"bash", "-l", "-c", fmt.Sprintf("./etc/scripts/actions/%s.ts", action)})
82-
83-
return m
84-
}
85-
86-
func (m *WorkflowRuntime) Container(ctx context.Context) *dagger.Container {
87-
return m.Con
88-
}
89-
90-
func (m *WorkflowRuntime) Stdout(ctx context.Context) (string, error) {
91-
stdout, err := m.Con.Stdout(ctx)
92-
if err != nil {
93-
return "", fmt.Errorf("failed to get stdout: %w", err)
94-
}
95-
return stdout, nil
96-
}
97-
98-
func (m *WorkflowRuntime) setEnvs(ctx context.Context) *WorkflowRuntime {
99-
m.Con = m.Con.
100-
WithEnvVariable("MODE", m.Mode)
101-
102-
if m.GhToken != nil {
103-
tokenString, _ := m.GhToken.Plaintext(ctx)
104-
105-
m.Con = m.Con.
106-
WithEnvVariable("GH_TOKEN", tokenString)
107-
}
108-
109-
return m
110-
}
Lines changed: 75 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,80 @@
11
package main
22

3-
import "dagger/workflow_runtime/internal/dagger"
3+
import (
4+
"context"
5+
"dagger/workflow_runtime/internal/dagger"
6+
"fmt"
7+
)
48

59
type WorkflowRuntime struct {
6-
Dir *dagger.Directory
7-
Mode string
8-
GhToken *dagger.Secret
9-
Con *dagger.Container
10+
Dir *dagger.Directory
11+
Con *dagger.Container
12+
}
13+
14+
// Setup Proto
15+
func (m *WorkflowRuntime) BuildBaseEnv(ctx context.Context) *WorkflowRuntime {
16+
m.Con = dag.
17+
Container().
18+
From("ubuntu:plucky").
19+
// apt-get update && apt-get install -y curl git unzip gzip xz-utils
20+
WithExec([]string{"apt-get", "update"}).
21+
WithExec([]string{"apt-get", "install", "-y", "build-essential", "curl", "git", "unzip", "bash", "gzip", "xz-utils"}).
22+
// curl -fsSL https://moonrepo.dev/install/proto.sh | bash -s 0.35.3 --yes
23+
WithExec([]string{"bash", "-l", "-c", "curl -fsSL https://moonrepo.dev/install/proto.sh | bash -s 0.44.1 --yes"}).
24+
WithEnvVariable("PROTO_HOME", "/root/.proto", dagger.ContainerWithEnvVariableOpts{Expand: true}).
25+
WithEnvVariable("PATH", "$PATH:$PROTO_HOME/shims:$PROTO_HOME/bin", dagger.ContainerWithEnvVariableOpts{Expand: true})
26+
27+
return m
28+
}
29+
30+
func (m *WorkflowRuntime) BuildEnv(ctx context.Context) *WorkflowRuntime {
31+
source := dag.Directory().WithDirectory("/", m.Dir, dagger.DirectoryWithDirectoryOpts{
32+
Exclude: []string{"node_modules", ".cache", ".moon/cache"},
33+
})
34+
35+
m.Con = m.BuildBaseEnv(ctx).
36+
Con.
37+
WithWorkdir("/workspace").
38+
WithFile("/workspace/.prototools", m.Dir.File(".prototools")).
39+
// proto use
40+
WithExec([]string{"proto", "use"}).
41+
// rm .prototools
42+
WithoutFile("/workspace/.prototools").
43+
WithMountedDirectory("/workspace", source).
44+
// moon setup
45+
WithExec([]string{"moon", "setup"}).
46+
// yarn install --immutable
47+
WithExec([]string{"yarn", "install", "--immutable"})
48+
49+
return m
50+
}
51+
52+
func (m *WorkflowRuntime) WithAction(ctx context.Context, action string) *WorkflowRuntime {
53+
m.Con = m.Con.WithExec([]string{"bash", "-l", "-c", fmt.Sprintf("./etc/scripts/actions/%s.ts", action)})
54+
55+
return m
56+
}
57+
58+
func (m *WorkflowRuntime) Container(ctx context.Context) *dagger.Container {
59+
return m.Con
60+
}
61+
62+
func (m *WorkflowRuntime) Stdout(ctx context.Context) (string, error) {
63+
stdout, err := m.Con.Stdout(ctx)
64+
if err != nil {
65+
return "", fmt.Errorf("failed to get stdout: %w", err)
66+
}
67+
return stdout, nil
68+
}
69+
70+
func (m *WorkflowRuntime) WithEnvVariable(name, value string) *WorkflowRuntime {
71+
m.Con = m.Con.WithEnvVariable(name, value)
72+
73+
return m
74+
}
75+
76+
func (m *WorkflowRuntime) WithSecretVariable(name string, secret *dagger.Secret) *WorkflowRuntime {
77+
m.Con = m.Con.WithSecretVariable(name, secret)
78+
79+
return m
1080
}

0 commit comments

Comments
 (0)