Clojars 用 depstar 和 deps-deploy 发包的记录

因为考虑 CI 做部署的事情, 在网上问了一下, 有社区的高手给了个方案:

https://clojureverse.org/t/gi...

I would expect this to be possible since lein, boot, and CLI/deps.edn all have ways to build an uberjar and publish it to Clojars. (for the latter, see https://github.com/clojure/to... 3 – I use https://github.com/seancorfie... 2 and https://github.com/slipset/de... 4 for build/deploy)

配置 Meyvn 的时候, 安装过程询问是否要证书, 选了 NO, 然后就退出了.
后来又尝试了下 https://github.com/juxt/pack.... 安装过程就出错了.

高手提供的方案是有两个脚本做打包和发布, 他使用的, 比较稳定的,

https://github.com/seancorfie...
https://github.com/slipset/de...

具体的打包发布步骤基本对应 https://juxt.pro/blog/posts/p...

跑通以后目前的 deps.edn 配置:

{:paths ["src"]
 :aliases {:depstar {:extra-deps {seancorfield/depstar {:mvn/version "0.5.2"}}
                     :main-opts ["-m" "hf.depstar.jar" "target/lilac.jar"]}
           :deploy {:extra-deps {deps-deploy {:mvn/version "RELEASE"}}
                    :main-opts ["-m" "deps-deploy.deps-deploy" "deploy" "target/lilac.jar"]}
           :install {:extra-deps {deps-deploy {:mvn/version "RELEASE"}}
                     :main-opts ["-m" "deps-deploy.deps-deploy" "install" "target/lilac.jar"]}}}

启动命令:

    "m2": "clojure -A:depstar && clojure -A:install",
    "deploy": "clojure -A:depstar && clojure -A:deploy",

pom.xml 文件是 clojure -Spom 生成的, 但是中间内容要修改, 包括增加部分字段,

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>mvc-works</groupId>
  <artifactId>calcit-workflow</artifactId>
  <version>0.0.1-a1</version>
  <name>calcit-workflow</name>

  <url>https://github.com/mvc-works/calcit-workflow</url>
  <description>TODO</description>
  <scm>
    <url>https://github.com/mvc-works/calcit-workflow</url>
  </scm>

  <dependencies>
    <dependency>
      <groupId>org.clojure</groupId>
      <artifactId>clojure</artifactId>
      <version>1.10.1</version>
    </dependency>
  </dependencies>
  <build>
    <sourceDirectory>src</sourceDirectory>
  </build>
  <repositories>
    <repository>
      <id>clojars</id>
      <url>https://repo.clojars.org/</url>
    </repository>
  </repositories>
</project>

单纯 pom.xml 的内容结构是很复杂的, 参考:
https://github.com/seancorfie...
https://github.com/clojure/cl...

没有打算提供完整的 pom 文件了. Clojars 上显示的内容也不完整.
目前只是想做到能发包和使用, 维护尽量简单可重复.
毕竟影响到的项目太多了.

另外 deps-deploy 账号密码是通过 env 提供的, 具体看 README.
对应 CI 来说基本还是可以配的, 管理来说却是不如 token 合适.

阅读 2.1k

推荐阅读
题叶
用户专栏

ClojureScript 爱好者.

500 人关注
251 篇文章
专栏主页