(.require [library [lux (.except) ["[0]" ffi (.only import)] [abstract ["[0]" monad (.only do)]] [control ["[0]" pipe] ["[0]" try (.only Try)] ["[0]" io (.only IO)] [concurrency ["[0]" async (.only Async)]] [function [predicate (.only Predicate)]]] [data [binary (.only Binary)] ["[0]" text (.only) ["%" \\format] [encoding ["[0]" utf8]]] [collection ["[0]" set] ["[0]" dictionary]] [format ["[0]" tar] ["[0]" xml]]] [meta [compiler [meta ["[0]" export] ["[0]" archive] ["[0]" context] ["[0]" packager ["[1]" jvm]]]]] [world ["[0]" environment [/ (.only Environment)] ["[1]" \\parser]] [console (.only Console)] ["[0]" shell (.only Shell)] ["[0]" file]]]] ["[0]" // ["[1][0]" snapshot] ["/[1]" // ["[1][0]" install] ["/[1]" // [command (.only Command)] ["/" profile] ["[1][0]" action] ["[1][0]" pom] ["[1][0]" package] ["[1][0]" hash] ["[1][0]" dependency ["[1]/[0]" deployment] ["[1]/[0]" status]] ["[1][0]" repository (.only Repository) ["[1]/[0]" origin] ["[1]/[0]" local]] ["[1][0]" artifact (.only Artifact) ["[1]/[0]" type] ["[1]/[0]" extension (.only Extension)]]]]]) (import java/lang/String "[1]::[0]" (toLowerCase [] java/lang/String)) (import java/lang/System "[1]::[0]" ("static" getProperty [java/lang/String] "io" "try" java/lang/String)) (def windows? (IO (Try Bit)) (at (try.with io.monad) each (|>> java/lang/String::toLowerCase ffi.of_string (text.starts_with? "windows")) (java/lang/System::getProperty (ffi.as_string "os.name")))) (def dummy_jar Binary (|> (packager.package (context.jvm "") (dictionary.empty text.hash) archive.empty {.#None}) try.trusted (pipe.when {.#Left it} it {.#Right _} (undefined)))) (with_template [ ] [(def (-> Text Text) (text.suffix ))] [asc ".asc"] [pom ////artifact/extension.pom] [tar ////artifact/extension.lux_library] [jar ////artifact/extension.jvm_library] [md5 ////artifact/extension.md5] ) (with_template [ ] [(def (-> Text Text) (|>> (text.suffix ) ..jar))] [javadoc "-javadoc"] [sources "-sources"] ) (def .public release? (Predicate Artifact) (|>> //snapshot.snapshot? not)) (def (install_dummies! environment local fs artifact) (-> (Environment Async) (Repository Async) (file.System Async) Artifact (Async (Try Any))) (do (try.with async.monad) [.let [$artifact (////artifact.uri (the ////artifact.#version artifact) artifact)] _ (at local upload (..jar $artifact) ..dummy_jar) _ (at local upload (..javadoc $artifact) ..dummy_jar) _ (at local upload (..sources $artifact) ..dummy_jar)] (in []))) (def (signed it) (-> Text [Text Text]) [it (..asc it)]) (def (release_unsigned_artifact! local remote uri) (-> (Repository Async) (Repository Async) Text (Async (Try Binary))) (do [! ////action.monad] [it (at local download uri) _ (at remote upload uri it)] (in it))) (def (release_signed_artifact! local remote [artifact signature]) (-> (Repository Async) (Repository Async) [Text Text] (Async (Try Any))) (do [! ////action.monad] [it (..release_unsigned_artifact! local remote artifact) _ (|> it ////hash.md5 (at ////hash.md5_codec encoded) (at utf8.codec encoded) (at remote upload (..md5 artifact))) _ (..release_unsigned_artifact! local remote signature)] (in []))) (def .public (do! environment shell console local remote fs artifact profile) (-> (Environment Async) (Shell Async) (Console Async) (Repository Async) (Repository Async) (file.System Async) Artifact (Command Any)) (do [! ////action.monad] [_ (///install.do! console fs local profile) _ (install_dummies! environment local fs artifact) .let [working_directory (at environment directory) @root (////repository/local.root environment fs) $bundle (////artifact.bundle (the ////artifact.#version artifact) artifact) / (at fs separator) @local (%.format @root / $bundle)] windows? (async.future ..windows?) process (is (Async (Try (shell.Process Async))) (at shell execute [environment.empty @local (if windows? ["cmd" (list "/c" "for %file in (.\*) do gpg.exe -ab %file")] ["sh" (list "-c" "for file in *.*; do gpg -ab $file; done")])])) exit (is (Async (Try shell.Exit)) (at process await [])) .let [$artifact (////artifact.uri (the ////artifact.#version artifact) artifact)] _ (monad.each ! (release_signed_artifact! local remote) (list (..signed (..pom $artifact)) (..signed (..tar $artifact)) (..signed (..jar $artifact)) (..signed (..javadoc $artifact)) (..signed (..sources $artifact))))] (in [])))