From 213afb5cab8f58629144e3be3abe480902cbba00 Mon Sep 17 00:00:00 2001 From: Johanna Bahl Date: Tue, 29 Oct 2024 15:19:36 +0100 Subject: [PATCH] Use scriv for changelog management --- .pre-commit-config.yaml | 2 +- changelog.d/CHANGELOG.md | 0 changelog.d/new_fragment.md.j2 | 17 +++++++++++++++++ changelog.d/scriv.ini | 6 ++++++ changelog.sh | 2 +- flake.nix | 1 + release/fc-release.sh | 23 +++++++++++++++++++++++ 7 files changed, 49 insertions(+), 2 deletions(-) create mode 100644 changelog.d/CHANGELOG.md create mode 100644 changelog.d/new_fragment.md.j2 create mode 100644 changelog.d/scriv.ini mode change 100644 => 100755 changelog.sh diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 8872e411c..8b269ef3c 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,4 +1,4 @@ -exclude: ^secrets/|^appenv$|pkgs/fc/sensusyntax/fixtures/(syntaxerror|empty).json|(nixos/infrastructure/container.nix|tests/testlib.nix|nixos/roles/devhost/vm.nix) +exclude: ^secrets/|^appenv$|pkgs/fc/sensusyntax/fixtures/(syntaxerror|empty).json|(nixos/infrastructure/container.nix|tests/testlib.nix|nixos/roles/devhost/vm.nix)|^changelog.d/new_fragment.md.j2$ repos: - hooks: - exclude: "(?x)^(\n secrets/|environments/.*/secret.*|\n .*\\.patch\n)$\n" diff --git a/changelog.d/CHANGELOG.md b/changelog.d/CHANGELOG.md new file mode 100644 index 000000000..e69de29bb diff --git a/changelog.d/new_fragment.md.j2 b/changelog.d/new_fragment.md.j2 new file mode 100644 index 000000000..261aea564 --- /dev/null +++ b/changelog.d/new_fragment.md.j2 @@ -0,0 +1,17 @@ + + + + +### NixOS platform + +- A bullet item for the NixOS platform category. + diff --git a/changelog.d/scriv.ini b/changelog.d/scriv.ini new file mode 100644 index 000000000..dedf2e54f --- /dev/null +++ b/changelog.d/scriv.ini @@ -0,0 +1,6 @@ +[scriv] +format = md +entry_title_template = +categories = Impact, NixOS platform +output_file = changelog.d/CHANGELOG.md.tmp +skip_fragments = CHANGELOG.* diff --git a/changelog.sh b/changelog.sh old mode 100644 new mode 100755 index fc598241d..f1ad45ff5 --- a/changelog.sh +++ b/changelog.sh @@ -1,3 +1,3 @@ #!/usr/bin/env bash -nix develop --impure --command scriv create --edit +nix develop --impure --command scriv create --edit --add diff --git a/flake.nix b/flake.nix index cb5345154..f96f05c27 100644 --- a/flake.nix +++ b/flake.nix @@ -139,6 +139,7 @@ packages = with pkgs; [ jq + scriv ] ++ (with self'.packages; [ fcBranchDiffRelease fcGetCurrentChannelUrl diff --git a/release/fc-release.sh b/release/fc-release.sh index 1e2458689..11131a1cf 100755 --- a/release/fc-release.sh +++ b/release/fc-release.sh @@ -18,6 +18,15 @@ if ! git remote -v | grep -Eq "^origin\s.*github.com.flyingcircusio/fc-nixos"; t exit 64 fi +if [[ ! -d ../doc/changelog.d ]] || ! git -C ../doc remote -v | grep -Eq "^origin\s.*github.com.flyingcircusio/doc"; then + echo "$0: please ensure that you have a checkout of flyingcircusio/doc next to this repo" + exit 64 +fi +if [[ -e ../doc/changelog.d/"$nixos_version".md ]]; then + echo "$0: the changelog fragment '../doc/changelog.d/$nixos_version.md' already exists" + exit 64 +fi + git fetch origin --tags --prune git checkout "$dev" git merge --ff-only # expected to fail on unclean/unpushed workdirs @@ -25,8 +34,22 @@ git merge --ff-only # expected to fail on unclean/unpushed workdirs git checkout "$stag" git merge --ff-only +TEMP_CHANGELOG=changelog.d/CHANGELOG.md.tmp +CHANGELOG=changelog.d/CHANGELOG.md +truncate -s 0 $TEMP_CHANGELOG +scriv collect --add +sed -e "s/^## Impact/## Impact\n### $nixos_version/" \ + -e "s/^## NixOS platform/## NixOS $nixos_version platform/" $TEMP_CHANGELOG > ../doc/changelog.d/"$nixos_version".md +echo -e "\n" >> $TEMP_CHANGELOG +cat $CHANGELOG >> $TEMP_CHANGELOG +(echo "# Release $releaseid"; cat $TEMP_CHANGELOG) > $CHANGELOG +rm $TEMP_CHANGELOG +git add $TEMP_CHANGELOG $CHANGELOG +git commit -m "Collect changelog fragments" + git checkout "$prod" git merge --ff-only + msg="Merge branch '$stag' into $prod for release $releaseid" git merge -m "$msg" "$stag"