@@ -68,6 +68,8 @@ should your dependencies change.
68
68
69
69
The `outputs` field is the target for the bundle. It can be a directory, a
70
70
tarball, or an `Artifacts.toml` file. Or it can be an array of multiple targets.
71
+ For `Artifacts.toml` files the `artifacts_url` field must be specified, which
72
+ points at the URL where the tarball can be downloaded from.
71
73
72
74
The `key` field is the name of the private and public key files. The private key
73
75
is used to sign the bundled packages and the public key is included in the
@@ -101,10 +103,7 @@ listed below. The valid names for handlers are:
101
103
- `code_injector.jl`: A function that injects extra code into the bundled
102
104
packages. Takes `filename` as an argument.
103
105
"""
104
- function bundle (
105
- config:: AbstractString = " PackageBundler.toml" ;
106
- clean:: Bool = false ,
107
- )
106
+ function bundle (config:: AbstractString = " PackageBundler.toml" ; clean:: Bool = false )
108
107
config = abspath (config)
109
108
endswith (config, " .toml" ) || error (" Config file must be a TOML file: `$config `." )
110
109
isfile (config) || error (" Config file not found: `$config `." )
@@ -164,6 +163,9 @@ function bundle(
164
163
outputs = String .(vcat (outputs))
165
164
outputs = isempty (outputs) ? [name] : outputs
166
165
166
+ # Artifact URL for `Artifacts.toml` files.
167
+ artifact_url = get (config, " artifacts_url" , nothing ):: Union{String,Nothing}
168
+
167
169
# Multiplexers. The list of multiplexer programs to try to use to select
168
170
# specific versions of Julia for each environment based on it's
169
171
# `julia_version`.
@@ -208,18 +210,41 @@ function bundle(
208
210
end
209
211
isdir (output) || mkpath (output)
210
212
cp (temp_dir, output; force = true )
211
- else
212
- if is_artifacts
213
- # TODO : implement.
214
- error (" unsupported output type: $output " )
215
- else
216
- @info " Generating tarball bundle." output
217
- isdir (dirname (output)) || mkpath (dirname (output))
218
- tar_gz = open (output, write = true )
219
- tar = CodecZlib. GzipCompressorStream (tar_gz)
220
- Tar. create (temp_dir, tar)
221
- close (tar)
213
+ elseif is_tarball
214
+ @info " Generating tarball bundle." output
215
+ isdir (dirname (output)) || mkpath (dirname (output))
216
+ tar_gz = open (output, write = true )
217
+ tar = CodecZlib. GzipCompressorStream (tar_gz)
218
+ Tar. create (temp_dir, tar)
219
+ close (tar)
220
+ elseif is_artifacts
221
+ @info " Generating Artifacts.toml bundle." output
222
+ if isnothing (artifact_url)
223
+ error (" `artifacts_url` must be specified for Artifacts.toml output." )
224
+ end
225
+ artifact_toml = joinpath (temp_dir, " Artifacts.toml" )
226
+ product_hash = Pkg. Artifacts. create_artifact () do artifact_dir
227
+ cp (temp_dir, artifact_dir; force = true )
222
228
end
229
+ artifact_name = " $name .tar.gz"
230
+ temp_artifact = joinpath (temp_dir, artifact_name)
231
+ download_hash = Pkg. Artifacts. archive_artifact (product_hash, temp_artifact)
232
+ Pkg. Artifacts. bind_artifact! (
233
+ artifact_toml,
234
+ name,
235
+ product_hash,
236
+ force = true ,
237
+ download_info = Tuple[(" $artifact_url /$artifact_name " , download_hash)],
238
+ )
239
+ if clean && isdir (dirname (output))
240
+ @warn " Cleaning directory." dirname (output)
241
+ rm (dirname (output); recursive = true )
242
+ end
243
+ isdir (dirname (output)) || mkpath (dirname (output))
244
+ cp (artifact_toml, output; force = true )
245
+ cp (temp_artifact, joinpath (dirname (output), artifact_name); force = true )
246
+ else
247
+ error (" Invalid output target: $output " )
223
248
end
224
249
end
225
250
end
0 commit comments