diff --git a/.circleci/config.yml b/.circleci/config.yml index 8ba3fd5..f97f041 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -43,7 +43,9 @@ jobs: mkdir -p /tmp/release lein do clean, uberjar VERSION=$(cat resources/DEPS_CLJ_VERSION) - cp target/deps.clj-$VERSION-standalone.jar /tmp/release + artifact="target/deps.clj-$VERSION-standalone.jar" + cp "$artifact" /tmp/release + bb upload-artifact :file "$artifact" - store_artifacts: path: /tmp/release destination: release @@ -100,6 +102,7 @@ jobs: command: | bash <(curl -s https://raw.githubusercontent.com/borkdude/babashka/master/install) --dir ~ sudo mv ~/bb /usr/local/bin/bb + bb --version - run: name: Install lsof command: | diff --git a/.circleci/script/release b/.circleci/script/release index 4c518b6..d425a07 100755 --- a/.circleci/script/release +++ b/.circleci/script/release @@ -6,10 +6,15 @@ cp deps /tmp/release VERSION=$(cat resources/DEPS_CLJ_VERSION) -cd /tmp/release +pushd /tmp/release ## release binary as zip archive -zip "deps.clj-$VERSION-$DEPS_CLJ_PLATFORM-amd64.zip" deps +artifact="deps.clj-$VERSION-$DEPS_CLJ_PLATFORM-amd64.zip" +zip "$artifact" deps + +popd + +bb upload-artifact :file "/tmp/release/$artifact" rm deps diff --git a/appveyor.yml b/appveyor.yml index b187819..7c78333 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -45,7 +45,11 @@ build_script: echo Creating zip archive - jar -cMf deps.clj-%DEPS_CLJ_VERSION%-windows-amd64.zip deps.exe + set ARTIFACT=deps.clj-%DEPS_CLJ_VERSION%-windows-amd64.zip + + jar -cMf %ARTIFACT% deps.exe + + bb upload-artifact :file %ARTIFACT% dir diff --git a/bb.edn b/bb.edn index d2ed5be..5e627e0 100644 --- a/bb.edn +++ b/bb.edn @@ -1,7 +1,8 @@ {:paths ["resources" "bb"] + :deps {io.github.borkdude/gh-release-artifact {:git/sha "db5e79559fdbfa009ed4a0921079e20e1e76b269"}} :min-bb-version "1.0.165" - + :tasks {:requires [[babashka.deps :as deps] [babashka.fs :as fs] @@ -36,4 +37,6 @@ :task (doseq [task '[jvm-clj-test jvm-deps-test]] (println :running... task) (run task) - (println))}}} + (println))} + + upload-artifact {:task (exec 'artifact/upload)}}} diff --git a/bb/artifact.clj b/bb/artifact.clj new file mode 100644 index 0000000..11d3b32 --- /dev/null +++ b/bb/artifact.clj @@ -0,0 +1,30 @@ +(ns artifact + (:require [borkdude.gh-release-artifact :as ghr] + [clojure.java.shell :refer [sh]] + [clojure.string :as str])) + +(defn current-branch [] + (or (System/getenv "APPVEYOR_PULL_REQUEST_HEAD_REPO_BRANCH") + (System/getenv "APPVEYOR_REPO_BRANCH") + (System/getenv "CIRCLE_BRANCH") + (System/getenv "GITHUB_REF_NAME") + (System/getenv "CIRRUS_BRANCH") + (-> (sh "git" "rev-parse" "--abbrev-ref" "HEAD") + :out + str/trim))) + +(defn upload [opts] + (assert (:file opts) "File is required") + (let [ght (System/getenv "GITHUB_TOKEN") + current-version + (-> (slurp "resources/DEPS_CLJ_VERSION") + str/trim) + branch (current-branch)] + (if (and ght (contains? #{"master" "main"} branch)) + (ghr/release-artifact (merge {:org "borkdude" + :repo "deps.clj" + :tag (str "v" current-version) + :file "README.md" + :sha256 true} + opts)) + (println "Skipping release artifact (no GITHUB_TOKEN or not on main branch)")))) diff --git a/resources/DEPS_CLJ_VERSION b/resources/DEPS_CLJ_VERSION index db19125..f9def3d 100644 --- a/resources/DEPS_CLJ_VERSION +++ b/resources/DEPS_CLJ_VERSION @@ -1 +1 @@ -1.11.1.1183-SNAPSHOT \ No newline at end of file +1.11.1.1189