Skip to content

Commit

Permalink
improve release script
Browse files Browse the repository at this point in the history
  • Loading branch information
tek committed Sep 26, 2023
1 parent fa9f26b commit bfd5103
Showing 1 changed file with 29 additions and 14 deletions.
43 changes: 29 additions & 14 deletions lib/release.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,35 @@

inherit (config.internal) pkgs;

git = "${pkgs.git}/bin/git";

preamble = ''
#!${pkgs.zsh}/bin/zsh
setopt err_exit no_unset pipefail
if [[ $# == 0 ]]
then
echo 'Please specify version'
echo 'Error: Please specify version'
exit 1
fi
version="$1"
if ! ${git} diff --quiet
then
echo 'Error: Worktree is dirty'
exit 1
fi
ask() {
echo -n ">>> $1 [Yn] "
read -q decision || true
echo ""
[[ $decision != 'n' ]]
}
'';

updateVersions = ''
echo -n ">>> Run tests? [Yn] "
read -q decision || true
echo ""
if [[ $decision != 'n' ]]
if ask 'Run tests?'
then
nix build .#docs
nix run .#test
Expand All @@ -27,13 +39,19 @@
sed -Ei 's/~[[:digit:]]+\.[[:digit:]]+\.tar/~'"''${version%.*}.tar/" readme.md
sed -i 's/hixVersion = ".*"/hixVersion = "'"$version"'"/' modules/basic.nix
sed -i "s/Unreleased/$version/" changelog.md
${pkgs.git}/bin/git --no-pager diff
${pkgs.git}/bin/git add readme.md changelog.md examples modules/basic.nix
${git} --no-pager diff
if ! ask 'Versions updated. Continue?'
then
${git} reset --hard
echo ">>> Aborting."
exit 1
fi
${git} add .
'';

commitAndTag = ''
${pkgs.git}/bin/git commit --allow-empty -m "Release $version"
${pkgs.git}/bin/git tag -m "Release $version" "$version"
${git} commit --allow-empty -m "Release $version"
${git} tag -m "Release $version" "$version"
'';

nix = pkgs.writeScript "hix-release-nix" ''
Expand All @@ -47,15 +65,12 @@
${updateVersions}
nix run .#release -- -v $version
echo -n ">>> Update CLI version in overrides. Continue? [Yn] "
read -q decision || true
echo ""
if [[ $decision == 'n' ]]
if ! ask 'Update CLI version in overrides. Continue?'
then
echo ">>> Aborting."
exit 1
fi
${pkgs.git}/bin/git add modules/cli.nix
${git} add modules/cli.nix
${commitAndTag}
'';

Expand Down

0 comments on commit bfd5103

Please sign in to comment.