@@ -451,56 +451,24 @@ fn release(b: *Build, release_artifacts: []const *Build.Step.Compile) void {
451451 std .debug .assert (release_artifacts .len > 0 );
452452 for (release_artifacts ) | compile | std .debug .assert (compile .version != null );
453453
454- const publish_step = b .step ("publish" , "Publish release artifacts to releases.zigtools.org" );
454+ const publish_step = b .step ("publish" , "Publish release artifacts to releases.zigtools.org (requires curl) " );
455455 const release_step = b .step ("release" , "Build all release artifacts. (requires tar and 7z)" );
456456 const release_minisign = b .option (bool , "release-minisign" , "Sign release artifacts with Minisign" ) orelse false ;
457457
458- const FileExtension = enum {
459- zip ,
460- @"tar.xz" ,
461- @"tar.gz" ,
462- };
458+ publish_step .dependOn (release_step );
463459
464- const uri : std.Uri = if (b .graph .env_map .get ("ZLS_WORKER_ENDPOINT" )) | endpoint | blk : {
465- var uri = std .Uri .parse (endpoint ) catch std .debug .panic ("invalid URI: '{s}'" , .{endpoint });
466- if (! uri .path .isEmpty ()) std .debug .panic ("ZLS_WORKER_ENDPOINT URI must have no path component: '{s}'" , .{endpoint });
467- uri .path = .{ .raw = "/v1/zls/publish" };
468- break :blk uri ;
469- } else .{
470- .scheme = "https" ,
471- .host = .{ .raw = "releases.zigtools.org" },
472- .path = .{ .raw = "/v1/zls/publish" },
473- };
474-
475- const password = b .graph .env_map .get ("ZLS_WORKER_API_TOKEN" ) orelse "amogus" ;
476-
477- const publish_exe = b .addExecutable (.{
478- .name = "publish" ,
479- .target = b .graph .host ,
480- .root_source_file = b .path ("src/tools/publish_http_form.zig" ),
481- });
482-
483- // var publish_artifacts = b.addSystemCommand("curl")
484- var publish_artifacts = b .addRunArtifact (publish_exe );
485- publish_step .dependOn (& publish_artifacts .step );
486-
487- publish_artifacts .addArgs (&.{
488- b .fmt ("{}" , .{uri }),
489- "--user" ,
490- b .fmt ("admin:{s}" , .{password }),
491- });
492460 // It is possible for the version to be something like `0.12.0-dev` when `git describe` failed.
493461 // Ideally we would want to report a failure about this when running one of the release/publish steps.
494462 // The problem is during the configure phase, it is not possible to know which top level steps gets run.
495463 // So instead we use rely on the release-worker to reject this version string during the make phase.
496464 // One possible alternative would be to use a configuration option (i.e. -Dpublish) to conditionally run an assertion.
497- publish_artifacts . addArgs (&.{
498- "--form" , b . fmt ( "zls-version={}" , .{ release_artifacts [ 0 ]. version .? }),
499- "--form" , "compatibility=full" ,
500- "--form" , b . fmt ( "zig-version={s}" , .{ builtin . zig_version_string }) ,
501- "--form" , b . fmt ( "minimum-build-zig-version={s}" , .{ minimum_build_zig_version }) ,
502- "--form" , b . fmt ( "minimum-runtime-zig-version={s}" , .{ minimum_runtime_zig_version }) ,
503- }) ;
465+ const released_zls_version = release_artifacts [ 0 ]. version .? ;
466+
467+ const FileExtension = enum {
468+ zip ,
469+ @ "tar.xz" ,
470+ @ "tar.gz" ,
471+ };
504472
505473 var compressed_artifacts : std .StringArrayHashMapUnmanaged (std .Build .LazyPath ) = .empty ;
506474
@@ -524,6 +492,7 @@ fn release(b: *Build, release_artifacts: []const *Build.Step.Compile) void {
524492 });
525493
526494 const compress_cmd = std .Build .Step .Run .create (b , "compress artifact" );
495+ compress_cmd .clearEnvironment ();
527496 compress_cmd .step .max_rss = switch (extension ) {
528497 .zip = > 160 * 1024 * 1024 , // 160 MiB
529498 .@"tar.xz" = > 512 * 1024 * 1024 , // 512 MiB
@@ -568,24 +537,77 @@ fn release(b: *Build, release_artifacts: []const *Build.Step.Compile) void {
568537
569538 const install_tarball = b .addInstallFileWithDir (file_path , install_dir , file_name );
570539 release_step .dependOn (& install_tarball .step );
571- publish_artifacts .addArg ("--form" );
572- publish_artifacts .addPrefixedFileArg (b .fmt ("{s}=@" , .{file_name }), file_path );
573540
574541 if (release_minisign ) {
575542 const minisign_basename = b .fmt ("{s}.minisig" , .{file_name });
576543
577544 const minising_cmd = b .addSystemCommand (&.{ "minisign" , "-Sm" });
545+ minising_cmd .clearEnvironment ();
578546 minising_cmd .addFileArg (file_path );
579547 minising_cmd .addPrefixedFileArg ("-s" , .{ .cwd_relative = "minisign.key" });
580548 const minising_file_path = minising_cmd .addPrefixedOutputFileArg ("-x" , minisign_basename );
581549
582550 const install_minising = b .addInstallFileWithDir (minising_file_path , install_dir , minisign_basename );
583551 release_step .dependOn (& install_minising .step );
584-
585- publish_artifacts .addArg ("--form" );
586- publish_artifacts .addPrefixedFileArg (b .fmt ("{s}=@" , .{minisign_basename }), minising_file_path );
587552 }
588553 }
554+
555+ // Create JSON request data
556+
557+ const prepare_release = b .addRunArtifact (b .addExecutable (.{
558+ .name = "prepare_release" ,
559+ .root_module = b .createModule (.{
560+ .root_source_file = b .path ("src/tools/prepare_release.zig" ),
561+ .target = b .graph .host ,
562+ .optimize = .Debug ,
563+ }),
564+ }));
565+
566+ prepare_release .addArgs (&.{
567+ "--zls-version" ,
568+ b .fmt ("{}" , .{released_zls_version }),
569+ "--zig-version" ,
570+ b .fmt ("{s}" , .{builtin .zig_version_string }),
571+ "--minimum-build-zig-version" ,
572+ b .fmt ("{s}" , .{minimum_build_zig_version }),
573+ "--minimum-runtime-zig-version" ,
574+ b .fmt ("{s}" , .{minimum_runtime_zig_version }),
575+ "--compatibility" ,
576+ "full" ,
577+ });
578+
579+ for (compressed_artifacts .values ()) | path | {
580+ prepare_release .addFileArg (path );
581+ }
582+
583+ // Send Post request to `https://releases.zigtools.org/v1/zls/publish`
584+
585+ const uri : std.Uri = if (b .graph .env_map .get ("ZLS_WORKER_ENDPOINT" )) | endpoint | blk : {
586+ var uri = std .Uri .parse (endpoint ) catch std .debug .panic ("invalid URI: '{s}'" , .{endpoint });
587+ if (! uri .path .isEmpty ()) std .debug .panic ("ZLS_WORKER_ENDPOINT URI must have no path component: '{s}'" , .{endpoint });
588+ uri .path = .{ .raw = "/v1/zls/publish" };
589+ break :blk uri ;
590+ } else .{
591+ .scheme = "https" ,
592+ .host = .{ .raw = "releases.zigtools.org" },
593+ .path = .{ .raw = "/v1/zls/publish" },
594+ };
595+
596+ const password = b .graph .env_map .get ("ZLS_WORKER_API_TOKEN" ) orelse "amogus" ;
597+
598+ var publish_artifacts = b .addSystemCommand (&.{"curl" });
599+ publish_artifacts .has_side_effects = true ;
600+ publish_step .dependOn (& publish_artifacts .step );
601+
602+ publish_artifacts .addArgs (&.{
603+ b .fmt ("{}" , .{uri }),
604+ "--fail" ,
605+ "--show-error" ,
606+ "--user" ,
607+ b .fmt ("admin:{s}" , .{password }),
608+ "--json" ,
609+ });
610+ publish_artifacts .addPrefixedFileArg ("@" , prepare_release .captureStdOut ());
589611}
590612
591613const Build = blk : {
0 commit comments