Skip to content

Commit

Permalink
First cut at a clojars deploy tool that signs [IMMUTANT-274]
Browse files Browse the repository at this point in the history
It still needs to be wired up to maven to call it, though we'd still
do that manually & locally after a release build.
  • Loading branch information
tobias committed May 23, 2013
1 parent fc12d0b commit c0b1b58
Showing 1 changed file with 63 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
;; Copyright 2008-2013 Red Hat, Inc, and individual contributors.
;;
;; This is free software; you can redistribute it and/or modify it
;; under the terms of the GNU Lesser General Public License as
;; published by the Free Software Foundation; either version 2.1 of
;; the License, or (at your option) any later version.
;;
;; This software is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
;; Lesser General Public License for more details.
;;
;; You should have received a copy of the GNU Lesser General Public
;; License along with this software; if not, write to the Free
;; Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
;; 02110-1301 USA, or see the FSF site: http://www.fsf.org.

(ns immutant.build.deploy-to-clojars
(:require [clojure.java.io :as io]
[leiningen.core.project :as project]
[leiningen.core.user :as user]
[leiningen.deploy :as deploy]
[cemerick.pomegranate.aether :as aether])
(:gen-class))

(def key-id "BFC757F9")

(defn artifacts [dir project]
(let [artifacts {[:extension "pom"] (.getAbsolutePath
(io/file dir "pom.xml"))
[:extension "jar"] (.getAbsolutePath
(io/file dir
(format "%s-%s.jar"
(:name project)
(:version project))))}]
;; TODO: use the immutant cert
(reduce merge artifacts
(map #(deploy/signature-for-artifact % {:gpg-key key-id})
artifacts))))

(defn deploy [project artifacts]
(println "Publishing artifacts for" (:name project))
(aether/deploy
:coordinates [(symbol (:group project) (:name project))
project]
:artifact-map artifacts
:transfer-listener :stdout
:repository (deploy/repo-for project "clojars")))

(defn process-artifacts [base-dir]
(println "Looking for artifacts in" base-dir)
(for [dir (file-seq (io/file base-dir))
:let [project-file (io/file dir "project.clj")]
:when (.exists project-file)]
(let [project (project/read (.getAbsolutePath project-file))]
(deploy project (artifacts dir project)))))

(defn -main []
(println "Pushing artifacts to clojars...")
(if-let [dir (System/getProperty "dir")]
(process-artifacts dir)
(println "No dir provided - use -Ddir=/path/to/artifacts"))
(shutdown-agents))

0 comments on commit c0b1b58

Please sign in to comment.