From b8439c8add612cfaf820f223908f613c89804d58 Mon Sep 17 00:00:00 2001 From: raphasampaio Date: Fri, 13 Dec 2024 14:48:35 -0300 Subject: [PATCH 1/3] Updated --- src/configuration.jl | 15 +++++++++++++++ src/deploy/psrmodels.jl | 26 ++++++++------------------ src/setup.jl | 2 +- src/sign.jl | 12 ++---------- 4 files changed, 26 insertions(+), 29 deletions(-) diff --git a/src/configuration.jl b/src/configuration.jl index bda86a1..38ffde3 100644 --- a/src/configuration.jl +++ b/src/configuration.jl @@ -75,3 +75,18 @@ end function is_stable_release(configuration::Configuration) return is_stable_release(configuration.development_stage) end + +function setup_exe(configuration::Configuration) + target = configuration.target + version = configuration.version + + if Sys.iswindows() + return "$target-$version-win64.exe" + else + lOG.fatal_error("SETUP: Creating setup file is only supported on Windows") + end +end + +function setup_exe_path(configuration::Configuration) + return joinpath(configuration.setup_path, setup_exe(configuration)) +end \ No newline at end of file diff --git a/src/deploy/psrmodels.jl b/src/deploy/psrmodels.jl index 0cd0577..9c6991b 100644 --- a/src/deploy/psrmodels.jl +++ b/src/deploy/psrmodels.jl @@ -10,7 +10,7 @@ function generate_unique_key(; bucket::AbstractString, version::VersionNumber, target::AbstractString, - setup_zip::AbstractString, + filename::AbstractString, overwrite::Bool = false, ) objects = S3.list_objects_v2(bucket, Dict("prefix" => target)) @@ -20,10 +20,10 @@ function generate_unique_key(; if startswith(key, "$target/$version/") if overwrite - Log.info("PSRMODELS: Overwriting the $setup_zip in the $bucket bucket") + Log.info("PSRMODELS: Overwriting the $filename in the $bucket bucket") return key else - Log.fatal_error("PSRMODELS: The $setup_zip already exists in the $bucket bucket") + Log.fatal_error("PSRMODELS: The $filename already exists in the $bucket bucket") end end end @@ -31,7 +31,7 @@ function generate_unique_key(; for _ in 1:10 hash = randstring(['a':'z'; '0':'9'], 6) - key = "$target/$version/$hash/$setup_zip" + key = "$target/$version/$hash/$filename" objects = S3.list_objects_v2(bucket, Dict("prefix" => target)) if haskey(objects, "Contents") @@ -65,17 +65,6 @@ function deploy_to_psrmodels(; target = configuration.target version = configuration.version - setup_path = configuration.setup_path - - setup_exe = "$target-$version-setup.exe" - setup_exe_path = joinpath(setup_path, setup_exe) - - setup_zip = "$target-$version.zip" - setup_zip_path = joinpath(setup_path, setup_zip) - - Log.info("PSRMODELS: Zipping $setup_exe") - run(`$(p7zip_jll.p7zip()) a -tzip $setup_zip_path $setup_exe_path`) - @assert isfile(setup_zip_path) aws_credentials = AWSCredentials(aws_access_key, aws_secret_key) aws_config = AWSConfig(; creds = aws_credentials, region = "us-east-1") @@ -85,12 +74,13 @@ function deploy_to_psrmodels(; bucket = bucket, version = version, target = target, - setup_zip = setup_zip, + filename = setup_exe(configuration), overwrite = overwrite, ) - Log.info("PSRMODELS: Uploading $setup_zip") - S3.put_object(bucket, key, Dict("body" => read(setup_zip_path))) + Log.info("PSRMODELS: Uploading $(setup_exe(configuration))") + @assert isfile(setup_exe_path(configuration)) + S3.put_object(bucket, key, Dict("body" => read(setup_exe_path(configuration)))) Log.info("PSRMODELS: Success") diff --git a/src/setup.jl b/src/setup.jl index 9d5d9e5..c2a7f98 100644 --- a/src/setup.jl +++ b/src/setup.jl @@ -47,7 +47,7 @@ function create_setup( writeln(f, "VersionInfoProductName=$target$version") writeln(f, "DisableDirPage=no") writeln(f, "OutputDir=.\\") - writeln(f, "OutputBaseFilename=$target-$version-setup") + writeln(f, "OutputBaseFilename=$target-$version-win64") writeln(f, "Compression=lzma") writeln(f, "SolidCompression=yes") writeln(f, "AlwaysShowComponentsList=yes") diff --git a/src/sign.jl b/src/sign.jl index 499c904..9e0594d 100644 --- a/src/sign.jl +++ b/src/sign.jl @@ -9,15 +9,11 @@ function upload_file_to_certificate_server( connect_timeout::Integer = CONNECT_TIMEOUT, connect_retries::Integer = CONNECT_RETRIES, ) - target = configuration.target - version = configuration.version - setup_exe_path = joinpath(configuration.setup_path, "$target-$version-setup.exe") - certificate_server_url = configuration.certificate_server_url url = "$certificate_server_url/upload" headers = [] - data = ["filename" => "", "file" => open(setup_exe_path)] + data = ["filename" => "", "file" => open(setup_exe_path(configuration))] body = HTTP.Form(data) t = time() @@ -38,10 +34,6 @@ function download_file_from_server( connect_timeout::Integer = CONNECT_TIMEOUT, connect_retries::Integer = CONNECT_RETRIES, ) - target = configuration.target - version = configuration.version - setup_exe_path = joinpath(configuration.setup_path, "$target-$version-setup.exe") - certificate_server_url = configuration.certificate_server_url url = "$certificate_server_url/download/$filename" @@ -50,7 +42,7 @@ function download_file_from_server( Log.info("SETUP: Downloaded file from certificate server in $(time() - t) seconds") if response.status == 200 - open(setup_exe_path, "w") do io + open(setup_exe_path(configuration), "w") do io write(io, response.body) return nothing end From 20a967b95286c958ae6d6a95b9b2908426c0c994 Mon Sep 17 00:00:00 2001 From: raphasampaio Date: Mon, 16 Dec 2024 17:24:51 -0300 Subject: [PATCH 2/3] [skip ci] minor changes --- src/configuration.jl | 2 +- src/deploy/psrmodels.jl | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/configuration.jl b/src/configuration.jl index 38ffde3..190d244 100644 --- a/src/configuration.jl +++ b/src/configuration.jl @@ -89,4 +89,4 @@ end function setup_exe_path(configuration::Configuration) return joinpath(configuration.setup_path, setup_exe(configuration)) -end \ No newline at end of file +end diff --git a/src/deploy/psrmodels.jl b/src/deploy/psrmodels.jl index 9c6991b..0038825 100644 --- a/src/deploy/psrmodels.jl +++ b/src/deploy/psrmodels.jl @@ -53,6 +53,8 @@ function generate_unique_key(; end error("Failed to generate a unique hash") + + return nothing end function deploy_to_psrmodels(; From cb4e7343e392bb24b5ff2bedbbf9775d36ca9675 Mon Sep 17 00:00:00 2001 From: raphasampaio Date: Mon, 16 Dec 2024 17:38:37 -0300 Subject: [PATCH 3/3] Updated --- test/Example.jl/Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Example.jl/Project.toml b/test/Example.jl/Project.toml index 124c94a..75d0f8b 100644 --- a/test/Example.jl/Project.toml +++ b/test/Example.jl/Project.toml @@ -1,6 +1,6 @@ name = "Example" uuid = "28d347f4-7536-4c5e-b41f-4013aab74eac" -version = "0.2.0" +version = "0.3.0" [deps]