-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add deploy task to build script * Add Github action for auto-deploying master * Use POM settings more consistently
- Loading branch information
1 parent
4f8e0ec
commit 06fcb15
Showing
2 changed files
with
104 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,44 @@ | ||
# name: Deploy | ||
# | ||
# on: | ||
# push: | ||
# branches: | ||
# - master | ||
# | ||
# jobs: | ||
# deploy: | ||
# runs-on: ubuntu-20.04 | ||
# environment: Deployment | ||
# steps: | ||
# - uses: actions/[email protected] | ||
# with: | ||
# fetch-depth: 0 | ||
# - name: Prepare JDK 17 | ||
# uses: actions/setup-java@v3 | ||
# with: | ||
# java-version: 17 | ||
# distribution: 'temurin' | ||
# - name: Setup Clojure | ||
# uses: DeLaGuardo/[email protected] | ||
# with: | ||
# cli: 1.11.1.1413 | ||
# - name: Restore cache | ||
# uses: actions/cache@v3 | ||
# with: | ||
# path: | | ||
# ~/.m2/repository | ||
# ~/.gitlibs | ||
# ~/.deps.clj | ||
# key: v1-${{ hashFiles('./deps.edn') }}-deploy | ||
# restore-keys: | | ||
# v1-${{ hashFiles('./deps.edn') }}- | ||
# v1- | ||
# - name: Build Macaw | ||
# run: clojure -T:build build | ||
# env: | ||
# GITHUB_SHA: ${{ env.GITHUB_SHA }} | ||
# - name: Deploy Macaw | ||
# run: clojure -T:build deploy | ||
# env: | ||
# CLOJARS_USERNAME: ${{ secrets.CLOJARS_USERNAME }} | ||
# CLOJARS_PASSWORD: ${{ secrets.CLOJARS_PASSWORD }} | ||
name: Deploy | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
|
||
jobs: | ||
deploy: | ||
runs-on: ubuntu-20.04 | ||
environment: Deployment | ||
steps: | ||
- uses: actions/[email protected] | ||
with: | ||
fetch-depth: 0 | ||
- name: Prepare JDK 17 | ||
uses: actions/setup-java@v3 | ||
with: | ||
java-version: 17 | ||
distribution: 'temurin' | ||
- name: Setup Clojure | ||
uses: DeLaGuardo/[email protected] | ||
with: | ||
cli: 1.11.1.1413 | ||
- name: Restore cache | ||
uses: actions/cache@v3 | ||
with: | ||
path: | | ||
~/.m2/repository | ||
~/.gitlibs | ||
~/.deps.clj | ||
key: v1-${{ hashFiles('./deps.edn') }}-deploy | ||
restore-keys: | | ||
v1-${{ hashFiles('./deps.edn') }}- | ||
v1- | ||
- name: Build Macaw | ||
run: clojure -T:build jar | ||
env: | ||
GITHUB_SHA: ${{ env.GITHUB_SHA }} | ||
- name: Deploy Macaw | ||
run: clojure -T:build deploy | ||
env: | ||
CLOJARS_USERNAME: ${{ secrets.CLOJARS_USERNAME }} | ||
CLOJARS_PASSWORD: ${{ secrets.CLOJARS_PASSWORD }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,9 +4,12 @@ | |
(:require | ||
[clojure.java.shell :as sh] | ||
[clojure.string :as str] | ||
[clojure.tools.build.api :as b])) | ||
[clojure.tools.build.api :as b] | ||
[deps-deploy.deps-deploy :as dd])) | ||
|
||
(def lib 'metabase/macaw) | ||
(def lib 'io.github.metabase/macaw) | ||
(def github-url "https://github.com/metabase/macaw") | ||
(def scm-url "[email protected]:metabase/macaw.git") | ||
|
||
(def major-minor-version "0.1") | ||
|
||
|
@@ -17,6 +20,12 @@ | |
parse-long) | ||
"9999-SNAPSHOT")) | ||
|
||
(def sha | ||
(or (not-empty (System/getenv "GITHUB_SHA")) | ||
(not-empty (-> (sh/sh "git" "rev-parse" "HEAD") | ||
:out | ||
str/trim)))) | ||
|
||
(def version (str major-minor-version \. (commit-number))) | ||
(def target "target") | ||
(def class-dir (format "%s/classes" target)) | ||
|
@@ -25,23 +34,60 @@ | |
|
||
(def basis (delay (b/create-basis {:project "deps.edn"}))) | ||
|
||
(def pom-template | ||
[[:description "A Clojure wrapper for JSqlParser"] | ||
[:url github-url] | ||
[:licenses | ||
[:license | ||
[:name "Eclipse Public License"] | ||
[:url "http://www.eclipse.org/legal/epl-v10.html"]]] | ||
[:developers | ||
[:developer | ||
[:name "Tim Macdonald"]]] | ||
[:scm | ||
[:url github-url] | ||
[:connection (str "scm:git:" scm-url)] | ||
[:developerConnection (str "scm:git:" scm-url)] | ||
[:tag sha]]]) | ||
|
||
(def default-options | ||
{:lib lib | ||
:version version | ||
:jar-file jar-file | ||
:basis @basis | ||
:class-dir class-dir | ||
:target target | ||
:src-dirs ["src" "java"] | ||
:pom-data pom-template}) | ||
|
||
(defn clean [_] | ||
(b/delete {:path target})) | ||
|
||
(defn compile [_] | ||
(b/javac {:src-dirs ["java"] | ||
:class-dir class-dir | ||
:basis @basis | ||
:javac-opts ["--release" "11"]})) | ||
(defn compile [opts] | ||
(println "\nCompiling Java files...") | ||
(b/javac (merge default-options | ||
opts | ||
{:src-dirs ["java"] | ||
:javac-opts ["--release" "11"]}))) | ||
|
||
(defn jar [_] | ||
(defn jar [opts] | ||
(println "\nStarting to build a JAR...") | ||
(compile nil) | ||
(b/write-pom {:class-dir class-dir | ||
:lib lib | ||
:version version | ||
:basis @basis | ||
:src-dirs ["src"]}) | ||
(println "\tWriting pom.xml...") | ||
(b/write-pom (merge default-options opts)) | ||
(println "\tCopying source...") | ||
(b/copy-dir {:src-dirs ["src" "resources"] | ||
:target-dir class-dir}) | ||
(printf "\tBuilding %s...\n" jar-file) | ||
(b/jar {:class-dir class-dir | ||
:jar-file jar-file})) | ||
:jar-file jar-file}) | ||
(println "Done! 🦜")) | ||
|
||
|
||
(defn deploy [opts] | ||
(let [opts (merge default-options opts)] | ||
(printf "Deploying %s...\n" jar-file) | ||
(dd/deploy {:installer :remote | ||
:artifact (b/resolve-path jar-file) | ||
:pom-file (b/pom-path (select-keys opts [:lib :class-dir]))}) | ||
(println "Deployed! 🦜"))) |