Skip to content

Commit e20eaab

Browse files
committed
add version tracking and release script
The derivation had no version, making it hard to tell which build a user is running when debugging issues like #135. Add version.txt as the single source of truth, referenced by default.nix via lib.fileContents. The release script is adopted from nixpkgs-review to automate bumping version.txt, tagging, and creating a GitHub draft release.
1 parent 32cc843 commit e20eaab

File tree

3 files changed

+44
-1
lines changed

3 files changed

+44
-1
lines changed

bin/create-release.sh

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#!/usr/bin/env bash
2+
3+
set -euo pipefail
4+
5+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null && pwd)"
6+
cd "$SCRIPT_DIR/.."
7+
8+
version="${1:-}"
9+
if [[ -z $version ]]; then
10+
echo "USAGE: $0 version" >&2
11+
exit 1
12+
fi
13+
14+
if [[ "$(git symbolic-ref --short HEAD)" != "main" ]]; then
15+
echo "must be on main branch" >&2
16+
exit 1
17+
fi
18+
19+
# ensure we are up-to-date
20+
uncommitted_changes=$(git diff --compact-summary)
21+
if [[ -n $uncommitted_changes ]]; then
22+
echo -e "There are uncommitted changes, exiting:\n${uncommitted_changes}" >&2
23+
exit 1
24+
fi
25+
git pull git@github.com:Mic92/nixos-shell main
26+
unpushed_commits=$(git log --format=oneline origin/main..main)
27+
if [[ $unpushed_commits != "" ]]; then
28+
echo -e "\nThere are unpushed changes, exiting:\n$unpushed_commits" >&2
29+
exit 1
30+
fi
31+
# make sure tag does not exist
32+
if git tag -l | grep -q "^${version}\$"; then
33+
echo "Tag ${version} already exists, exiting" >&2
34+
exit 1
35+
fi
36+
echo "$version" > version.txt
37+
git add version.txt
38+
git commit -m "bump version ${version}"
39+
git push origin main
40+
git tag "${version}"
41+
git push origin "${version}"
42+
gh release create "${version}" --draft --title "${version}" --generate-notes

default.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
with pkgs;
66
stdenv.mkDerivation {
7-
name = "nixos-shell";
7+
name = "nixos-shell-${lib.fileContents ./version.txt}";
88
src = builtins.filterSource
99
(path: type: baseNameOf path != "nixos.qcow2" &&
1010
baseNameOf path != ".git" &&

version.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
2.1.0

0 commit comments

Comments
 (0)