Skip to content

Commit

Permalink
Add a script for making releases
Browse files Browse the repository at this point in the history
  • Loading branch information
Miikka Koskinen committed May 5, 2020
1 parent a5a285b commit 370365a
Show file tree
Hide file tree
Showing 3 changed files with 88 additions and 1 deletion.
17 changes: 17 additions & 0 deletions docs/11_developer_guide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Developer guide

## Running tests

```sh
./scripts/test.sh clj
./scripts/test.sh cljs
```


## Creating a release

1. Update `CHANGELOG.md`
2. Set the appropriate version in `project.clj` and commit and push.
3. Run `./scripts/release.sh`

The actual building of the release artifact is done by the CI service.
3 changes: 2 additions & 1 deletion project.clj
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
[lein-doo "0.1.11"]
[lein-cljsbuild "1.1.7"]
[lein-cloverage "1.1.1"]
[lein-codox "0.10.7"]]
[lein-codox "0.10.7"]
[lein-pprint "1.3.2"]]
:jvm-opts ^:replace ["-server"]
;:global-vars {*warn-on-reflection* true}
:dependencies [[org.clojure/clojure "1.10.0"]
Expand Down
69 changes: 69 additions & 0 deletions scripts/release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
#!/usr/bin/env bash
# Release a new version

set -euo pipefail

if ! hub version > /dev/null; then
echo "The hub tool is needed. If you're on macOS, you can install it with \`brew install hub\`"
exit 1
fi

BRANCH=$(git rev-parse --abbrev-ref HEAD)

if [[ "$BRANCH" != "master" ]]; then
echo "This script only works in the master branch."
exit 1
fi

if ! git diff-index --quiet HEAD -- project.clj; then
echo "project.clj contains uncommited changes. Commit them first."
exit 1
fi

if ! git merge-base --is-ancestor "master@{u}" master; then
echo "The master branch has not been pushed. Please git push."
exit 1
fi

VERSION=$(lein pprint --no-pretty -- :version)

echo "Version in project.clj: $VERSION"

case "$VERSION" in
*-SNAPSHOT)
echo ""
echo "SNAPSHOT releases are not supported. You can \`lein deploy\` them yourself."
exit 1
;;
esac

echo "Going to release version $VERSION... is this correct? [y/n]"

read -r answer
case "$answer" in
y | Y | yes | YES)
;;
*)
echo "Exiting"
exit 1
;;
esac

if hub release show "$VERSION" 2>/dev/null; then
echo
echo "Release $VERSION already exists"
exit 1
else
echo "* Release $VERSION does not yet exist"
fi

# Let's just check if the chanelog contains an appropriate title
if ! grep -q -F "# $VERSION " CHANGELOG.md; then
echo
echo "Please update CHANGELOG to contain the release $VERSION"
exit 1
else
echo "* Changelog has been updated"
fi

hub release create -m "$VERSION" "$VERSION"

0 comments on commit 370365a

Please sign in to comment.