Skip to content

Commit

Permalink
Prep for release
Browse files Browse the repository at this point in the history
  • Loading branch information
mainej committed Aug 20, 2021
1 parent 623d22f commit 098ee5f
Show file tree
Hide file tree
Showing 8 changed files with 172 additions and 20 deletions.
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ change log follows the conventions of
[keepachangelog.com](http://keepachangelog.com/).

## [Unreleased]

## [1.4.0.32]
### Added
- Reagent interop for Tab

Expand Down Expand Up @@ -56,7 +58,8 @@ Update clojars with more repository information.
### Added
- Reagent interop with @headlessui/react for Disclosure, Transition and FocusTrap

[Unreleased]: https://github.com/mainej/headlessui-reagent/compare/v1.2.1...main
[Unreleased]: https://github.com/mainej/headlessui-reagent/compare/v1.4.0.32...main
[1.4.0.32]: https://github.com/mainej/headlessui-reagent/compare/v1.2.1...v1.4.0.32
[1.2.1]: https://github.com/mainej/headlessui-reagent/compare/v1.2.0...v1.2.1
[1.2.0]: https://github.com/mainej/headlessui-reagent/compare/v1.1.0...v1.2.0
[1.1.0]: https://github.com/mainej/headlessui-reagent/compare/v1.0.0...v1.1.0
Expand Down
16 changes: 4 additions & 12 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,19 @@ TODO: establish contributing guidelines here.

### Prepare

1. Decide on release version.
* Prefer matching release to @headlessui/react's current version:
`bin/preview-tag --version v1.2.0`
* If you need to release outside of @headlessui/react's release cycle:
`bin/preview-tag --patch` (or --minor, --major) to learn new version
number.
1. Run `bin/preview-tag` to learn new version number.
2. Proactively update CHANGELOG.md for new version number.
3. Proactively update package.json for new version number.
3. Commit
4. Commit
5. Tag commit `bin/tag-release`

### Release

Deploy to Clojars -- needs `CLOJARS_USERNAME` and `CLOJARS_PASSWORD` environment
variables:

$ envdir ../../env/clojars bin/clojars-release --version v1.2.0 # or: --patch, --minor, or --major
$ envdir ../../env/clojars bin/clojars-release

The library will be deployed to [clojars.org][clojars].

Push to github, with tags:

$ git push --follow-tags

[clojars]: https://clojars.org/com.github.mainej/headlessui-reagent
3 changes: 1 addition & 2 deletions bin/clojars-release
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,4 @@

set -Eeuo pipefail

# expects --patch, --minor, or --major
clojure -M:release "$@"
clojure -T:build release
4 changes: 2 additions & 2 deletions bin/preview-tag
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@

set -Eeuo pipefail

# expects --patch, --minor, or --major
clojure -M:release tag --dry-run "$@"
echo "The tag for this commit would be" $(clojure -T:build current-tag)
echo "The tag for the next commit would be" $(clojure -T:build preview-tag)
5 changes: 5 additions & 0 deletions bin/tag-release
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env bash

set -Eeuo pipefail

exec git tag $(clojure -T:build current-tag)
7 changes: 5 additions & 2 deletions deps.edn
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
{:paths ["src"]
:deps {}
:aliases {:release {:extra-deps {applied-science/deps-library {:mvn/version "0.4.0"}}
:main-opts ["-m" "applied-science.deps-library"]}}}
:aliases {;; for help: clojure -A:deps -T:build help/doc
:build {:paths ["dev"]
:deps {io.github.clojure/tools.build {:git/tag "v0.1.8" :git/sha "38d2780"}
slipset/deps-deploy {:mvn/version "0.1.5"}}
:ns-default build}}}
150 changes: 150 additions & 0 deletions dev/build.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
(ns build
(:require
[clojure.java.io :as jio]
[clojure.string :as string]
[clojure.tools.build.api :as b]
[deps-deploy.deps-deploy :as d]))

