From 5c5d3221557a8ebbac90bad070300cc53ce195eb Mon Sep 17 00:00:00 2001 From: Erik Assum Date: Fri, 8 Oct 2021 20:39:31 +0200 Subject: [PATCH] Set up automagic deploy (#65) --- .circleci/config.yml | 107 ++++++++++++++++++++++++++++++++++++++++--- project.clj | 8 ++-- 2 files changed, 105 insertions(+), 10 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 42ec75c..32c9b5c 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,4 +1,32 @@ version: 2.1 + +workflows: + version: 2 + default: + jobs: + - reflection: + filters: + tags: + only: /.*/ + + - openjdk-8: + filters: + tags: + only: /.*/ + + - openjdk-11: + filters: + tags: + only: /.*/ + + - deploy: + requires: [openjdk-8, openjdk-11, reflection] + filters: + tags: + only: /Release-.*/ + context: + - CLOJARS_DEPLOY + commands: setup-project: description: "Setup project" @@ -79,10 +107,75 @@ jobs: - setup-project - run-tests -workflows: - version: 2 - default: - jobs: - - reflection - - openjdk-8 - - openjdk-11 + deploy: + docker: + # specify the version you desire here + - image: circleci/clojure:openjdk-8-lein-2.9.1 + # Specify service dependencies here if necessary + # CircleCI maintains a library of pre-built images + # documented at https://circleci.com/docs/2.0/circleci-images/ + # - image: circleci/postgres:9.4 + + working_directory: ~/repo + + environment: + LEIN_ROOT: "true" + # Customize the JVM maximum heap limit + JVM_OPTS: -Xmx3200m + + steps: + - checkout + + # Download and cache dependencies + - restore_cache: + keys: + - v1-dependencies-{{ checksum "project.clj" }} + # fallback to using the latest cache if no exact match is found + - v1-dependencies- + + # Download and cache dependencies + - restore_cache: + keys: + - v1-dependencies-{{ checksum "project.clj" }} + # fallback to using the latest cache if no exact match is found + - v1-dependencies- + + - run: + name: Install babashka + command: | + curl -s https://raw.githubusercontent.com/borkdude/babashka/master/install -o install.sh + sudo bash install.sh + rm install.sh + - run: + name: Install deployment-script + command: | + curl -s https://raw.githubusercontent.com/clj-commons/infra/main/deployment/circle-maybe-deploy.bb -o circle-maybe-deploy.bb + chmod a+x circle-maybe-deploy.bb + + - run: lein deps + + - run: + name: Setup GPG signing key + command: | + GNUPGHOME="$HOME/.gnupg" + export GNUPGHOME + mkdir -p "$GNUPGHOME" + chmod 0700 "$GNUPGHOME" + + echo "$GPG_KEY" \ + | base64 --decode --ignore-garbage \ + | gpg --batch --allow-secret-key-import --import + + gpg --keyid-format LONG --list-secret-keys + + - save_cache: + paths: + - ~/.m2 + key: v1-dependencies-{{ checksum "project.clj" }} + - run: + name: Deploy + command: | + GPG_TTY=$(tty) + export GPG_TTY + echo $GPG_TTY + ./circle-maybe-deploy.bb lein deploy clojars diff --git a/project.clj b/project.clj index 0602d18..8855e74 100644 --- a/project.clj +++ b/project.clj @@ -1,4 +1,4 @@ -(defproject org.flatland/ordered "1.5.10-SNAPSHOT" +(defproject org.flatland/ordered (or (System/getenv "PROJECT_VERSION") "1.5.10") :url "https://github.com/clj-commons/ordered" :license {:name "Eclipse Public License - v 1.0" :url "http://www.eclipse.org/legal/epl-v10.html"} @@ -6,8 +6,10 @@ :dependencies [[org.clojure/clojure "1.10.1"]] :aliases {"testall" ["with-profile" "+1.8:+1.9:+1.10.0:+1.10.1" "test"] "depsall" ["with-profile" "+1.8:+1.9:+1.10.0:+1.10.1" "deps"]} - :deploy-repositories [["releases" :clojars] - ["snapshots" :clojars]] + :deploy-repositories [["clojars" {:url "https://repo.clojars.org" + :username :env/clojars_username + :password :env/clojars_ordered_password + :sign-releases true}]] :profiles {:1.10.1 {:dependencies [[org.clojure/clojure "1.10.1"]]} :1.10.0 {:dependencies [[org.clojure/clojure "1.10.0"]]} :1.9 {:dependencies [[org.clojure/clojure "1.9.0"]]}