Skip to content

Commit

Permalink
Merge pull request #163 from liquidz/feature/release
Browse files Browse the repository at this point in the history
Update to use build.edn
  • Loading branch information
liquidz authored May 22, 2022
2 parents 79d24dc + ec9b51d commit 61e2e81
Show file tree
Hide file tree
Showing 14 changed files with 148 additions and 184 deletions.
30 changes: 0 additions & 30 deletions .github/workflows/deploy.yml

This file was deleted.

27 changes: 0 additions & 27 deletions .github/workflows/docker.yml

This file was deleted.

78 changes: 78 additions & 0 deletions .github/workflows/release.yml
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 }}
9 changes: 0 additions & 9 deletions .github/workflows/static.yml

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ jobs:
test:
strategy:
matrix:
java: ['8', '11', '16', '17-ea']
java: ['8', '11', '17']

runs-on: ubuntu-latest
steps:
Expand Down
8 changes: 8 additions & 0 deletions CHANGELOG.adoc
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
All notable changes to this project will be documented in this file. This change log follows the conventions of http://keepachangelog.com/[keepachangelog.com].

== Unreleased (dev)
// {{{
=== Changed
* Changed to use https://github.com/liquidz/build.edn[build.edn].
* Changed version format to `MAJOR.MINOR.COMMIT`.

=== Fixed
* Fixed `dep.github-action.matrix` not to throw exception with integer.
// }}}

== 1.6.2 (2022-05-14)
// {{{
Expand Down
8 changes: 4 additions & 4 deletions Dockerfile
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"]
129 changes: 46 additions & 83 deletions build.clj
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)))
8 changes: 1 addition & 7 deletions deps.edn
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,9 @@
:main-opts ["-m" "cloverage.coverage" "--ns-exclude-regex" "leiningen.antq"]}

:build
{:deps {io.github.clojure/tools.build {:git/tag "v0.8.2" :git/sha "ba1a2bf"}
slipset/deps-deploy {:mvn/version "0.2.0"}}
{:deps {com.github.liquidz/build.edn {:git/tag "0.1.49" :git/sha "2e03312"}}
:ns-default build}

:deploy
{:extra-deps {slipset/deps-deploy {:mvn/version "RELEASE"}}
:exec-fn deps-deploy.deps-deploy/deploy
:exec-args {}}

;; -X
:latest
{:extra-deps {org.slf4j/slf4j-nop {:mvn/version "RELEASE"}}
Expand Down
15 changes: 0 additions & 15 deletions script/version_check.sh

This file was deleted.

2 changes: 1 addition & 1 deletion src/antq/core.clj
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@
(u.maven/initialize-proxy-setting!)
(let [options (cond-> options
;; Force "format" reporter when :error-format is specified
(some? (:error-format options)) (assoc :reporter "format"))
(some? (:error-format options)) (assoc :reporter "format"))
deps (and (not errors)
(fetch-deps options))]
(cond
Expand Down
3 changes: 2 additions & 1 deletion src/antq/dep/github_action/matrix.clj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

(defn- matrix-variable-name
[version]
(when-let [[[_ vname]] (re-seq #"\$\{\{\s*matrix\.(.+?)\s*}}" version)]
(when-let [[[_ vname]] (re-seq #"\$\{\{\s*matrix\.(.+?)\s*}}"
(str version))]
vname))

(defn expand-matrix-value
Expand Down
Loading

0 comments on commit 61e2e81

Please sign in to comment.