diff --git a/Changelog.md b/Changelog.md new file mode 100644 index 0000000..ddb66c9 --- /dev/null +++ b/Changelog.md @@ -0,0 +1,16 @@ +# Changelog +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). + +## Unreleased +### Added +### Changed +### Deprecated +### Removed +### Fixed + +## [v0.1.0.0] - 2020-02-06 +First release. +### Added +- Changelog file and related tooling. diff --git a/README.md b/README.md index 4510921..f1daf1c 100644 --- a/README.md +++ b/README.md @@ -228,6 +228,11 @@ You're looking for managing an app but it's not included in `sdd` yet? Here's ho 1. Add the new files, commit, and push. 1. Open a PR! +### Releasing + +1. Update Changelog. +1. Run `./release VERSION` + ## Python apps Consider using [`pipx`](https://pipxproject.github.io/pipx/) for installing Python applications (in isolated environments). diff --git a/bootstrap.sh b/bootstrap.sh index 0b83dca..f42cebf 100755 --- a/bootstrap.sh +++ b/bootstrap.sh @@ -16,6 +16,18 @@ if [[ ! "$PATH" == *"$prefix/bin"* ]]; then fi # Record installed version +latest_tag="$(git tag --list --sort -refname | grep -m1 -E 'v0.[0-9]+.[0-9]+.[0-9]+')" +[ $? -ne 0 ] && exit 1 + +head_sha="$(git rev-parse HEAD)" +if [[ "$(git rev-parse "$latest_tag")" != "$head_sha" ]]; then + # construct version identifier of form 'v0.X.Y.Z (+N @d34dc0ffee)' + nr_commits_since_latest_tag="$(git rev-list "$latest_tag".. --count)" + latest_tag="$latest_tag (+$nr_commits_since_latest_tag @$head_sha)" +fi + +echo "$latest_tag" > "$prefix"/lib/sdd/version + SDD_APPS_DIR=${XDG_DATA_DIR:-$HOME/.local/share}/sdd/apps mkdir -p "$SDD_APPS_DIR" -echo sdd="$(git rev-parse HEAD)" >> "$SDD_APPS_DIR"/installed +echo sdd="$head_sha" >> "$SDD_APPS_DIR"/installed diff --git a/lib/sdd/apps/user/sdd b/lib/sdd/apps/user/sdd index eba436e..585425a 100644 --- a/lib/sdd/apps/user/sdd +++ b/lib/sdd/apps/user/sdd @@ -20,5 +20,5 @@ sdd_uninstall() { } sdd_fetch_latest_version() { - _sha_of_github_master pylipp sdd + _tag_name_of_latest_github_release pylipp sdd } diff --git a/lib/sdd/framework/utils.bash b/lib/sdd/framework/utils.bash index 3a6647a..f2c9368 100644 --- a/lib/sdd/framework/utils.bash +++ b/lib/sdd/framework/utils.bash @@ -33,12 +33,14 @@ END_OF_HELP_TEXT utils_version() { # Publish version of present sdd installation to stdout - if [ ! -e "$SDD_DATA_DIR"/apps/installed ]; then - printf 'Cannot find %s.\n' "$SDD_DATA_DIR"/apps/installed >&2 - return 1; + local version_filepath + version_filepath="$FRAMEWORKDIR"/../version + if [ ! -e "$version_filepath" ]; then + printf 'Cannot find %s.\n' "$version_filepath" >&2 + return 1 fi - tac "$SDD_DATA_DIR"/apps/installed | grep -m 1 '^sdd=' | cut -d '=' -f2 + cat "$version_filepath" } _validate_apps() { diff --git a/release b/release new file mode 100755 index 0000000..d48844e --- /dev/null +++ b/release @@ -0,0 +1,17 @@ +#!/usr/bin/env bash + +if [ $# -ne 1 ]; then + printf "Usage: %s VERSION\n" "$0" >&2 + exit 1 +fi + +version="$1" +if ! echo "$version" | grep -m1 -E 'v0.[0-9]+.[0-9]+.[0-9]+' >/dev/null 2>&1; then + printf "Version '%s' not in format v0.X.Y.Z\n" "$version" >&2 + exit 1 +fi + +set -e +git tag "$version" +git push --tags origin master +hub release create -m "$version" -m "$(awk -v RS='' "/\[$version\]/" Changelog.md | tail -n+2)" -e -o "$version" diff --git a/test/framework/bootstrap.bats b/test/framework/bootstrap.bats index 8c448cd..066649b 100644 --- a/test/framework/bootstrap.bats +++ b/test/framework/bootstrap.bats @@ -16,6 +16,9 @@ teardown() { run "$HOME/.local/bin/sdd" [ "$status" -eq 0 ] + + run grep '^v' <("$HOME/.local/bin/sdd" --version) + [ "$status" -eq 0 ] } @test "Custom sdd installation succeeds" {