@@ -38,14 +38,21 @@ func (m *HttpNu) DarwinEnv(
3838 )
3939}
4040
41- func (m * HttpNu ) DarwinBuild (ctx context.Context , src * dagger.Directory ) * dagger.File {
42- return m .DarwinEnv (ctx , src ).
41+ func (m * HttpNu ) DarwinBuild (ctx context.Context , src * dagger.Directory , version string ) * dagger.File {
42+ container := m .DarwinEnv (ctx , src ).
4343 WithExec ([]string {"rustup" , "update" , "stable" }).
4444 WithExec ([]string {"rustup" , "default" , "stable" }).
4545 WithExec ([]string {"rustup" , "target" , "add" , "aarch64-apple-darwin" }).
46- WithExec ([]string {"./scripts/cross-build-darwin.sh" , "--release" }).
47- WithExec ([]string {"tar" , "-czf" , "/tmp/http-nu-darwin-arm64.tar.gz" , "-C" , "/app/target/aarch64-apple-darwin/release" , "http-nu" }).
48- File ("/tmp/http-nu-darwin-arm64.tar.gz" )
46+ WithExec ([]string {"./scripts/cross-build-darwin.sh" , "--release" })
47+
48+ container = container .WithExec ([]string {"sh" , "-c" , `
49+ mkdir -p /tmp/http-nu-` + version + `
50+ cp /app/target/aarch64-apple-darwin/release/http-nu /tmp/http-nu-` + version + `/
51+ cd /tmp
52+ tar -czf http-nu-` + version + `-darwin-arm64.tar.gz http-nu-` + version + `
53+ ` })
54+
55+ return container .File ("/tmp/http-nu-" + version + "-darwin-arm64.tar.gz" )
4956}
5057
5158func (m * HttpNu ) WindowsEnv (
@@ -71,15 +78,22 @@ func (m *HttpNu) WindowsEnv(
7178 )
7279}
7380
74- func (m * HttpNu ) WindowsBuild (ctx context.Context , src * dagger.Directory ) * dagger.File {
75- return m .WindowsEnv (ctx , src ).
81+ func (m * HttpNu ) WindowsBuild (ctx context.Context , src * dagger.Directory , version string ) * dagger.File {
82+ container := m .WindowsEnv (ctx , src ).
7683 WithExec ([]string {"rustup" , "update" , "stable" }).
7784 WithExec ([]string {"rustup" , "default" , "stable" }).
7885 WithExec ([]string {"rustup" , "target" , "add" , "x86_64-pc-windows-gnu" }).
7986 WithExec ([]string {"cargo" , "check" , "--release" , "--tests" , "--target" , "x86_64-pc-windows-gnu" }).
80- WithExec ([]string {"cargo" , "build" , "--release" , "--target" , "x86_64-pc-windows-gnu" }).
81- WithExec ([]string {"tar" , "-czf" , "/tmp/http-nu-windows-amd64.tar.gz" , "-C" , "/app/target/x86_64-pc-windows-gnu/release" , "http-nu.exe" }).
82- File ("/tmp/http-nu-windows-amd64.tar.gz" )
87+ WithExec ([]string {"cargo" , "build" , "--release" , "--target" , "x86_64-pc-windows-gnu" })
88+
89+ container = container .WithExec ([]string {"sh" , "-c" , `
90+ mkdir -p /tmp/http-nu-` + version + `
91+ cp /app/target/x86_64-pc-windows-gnu/release/http-nu.exe /tmp/http-nu-` + version + `/
92+ cd /tmp
93+ tar -czf http-nu-` + version + `-windows-amd64.tar.gz http-nu-` + version + `
94+ ` })
95+
96+ return container .File ("/tmp/http-nu-" + version + "-windows-amd64.tar.gz" )
8397}
8498
8599func (m * HttpNu ) LinuxArm64Env (
@@ -94,11 +108,18 @@ func (m *HttpNu) LinuxArm64Env(
94108 )
95109}
96110
97- func (m * HttpNu ) LinuxArm64Build (ctx context.Context , src * dagger.Directory ) * dagger.File {
98- return m .LinuxArm64Env (ctx , src ).
99- WithExec ([]string {"cargo" , "build" , "--release" , "--target" , "aarch64-unknown-linux-musl" }).
100- WithExec ([]string {"tar" , "-czf" , "/tmp/http-nu-linux-arm64.tar.gz" , "-C" , "/app/target/aarch64-unknown-linux-musl/release" , "http-nu" }).
101- File ("/tmp/http-nu-linux-arm64.tar.gz" )
111+ func (m * HttpNu ) LinuxArm64Build (ctx context.Context , src * dagger.Directory , version string ) * dagger.File {
112+ container := m .LinuxArm64Env (ctx , src ).
113+ WithExec ([]string {"cargo" , "build" , "--release" , "--target" , "aarch64-unknown-linux-musl" })
114+
115+ container = container .WithExec ([]string {"sh" , "-c" , `
116+ mkdir -p /tmp/http-nu-` + version + `
117+ cp /app/target/aarch64-unknown-linux-musl/release/http-nu /tmp/http-nu-` + version + `/
118+ cd /tmp
119+ tar -czf http-nu-` + version + `-linux-arm64.tar.gz http-nu-` + version + `
120+ ` })
121+
122+ return container .File ("/tmp/http-nu-" + version + "-linux-arm64.tar.gz" )
102123}
103124
104125func (m * HttpNu ) LinuxAmd64Env (
@@ -113,9 +134,16 @@ func (m *HttpNu) LinuxAmd64Env(
113134 )
114135}
115136
116- func (m * HttpNu ) LinuxAmd64Build (ctx context.Context , src * dagger.Directory ) * dagger.File {
117- return m .LinuxAmd64Env (ctx , src ).
118- WithExec ([]string {"cargo" , "build" , "--release" , "--target" , "x86_64-unknown-linux-musl" }).
119- WithExec ([]string {"tar" , "-czf" , "/tmp/http-nu-linux-amd64.tar.gz" , "-C" , "/app/target/x86_64-unknown-linux-musl/release" , "http-nu" }).
120- File ("/tmp/http-nu-linux-amd64.tar.gz" )
137+ func (m * HttpNu ) LinuxAmd64Build (ctx context.Context , src * dagger.Directory , version string ) * dagger.File {
138+ container := m .LinuxAmd64Env (ctx , src ).
139+ WithExec ([]string {"cargo" , "build" , "--release" , "--target" , "x86_64-unknown-linux-musl" })
140+
141+ container = container .WithExec ([]string {"sh" , "-c" , `
142+ mkdir -p /tmp/http-nu-` + version + `
143+ cp /app/target/x86_64-unknown-linux-musl/release/http-nu /tmp/http-nu-` + version + `/
144+ cd /tmp
145+ tar -czf http-nu-` + version + `-linux-amd64.tar.gz http-nu-` + version + `
146+ ` })
147+
148+ return container .File ("/tmp/http-nu-" + version + "-linux-amd64.tar.gz" )
121149}
0 commit comments