2024-03-03 17:12:13 -05:00
|
|
|
{ pkgs, ... }:
|
|
|
|
|
|
|
|
{
|
|
|
|
# https://devenv.sh/basics/
|
2024-03-08 13:24:43 -05:00
|
|
|
env = {
|
|
|
|
PROJECT_NAME = "go-twitch";
|
2024-03-03 17:12:13 -05:00
|
|
|
|
2024-03-08 13:24:43 -05:00
|
|
|
MOCK_DATA_PATH = "~/.config/twitch-cli/eventCache.db";
|
|
|
|
MOCK_API_PORT = "3000";
|
|
|
|
|
|
|
|
CHANGELOG_FILE = "CHANGELOG.md";
|
|
|
|
};
|
2024-03-03 17:12:13 -05:00
|
|
|
|
|
|
|
# https://devenv.sh/packages/
|
|
|
|
packages = with pkgs; [
|
|
|
|
git
|
2024-03-08 01:28:33 -05:00
|
|
|
git-cliff
|
2024-03-03 17:12:13 -05:00
|
|
|
twitch-cli
|
|
|
|
];
|
|
|
|
|
|
|
|
# https://devenv.sh/scripts/
|
|
|
|
scripts = {
|
|
|
|
welcome-banner.exec = ''
|
|
|
|
echo "Welcome to the $PROJECT_NAME development environment."
|
|
|
|
echo "Golang version: $(go version | cut -d ' ' -f 3)"
|
|
|
|
'';
|
|
|
|
|
2024-03-08 13:24:43 -05:00
|
|
|
gen-changelog.exec = "git cliff -o $CHANGELOG_FILE";
|
|
|
|
release.exec = ''
|
2024-03-08 13:57:03 -05:00
|
|
|
set -euo pipefail
|
|
|
|
|
|
|
|
if [ -n "$(git status --porcelain)" ]; then
|
|
|
|
printf "Working directory is not clean. Please commit or stash your changes.\n"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2024-03-08 13:44:49 -05:00
|
|
|
version="$(git cliff --bumped-version)"
|
2024-03-08 14:00:01 -05:00
|
|
|
changelog=$(git cliff --unreleased --strip all | sed -e '/^#/d' -e '/^$/d')
|
2024-03-08 13:50:39 -05:00
|
|
|
git cliff --bump --unreleased --prepend $CHANGELOG_FILE
|
2024-03-08 13:24:43 -05:00
|
|
|
git add $CHANGELOG_FILE
|
2024-03-08 13:40:10 -05:00
|
|
|
git commit -m "chore(release): release $version"
|
2024-03-08 14:00:01 -05:00
|
|
|
git tag "$version" -m "Release $version" -m "$changelog"
|
2024-03-08 13:24:43 -05:00
|
|
|
git push --tags
|
|
|
|
'';
|
2024-03-08 01:28:33 -05:00
|
|
|
|
2024-03-03 17:12:13 -05:00
|
|
|
gen-mock-data.exec = "twitch-cli mock-api generate";
|
|
|
|
rm-mock-data.exec = "rm $MOCK_DATA_PATH";
|
|
|
|
start-mock-api.exec = "twitch-cli mock-api start -p $MOCK_API_PORT";
|
|
|
|
};
|
|
|
|
|
|
|
|
enterShell = "welcome-banner";
|
|
|
|
|
|
|
|
# https://devenv.sh/languages/
|
|
|
|
languages = {
|
|
|
|
nix.enable = true;
|
|
|
|
go.enable = true;
|
|
|
|
};
|
|
|
|
|
|
|
|
# https://devenv.sh/pre-commit-hooks/
|
|
|
|
# pre-commit.hooks.shellcheck.enable = true;
|
|
|
|
|
|
|
|
# https://devenv.sh/processes/
|
|
|
|
# processes.ping.exec = "ping example.com";
|
|
|
|
process.before = ''
|
|
|
|
if [ ! -f $MOCK_DATA_PATH ]; then
|
|
|
|
gen-mock-data
|
|
|
|
fi
|
|
|
|
'';
|
|
|
|
processes.mock-api.exec = "start-mock-api";
|
|
|
|
|
|
|
|
# See full reference at https://devenv.sh/reference/options/
|
|
|
|
}
|