Something went wrong. Try again.
forked from nix-community/disko
Something went wrong. Try again.
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273#! /usr/bin/env bash
# Don't run directly! Instead, use# nix run .#create-release
version=${1:-}if [[ -z "$version" ]]; then echo "USAGE: nix run .#create-release -- <version>" >&2 exit 1fi
# Check if we're running from the root of the repositoryif [[ ! -f "flake.nix" || ! -f "version.nix" ]]; then echo "This script must be run from the root of the repository" >&2 exit 1fi
# Check if the version matches the semver pattern (without suffixes)semver_regex="^([0-9]+)\.([0-9]+)\.([0-9]+)$"if [[ ! "$version" =~ $semver_regex ]]; then echo "Version must match the semver pattern (e.g., 1.0.0, 2.3.4)" >&2 exit 1fi
if [[ "$(git symbolic-ref --short HEAD)" != "master" ]]; then echo "must be on master branch" >&2 exit 1fi
# Ensure there are no uncommitted or unpushed changesuncommited_changes=$(git diff --compact-summary)if [[ -n "$uncommited_changes" ]]; then echo -e "There are uncommited changes, exiting:\n${uncommited_changes}" >&2 exit 1figit pull git@github.com:nix-community/disko masterunpushed_commits=$(git log --format=oneline origin/master..master)if [[ "$unpushed_commits" != "" ]]; then echo -e "\nThere are unpushed changes, exiting:\n$unpushed_commits" >&2 exit 1fi
# Run all tests to ensure we don't release a broken version# Two workers are safe on systems with at least 16GB of RAMnix-fast-build --no-link -j 2 --eval-workers 2 --flake .#checks
# Update the version filecat > version.nix <<EOF{ version = "$version"; released = false;}EOF
# Commit and tag the releasegit commit -am "release: v$version"git tag -a "v$version" -m "release: v$version"git tag -d "latest"git tag -a "latest" -m "release: v$version"
# a revsion suffix when run from the tagged release commitecho "{ version = \"$version\"; released = false; }" > version.nixgit commit -am "release: reset released flag"
echo "Release was prepared successfully!"echo "To push the release, run the following command:"echoecho " git push origin master v$version && git push --force origin latest"echoecho "After that, create a release on GitHub:"echoecho " https://github.com/nix-community/disko/releases/new"