From 24e7f5506b9ce530f2f50b45a0432cbaf5dba564 Mon Sep 17 00:00:00 2001 From: Julien Vincent Date: Thu, 18 Jan 2024 17:00:11 +0000 Subject: [PATCH] patch: Release to clojars instead of github --- .github/workflows/release.yml | 22 +++------------- build/build.clj | 48 +++++++++++++++++++++++++++++++++++ build/deps.edn | 3 +++ deps.edn | 11 +------- packages/kmono/deps.edn | 12 ++++----- packages/kmono/justfile | 14 +++++----- 6 files changed, 66 insertions(+), 44 deletions(-) create mode 100644 build/build.clj create mode 100644 build/deps.edn diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index ed4881c..98c9cc6 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -3,16 +3,8 @@ on: [push] jobs: build-and-publish: - permissions: - contents: write - packages: write - runs-on: ubuntu-latest - env: - GITHUB_USERNAME: ${{ secrets.ORG_GITHUB_ACTOR }} - GITHUB_TOKEN: ${{ secrets.ORG_GITHUB_TOKEN }} - steps: - name: Checkout git repo uses: actions/checkout@v2 @@ -40,17 +32,6 @@ jobs: with: cli: latest - - uses: s4u/maven-settings-action@v2.4.1 - with: - githubServer: false - servers: | - [{"id": "github-kepler", - "username": "${{ secrets.ORG_GITHUB_ACTOR }}", - "password": "${{ secrets.ORG_GITHUB_TOKEN }}"}, - {"id": "github-kepler-kmono", - "username": "${{ github.actor }}", - "password": "${{ secrets.GITHUB_TOKEN }}"}] - # - name: Test # run: | # just test ":snapshot?" ${{ github.ref_name != 'master' }} @@ -60,6 +41,9 @@ jobs: just build ":snapshot?" ${{ github.ref_name != 'master' }} - name: Release + env: + CLOJARS_USERNAME: infrastructure-kepler16-com + CLOJARS_PASSWORD: ${{ secrets.CLOJARS_PASSWORD }} run: | just release \ ":snapshot?" ${{ github.ref_name != 'master' }} \ diff --git a/build/build.clj b/build/build.clj new file mode 100644 index 0000000..81f623c --- /dev/null +++ b/build/build.clj @@ -0,0 +1,48 @@ +(ns build + (:require + [clojure.edn :as edn] + [clojure.java.io :as io] + [clojure.tools.build.api :as b] + [deps-deploy.deps-deploy :as deps-deploy])) + +(def basis (delay (b/create-basis {}))) + +(def kmono-config + (-> (io/file "deps.edn") + slurp + edn/read-string + :kmono/config)) + +(def lib (symbol (or (System/getenv "KMONO_PKG_NAME") + (str (:group kmono-config) "/" (:artifact kmono-config))))) +(def version (or (System/getenv "KMONO_PKG_VERSIO") "0.0.0")) +(def class-dir "target/classes") +(def jar-file "target/lib.jar") + +(defn clean [_] + (b/delete {:path "target"})) + +(defn build [_] + (b/write-pom {:class-dir class-dir + :lib lib + :version version + :basis @basis + :src-dirs ["src"] + :pom-data [[:description "Clojure monorepo tools"] + [:url "https://github.com/kepler16/kmono"] + [:licenses + [:license + [:name "MIT"] + [:url "https://opensource.org/license/mit"]]]]}) + + (b/copy-dir {:src-dirs ["src"] + :target-dir class-dir}) + + (b/jar {:class-dir class-dir + :jar-file jar-file})) + +(defn release [_] + (deps-deploy/deploy {:installer :remote + :artifact (b/resolve-path jar-file) + :pom-file (b/pom-path {:lib lib + :class-dir class-dir})})) diff --git a/build/deps.edn b/build/deps.edn new file mode 100644 index 0000000..b77496b --- /dev/null +++ b/build/deps.edn @@ -0,0 +1,3 @@ +{:paths ["./"] + :deps {io.github.clojure/tools.build {:mvn/version "0.9.6"} + slipset/deps-deploy {:mvn/version "0.2.2"}}} diff --git a/deps.edn b/deps.edn index 09e5692..f0893b5 100644 --- a/deps.edn +++ b/deps.edn @@ -1,11 +1,2 @@ -{:mvn/repos {"github-kepler" {:url "https://maven.pkg.github.com/kepler16/*"}} - :aliases {:dev {:classpath-overrides {org.clojure/clojure nil} - :extra-deps {kepler16/kmono {:local/root "packages/kmono"} - com.github.flow-storm/clojure {:mvn/version "1.11.1-11"} - com.github.flow-storm/flow-storm-dbg {:mvn/version "3.8.3"}} - :jvm-opts ["-Dclojure.storm.instrumentEnable=true" - "-Dclojure.storm.traceEnable=true" - "-Dflowstorm.theme=dark" - "-Dclojure.storm.instrumentOnlyPrefixes=k16."]} - :kmono {:deps {kepler16/kmono {:local/root "packages/kmono"}} +{:aliases {:kmono {:deps {com.kepler16/kmono {:local/root "packages/kmono"}} :ns-default k16.kmono.api}}} diff --git a/packages/kmono/deps.edn b/packages/kmono/deps.edn index a040034..b8a227f 100644 --- a/packages/kmono/deps.edn +++ b/packages/kmono/deps.edn @@ -1,6 +1,5 @@ -{:mvn/repos {"github-kepler" {:url "https://maven.pkg.github.com/kepler16/*"} - "github-kepler-kmono" {:url "https://maven.pkg.github.com/kepler16/kmono"}} - :kmono/config {:group kepler16 +{:kmono/config {:group com.kepler16 + :artifact kmono :build-cmd "just build" :release-cmd "just release"} :paths ["src" "resources"] @@ -14,7 +13,6 @@ metosin/malli {:mvn/version "0.11.0"} org.flatland/ordered {:mvn/version "1.15.11"}} - :aliases {:lib {:k16/metabuild {:kind :jar}} - :test {:extra-deps {lambdaisland/kaocha {:mvn/version "1.86.1355"}}} - :meta {:deps {kepler16/metabuild {:mvn/version "0.10.0"}} - :ns-default k16.metabuild.api}}} + :aliases {:build {:deps {local/build {:local/root "../../build"}} + :ns-default build} + :test {:extra-deps {lambdaisland/kaocha {:mvn/version "1.86.1355"}}}}} diff --git a/packages/kmono/justfile b/packages/kmono/justfile index d978e7f..414fe09 100644 --- a/packages/kmono/justfile +++ b/packages/kmono/justfile @@ -1,13 +1,11 @@ -library := "kepler16/kmono" -version := "$KMONO_PKG_VERSION" -maven_server := "github-kepler-kmono" - test: clojure -M:test -m "kaocha.runner" -build: - clojure -T:meta run :alias lib :lib {{ library }} :version \"{{ version }}\" +clean: + clojure -T:build clean -release: - clojure -T:meta deploy :repository \"{{ maven_server }}\" :lib {{ library }} :version \"{{ version }}\" +build: clean + clojure -T:build build +release: + clojure -T:build release