From ef59484a5f276f4804ff4af272e38cd81dac2e68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Tue, 24 Dec 2024 07:44:12 +0100 Subject: [PATCH] add release script --- scripts/create-release.sh | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100755 scripts/create-release.sh diff --git a/scripts/create-release.sh b/scripts/create-release.sh new file mode 100755 index 00000000..a868d5b8 --- /dev/null +++ b/scripts/create-release.sh @@ -0,0 +1,37 @@ +#!/usr/bin/env bash + +set -eu -o 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:nix-community/nixos-anywhere 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 +sed -i -e "s!version = \".*\"\$!version = \"${version}\"!" default.nix +git add src/default.nix +nix-shell -p nix-fast-build --command "nix-fast-build --eval-workers 2" +git commit -m "bump version ${version}" +git tag "${version}" + +echo "now run 'git push --tags origin main'"