diff --git a/bin/create-release.sh b/bin/create-release.sh new file mode 100755 index 0000000..7667fb8 --- /dev/null +++ b/bin/create-release.sh @@ -0,0 +1,42 @@ +#!/usr/bin/env bash + +set -euo pipefail + +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null && pwd)" +cd "$SCRIPT_DIR/.." + +version="${1:-}" +if [[ -z $version ]]; then + echo "USAGE: $0 version" >&2 + exit 1 +fi + +if [[ "$(git symbolic-ref --short HEAD)" != "main" ]]; then + echo "must be on main branch" >&2 + exit 1 +fi + +# ensure we are up-to-date +uncommitted_changes=$(git diff --compact-summary) +if [[ -n $uncommitted_changes ]]; then + echo -e "There are uncommitted changes, exiting:\n${uncommitted_changes}" >&2 + exit 1 +fi +git pull git@github.com:Mic92/nixos-shell main +unpushed_commits=$(git log --format=oneline origin/main..main) +if [[ $unpushed_commits != "" ]]; then + echo -e "\nThere are unpushed changes, exiting:\n$unpushed_commits" >&2 + exit 1 +fi +# make sure tag does not exist +if git tag -l | grep -q "^${version}\$"; then + echo "Tag ${version} already exists, exiting" >&2 + exit 1 +fi +echo "$version" > version.txt +git add version.txt +git commit -m "bump version ${version}" +git push origin main +git tag "${version}" +git push origin "${version}" +gh release create "${version}" --draft --title "${version}" --generate-notes diff --git a/default.nix b/default.nix index 12dfa0b..0133e2e 100644 --- a/default.nix +++ b/default.nix @@ -4,7 +4,7 @@ with pkgs; stdenv.mkDerivation { - name = "nixos-shell"; + name = "nixos-shell-${lib.fileContents ./version.txt}"; src = builtins.filterSource (path: type: baseNameOf path != "nixos.qcow2" && baseNameOf path != ".git" && diff --git a/version.txt b/version.txt new file mode 100644 index 0000000..7ec1d6d --- /dev/null +++ b/version.txt @@ -0,0 +1 @@ +2.1.0