(def ^:private lib 'com.github.mainej/headlessui-reagent)
(def ^:private git-revs (Integer/parseInt (b/git-count-revs nil)))
(defn- format-version [revision] (format "1.4.0.%s" revision))
(def ^:private version (format-version git-revs))
(def ^:private next-version (format-version (inc git-revs)))
(def ^:private tag (str "v" version))
(def ^:private next-tag (str "v" next-version))
(def ^:private class-dir "target/classes")
(def ^:private basis (b/create-basis {:root nil
:user nil
:project "deps.edn"}))
(def ^:private jar-file (format "target/%s-%s.jar" (name lib) version))
(def ^:private pom-dir (jio/file (b/resolve-path class-dir) "META-INF" "maven" (namespace lib) (name lib)))

#_{:clj-kondo/ignore #{:clojure-lsp/unused-public-var}}
(defn current-tag "Show the tag for the current release." [params]
(println tag)
params)

#_{:clj-kondo/ignore #{:clojure-lsp/unused-public-var}}
(defn preview-tag
"Show the tag for the next release.
This tag should be used in the CHANGELOG. After those edits are committed, run
`bin/tag-release`. This tag will be assigned to the CHANGELOG commit."
[params]
(println next-tag)
params)

(defn clean "Remove the target folder." [params]
(b/delete {:path "target"})
params)

(defn- die
([code message & args]
(die code (apply format message args)))
([code message]
(binding [*out* *err*]
(println message))
(System/exit code)))

(defn- git-rev []
(let [{:keys [exit out]} (b/process {:command-args ["git" "rev-parse" "HEAD"]
:out :capture})]
(when (zero? exit)
(string/trim out))))

(defn jar "Build the library JAR file." [params]
(b/write-pom {:class-dir class-dir
:lib lib
:version version
:scm {:tag (git-rev)}
:basis basis
:src-dirs ["src"]})
(b/copy-dir {:src-dirs ["src" "resources"]
:target-dir class-dir})
(b/jar {:class-dir class-dir
:jar-file jar-file})
params)

(defn- assert-changelog-updated [params]
(when-not (string/includes? (slurp "CHANGELOG.md") tag)
(die 10 "CHANGELOG.md must include tag.\n * If you will amend the current commit, use %s\n * If you intend to create a new commit, use %s" tag next-tag))
params)

(defn- assert-package-json-updated [params]
(when-not (string/includes? (slurp "package.json") version)
(die 10 "package.json must include version.\n * If you will amend the current commit, use %s\n * If you intend to create a new commit, use %s" version next-version))
params)

(defn- assert-scm-clean [params]
(when-not (-> {:command-args ["git" "status" "--porcelain"]
:out :capture}
b/process
:out
string/blank?)
(die 12 "Git working directory must be clean."))
params)

(defn- assert-scm-tagged [params]
(when-not (-> {:command-args ["git" "rev-list" tag]
:out :ignore
:err :ignore}
b/process
:exit
zero?)
(die 13 "Git tag %s must exist. Run bin/tag-release" tag))
(let [{:keys [exit out]} (b/process {:command-args ["git" "describe" "--tags" "--abbrev=0" "--exact-match"]
:out :capture})]
(when (or (not (zero? exit))
(not= (string/trim out) tag))
(die 14 "Git tag %s must be on HEAD." tag)))
params)

(defn- git-push [params]
(when (or (-> {:command-args ["git" "push" "origin" tag]
:out :ignore
:err :ignore}
b/process
:exit
zero?
not)
(-> {:command-args ["git" "push" "origin"]
:out :ignore
:err :ignore}
b/process
:exit
zero?
not))
(die 15 "Couldn't sync with github."))
params)

#_{:clj-kondo/ignore #{:clojure-lsp/unused-public-var}}
(defn release
"Release the library.
* Confirm that we are ready to release
* No outstanding commits
* Git tag for current release exists in local repo
* CHANGELOG.md references new tag
* Build the JAR
* Deploy to Clojars
* Ensure the tag is available on Github"
[params]
(assert-changelog-updated params)
(assert-package-json-updated params)
;; after assertions about
(assert-scm-clean params)
;; last, so that changes initiated by prior changes
(assert-scm-tagged params)
(jar params)
(d/deploy {:installer :remote
:artifact jar-file
:pom-file (jio/file pom-dir "pom.xml")})
(git-push params)
params)

(comment
(clean nil)
(jar nil)
(git-push nil)
(assert-changelog-updated nil)
)
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "headlessui-reagent",
"version": "1.2.1",
"version": "1.4.0.32",
"description": "Adapts headlessui for use with Reagent",
"repository": {
"type": "git",
Expand Down

0 comments on commit 098ee5f

Please sign in to comment.