Skip to content

Commit

Permalink
patch: Release to clojars instead of github
Browse files Browse the repository at this point in the history
  • Loading branch information
julienvincent committed Jan 18, 2024
1 parent c0dd30d commit b449288
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 44 deletions.
22 changes: 3 additions & 19 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -40,17 +32,6 @@ jobs:
with:
cli: latest

- uses: s4u/[email protected]
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' }}
Expand All @@ -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' }} \
Expand Down
48 changes: 48 additions & 0 deletions build/build.clj
Original file line number Diff line number Diff line change
@@ -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_VERSION") "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})}))
3 changes: 3 additions & 0 deletions build/deps.edn
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{:paths ["./"]
:deps {io.github.clojure/tools.build {:mvn/version "0.9.6"}
slipset/deps-deploy {:mvn/version "0.2.2"}}}
13 changes: 3 additions & 10 deletions deps.edn
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
{: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"}}
{:deps {local/build {:local/root "build"}}

:aliases {:kmono {:deps {com.kepler16/kmono {:local/root "packages/kmono"}}
:ns-default k16.kmono.api}}}
12 changes: 5 additions & 7 deletions packages/kmono/deps.edn
Original file line number Diff line number Diff line change
@@ -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"]
Expand All @@ -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"}}}}}
14 changes: 6 additions & 8 deletions packages/kmono/justfile
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit b449288

Please sign in to comment.