Skip to content

Commit

Permalink
Prepare release
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonk committed Oct 26, 2021
1 parent 43e6f54 commit ccba70d
Show file tree
Hide file tree
Showing 6 changed files with 90 additions and 29 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ adheres to [Semantic Versioning][semver].

## [Unreleased]

## [v1.0.6] - 2021-10-26

- Allow message builder to take message from environment.
- Add a `command-output` builder.
- Fix problem with setting MODE.
- Document `$INFORM_SLACK_PROGRESS_CLOCK`.

Expand Down Expand Up @@ -40,7 +43,8 @@ adheres to [Semantic Versioning][semver].

- First actual release.

[Unreleased]: https://github.com/jasonk/inform-slack/compare/v1.0.5...HEAD
[Unreleased]: https://github.com/jasonk/inform-slack/compare/v1.0.6...HEAD
[v1.0.6]: https://github.com/jasonk/inform-slack/releases/tag/v1.0.6
[v1.0.5]: https://github.com/jasonk/inform-slack/releases/tag/v1.0.5
[v1.0.4]: https://github.com/jasonk/inform-slack/releases/tag/v1.0.4
[v1.0.3]: https://github.com/jasonk/inform-slack/releases/tag/v1.0.3
Expand Down
2 changes: 1 addition & 1 deletion bin/inform-slack
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env bash
# https://github.com/jasonk/inform-slack

export INFORM_SLACK_VERSION="v1.0.5"
export INFORM_SLACK_VERSION="v1.0.6"

export INFORM_SLACK_SELF="$(realpath -P "${BASH_SOURCE[0]}")"
export INFORM_SLACK_DIR="$(cd -P "$(dirname "$INFORM_SLACK_SELF")/.." && pwd)"
Expand Down
25 changes: 25 additions & 0 deletions builders/command-output
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/usr/bin/env bash
# https://github.com/jasonk/inform-slack

source inform-slack

shell=""

while (( $# )); do
case "$1" in
--shell) shell="$2" ; shift 2 ;;
--shell=*) shell="${1#*=}" ; shift 1 ;;
-*) usage "Unknown option '$1'" ;;
*) break ;;
esac
done

if [ -n "${shell:-}" ]; then
command=( "$shell" "-c" "$@" )
else
command=( "$@" )
fi

printf -v output '```\n%s\n```\n' "$("${command[@]}")"

block-mrkdwn "$output"
16 changes: 16 additions & 0 deletions builders/command-output.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# command-output #

This builder takes a command and it's arguments, runs the command,
captures it's output, and posts the output to Slack as
pre-formatted text.

## Usage ##

```sh
inform-slack --attach command-output 'ls -l $WORKSPACE'
```

## Options ##

* `--shell <shell>` or `--shell=<shell>` - Run the command with
a shell, rather than directly.
42 changes: 42 additions & 0 deletions dev/check-release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/usr/bin/env bash
cd "$(dirname "$0")"

REPO="https://github.com/jasonk/inform-slack"

# Executable Version
EV="$(../bin/inform-slack --version)"
# Changelog Info
CI="$(grep -E '^## \[v([0-9\.]+)\]' ../CHANGELOG.md | head -1 | tr -d '\[\]#')"
# Changelog Version
CV="$(awk '{print $1}' <<<"$CI")"
# Changelog Date
CD="$(awk '{print $3}' <<<"$CI")"
# Today's Date
TD="$(date +%F)"

if git rev-parse -q --verify "refs/tags/$EV" >/dev/null; then
echo "Version $EV already tagged, did you forget to increment it?"
fi

if [ "$TD" != "$CD" ]; then
echo "Today is $TD, but latest Changelog entry is $CD"
fi
if [ "$CV" != "$EV" ]; then
echo "Executable version is $EV, but Changelog version is $CV"
fi

UR="$(grep -E '^\[Unreleased\]:' ../CHANGELOG.md)"
if [ -z "$UR" ]; then
echo "No [Unreleased] URL in CHANGELOG"
fi
if [ "$(basename "$UR")" != "${EV}...HEAD" ]; then
echo "Wrong [Unreleased] URL in CHANGELOG"
fi

if ! grep -qE "^\[$EV\]: $REPO/releases/tag/$EV$" ../CHANGELOG.md; then
echo "No [$EV] tag in CHANGELOG"
fi

if [ -n "$(git status --porcelain=v1 2>/dev/null)" ]; then
echo "The repo has uncommitted changes"
fi
28 changes: 1 addition & 27 deletions dev/make-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,33 +14,7 @@ CD="$(awk '{print $3}' <<<"$CI")"
# Today's Date
TD="$(date +%F)"

PROBLEMS=()
if git rev-parse -q --verify "refs/tags/$EV" >/dev/null; then
PROBLEMS+=( "Version $EV already tagged, did you forget to increment it?" )
fi

if [ "$TD" != "$CD" ]; then
PROBLEMS+=( "Today is $TD, but latest Changelog entry is $CD" )
fi
if [ "$CV" != "$EV" ]; then
PROBLEMS+=( "Executable version is $EV, but Changelog version is $CV" )
fi

UR="$(grep -E '^\[Unreleased\]:' ../CHANGELOG.md)"
if [ -z "$UR" ]; then
PROBLEMS+=( "No [Unreleased] URL in CHANGELOG" )
fi
if [ "$(basename "$UR")" != "${EV}...HEAD" ]; then
PROBLEMS+=( "Wrong [Unreleased] URL in CHANGELOG" )
fi

if ! grep -qE "^\[$EV\]: $REPO/releases/tag/$EV$" ../CHANGELOG.md; then
PROBLEMS+=( "No [$EV] tag in CHANGELOG" )
fi

if [ -n "$(git status --porcelain=v1 2>/dev/null)" ]; then
PROBLEMS+=( "The repo has uncommitted changes" )
fi
readarray -t PROBLEMS < <(./check-release.sh)

if (( ${#PROBLEMS[@]} )); then
echo "Problems detected, cannot release:" 1>&2
Expand Down

0 comments on commit ccba70d

Please sign in to comment.