Generate changelog in workflow using git-chglog

This commit is contained in:
Adriano Caloiaroooo 2025-11-28 18:14:30 -08:00
parent 81da08cd30
commit 24e95d2cac
No known key found for this signature in database
2 changed files with 13 additions and 23 deletions

View file

@ -22,8 +22,20 @@ jobs:
- name: Generate changelog
id: changelog
run: |
changelog=$(nix develop --impure --command git-chglog --next-tag=$(svu next))
git config --global user.email "actions@github.com"
git config --global user.name "Github Actions"
OLD_TAG=$(nix develop --impure --command svu current --strip-prefix)
NEW_TAG=$(nix develop --impure --command svu next --strip-prefix)
[ "$OLD_TAG" == "$NEW_TAG" ] && echo "no version bump" && exit 0
sed -i "s/$OLD_TAG/$NEW_TAG/g" default.nix
sed -i "s/$OLD_TAG/$NEW_TAG/g" main.go
changelog=$(nix develop --impure --command git-chglog --next-tag=v$NEW_TAG)
echo "$changelog" > CHANGELOG.md
git add default.nix
git add main.go
git add CHANGELOG.md
git commit -m "bump di-tui version" --allow-empty
git tag v$NEW_TAG
echo "changelog<<EOF" >> $GITHUB_OUTPUT
echo "$changelog" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT

View file

@ -63,31 +63,9 @@
pass_filenames = false;
entry = "${gomod2nix.legacyPackages.${system}.gomod2nix}/bin/gomod2nix";
};
pre-commit.hooks.changelog = {
enable = true;
always_run = true;
name = "change";
description = "Generate a changelog";
pass_filenames = false;
entry = "nix .#changelog";
};
}
];
};
});
apps = forEachSystem (system: let
pkgs = nixpkgs.legacyPackages.${system};
changelog-script = pkgs.writeShellScriptBin "changelog" ''
set -euo pipefail
current_tag=$(${pkgs.svu}/bin/svu current)
${pkgs.git-chglog}/bin/git-chglog "$current_tag"
echo "Generated CHANGELOG.md from $current_tag"
'';
in {
changelog = {
type = "app";
program = "${changelog-script}/bin/changelog";
};
});
};
}