-
-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #163 from liquidz/feature/release
Update to use build.edn
- Loading branch information
Showing
14 changed files
with
148 additions
and
184 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,78 @@ | ||
name: Tag and Release | ||
on: workflow_dispatch | ||
|
||
env: | ||
REGISTRY: ghcr.io | ||
IMAGE_NAME: ${{ github.repository }} | ||
|
||
jobs: | ||
tag-and-release: | ||
runs-on: ubuntu-latest | ||
permissions: write-all | ||
outputs: | ||
version: ${{ steps.deploy.outputs.version }} | ||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
- uses: actions/setup-java@v3 | ||
with: | ||
distribution: 'adopt' | ||
java-version: 11 | ||
- uses: DeLaGuardo/setup-clojure@master | ||
with: | ||
cli: latest | ||
|
||
- name: Show versions | ||
run: | | ||
java -version | ||
clojure --version | ||
- uses: actions/cache@v3 | ||
with: | ||
path: ~/.m2 | ||
key: test-m2-${{ hashFiles('deps.edn') }}-v1 | ||
|
||
- name: deploy to clojars | ||
id: deploy | ||
run: clojure -T:build deploy | ||
env: | ||
CLOJARS_PASSWORD: ${{secrets.CLOJARS_PASSWORD}} | ||
CLOJARS_USERNAME: ${{secrets.CLOJARS_USERNAME}} | ||
|
||
- uses: actions/create-release@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
tag_name: ${{ steps.deploy.outputs.version }} | ||
release_name: ${{ steps.deploy.outputs.version }} | ||
body: released | ||
draft: false | ||
prerelease: false | ||
|
||
- run: | | ||
clojure -T:build update-documents | ||
git diff | ||
git config --global user.email "github-actions@example.com" | ||
git config --global user.name "github-actions" | ||
git add -A | ||
git commit -m "Update for release" || exit 0 | ||
git push | ||
docker-push: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: docker login | ||
run: | | ||
echo ${{ secrets.CONTAINER_REGISTRY_TOKEN }} | docker login ${{ env.REGISTRY }} -u $GITHUB_ACTOR --password-stdin | ||
docker pull ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest | ||
# FIXME docker build . -t ...:latest -t ...:ref | ||
- name: build latest | ||
run: | | ||
docker build . -t ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest --cache-from ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest | ||
docker push ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest | ||
- name: build for tag | ||
run: | | ||
docker build . -t ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ needs.tag-and-release.outputs.version }} --cache-from ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest | ||
docker push ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ needs.tag-and-release.outputs.version }} |
This file was deleted.
Oops, something went wrong.
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
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
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,12 +1,12 @@ | ||
FROM clojure:openjdk-15-tools-deps-1.10.1.739 | ||
FROM clojure:openjdk-17-tools-deps | ||
|
||
RUN apt-get update && apt-get install -y git && rm -rf /var/lib/apt/lists/* | ||
|
||
WORKDIR /tmp/antq | ||
COPY deps.edn /tmp/antq/deps.edn | ||
COPY build.clj /tmp/antq/build.clj | ||
COPY src/ /tmp/antq/src/ | ||
RUN clojure -Spom && \ | ||
clojure -X:depstar uberjar :jar antq.jar :aot true :main-class antq.core :aliases '[:nop]' | ||
RUN clojure -T:build uberjar | ||
|
||
WORKDIR /tmp | ||
ENTRYPOINT ["java", "-jar", "/tmp/antq/antq.jar"] | ||
ENTRYPOINT ["java", "-jar", "/tmp/antq/target/antq-standalone.jar"] |
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,93 +1,56 @@ | ||
(ns build | ||
(:require | ||
[clojure.tools.build.api :as b] | ||
[clojure.xml :as xml] | ||
[deps-deploy.deps-deploy :as deploy])) | ||
|
||
(def ^:private class-dir "target/classes") | ||
(def ^:private jar-file "target/antq.jar") | ||
(def ^:private lib 'com.github.liquidz/antq) | ||
(def ^:private main 'antq.core) | ||
(def ^:private pom-file "./pom.xml") | ||
(def ^:private uber-file "target/antq-standalone.jar") | ||
|
||
(defn- get-basis | ||
[opt] | ||
(-> (select-keys opt [:aliases]) | ||
(merge {:project "deps.edn"}) | ||
(b/create-basis))) | ||
|
||
(defn- get-current-version | ||
[pom-file-path] | ||
(->> (xml/parse pom-file-path) | ||
(xml-seq) | ||
(some #(and (= :version (:tag %)) %)) | ||
(:content) | ||
(first))) | ||
|
||
(defn pom | ||
[arg] | ||
(let [basis (or (:basis arg) (get-basis arg)) | ||
lib' (or (:lib arg) lib) | ||
ver' (or (:version arg) (get-current-version pom-file))] | ||
(b/write-pom {:basis basis | ||
:class-dir class-dir | ||
:lib lib' | ||
:version ver' | ||
:src-dirs ["src"]}) | ||
(when (:copy? arg true) | ||
(b/copy-file {:src (b/pom-path {:lib lib' :class-dir class-dir}) | ||
:target pom-file})))) | ||
[build-edn.core :as build-edn])) | ||
|
||
(def ^:private config | ||
{:lib 'com.github.liquidz/antq | ||
:version "1.6.{{commit-count}}" | ||
:main 'antq.core | ||
:scm {:connection "scm:git:git://github.com/liquidz/antq.git" | ||
:developerConnection "scm:git:ssh://git@github.com/liquidz/antq.git" | ||
:url "https://github.com/liquidz/antq"} | ||
:documents [{:file "CHANGELOG.adoc" | ||
:match "Unreleased" | ||
:action :append-after | ||
:text "\n== {{version}} ({{yyyy-mm-dd}})"} | ||
{:file "README.adoc" | ||
:match "install com\\.github\\.liquidz/antq" | ||
:action :replace | ||
:text "clojure -Ttools install com.github.liquidz/antq '{:git/tag \"{{version}}\"}' :as antq"}] | ||
:github-actions? true}) | ||
|
||
(defn jar | ||
[arg] | ||
(let [basis (get-basis {}) | ||
arg (assoc arg :basis basis)] | ||
(pom arg) | ||
(b/copy-dir {:src-dirs (:paths basis) | ||
:target-dir class-dir}) | ||
(b/jar {:class-dir class-dir | ||
:jar-file jar-file}))) | ||
[m] | ||
(-> (merge config m) | ||
(build-edn/jar))) | ||
|
||
(defn uberjar | ||
[arg] | ||
(let [;; NOTE: To include org.slf4j/slf4j-nop | ||
basis (get-basis {:aliases [:nop]}) | ||
arg (assoc arg | ||
:basis basis | ||
:copy? false)] | ||
(pom arg) | ||
(b/copy-dir {:src-dirs (:paths basis) | ||
:target-dir class-dir}) | ||
(b/compile-clj {:basis basis | ||
;; NOTE: does not contain src/leiningen | ||
:src-dirs ["src/antq"] | ||
:class-dir class-dir}) | ||
(b/uber {:class-dir class-dir | ||
:uber-file uber-file | ||
:basis basis | ||
:main main}))) | ||
[m] | ||
(-> (merge config m) | ||
(assoc | ||
;; NOTE: To include org.slf4j/slf4j-nop | ||
:aliases [:nop] | ||
;; NOTE: does not contain src/leiningen | ||
:src-dirs ["src/antq"]) | ||
(build-edn/uberjar))) | ||
|
||
(defn install | ||
[arg] | ||
(jar arg) | ||
(deploy/deploy {:artifact jar-file | ||
:installer :local})) | ||
[m] | ||
(-> (merge config m) | ||
(build-edn/install))) | ||
|
||
(defn deploy | ||
[arg] | ||
(assert (and (System/getenv "CLOJARS_USERNAME") | ||
(System/getenv "CLOJARS_PASSWORD"))) | ||
(jar arg) | ||
(deploy/deploy {:artifact jar-file | ||
:installer :remote | ||
:pom-file (b/pom-path {:lib (or (:lib arg) lib) | ||
:class-dir class-dir})})) | ||
|
||
(defn deploy-snapshot | ||
[arg] | ||
(let [version (str (get-current-version pom-file) | ||
"-SNAPSHOT")] | ||
(deploy (assoc arg | ||
:version version | ||
:copy? false)))) | ||
[m] | ||
(let [config (merge config m)] | ||
(build-edn/deploy (assoc config :lib 'antq/antq)) | ||
(build-edn/deploy config))) | ||
|
||
(defn update-documents | ||
[m] | ||
(-> (merge config m) | ||
(build-edn/update-documents))) | ||
|
||
(defn lint | ||
[m] | ||
(-> (merge config m) | ||
(build-edn/lint))) |
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
This file was deleted.
Oops, something went wrong.
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
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
Oops, something went wrong.