-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflake.nix
79 lines (69 loc) · 2.34 KB
/
flake.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
{
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
flake-parts.url = "github:hercules-ci/flake-parts";
systems.url = "github:nix-systems/default";
};
outputs =
inputs@{
flake-parts,
systems,
...
}:
flake-parts.lib.mkFlake { inherit inputs; } {
systems = import systems;
perSystem =
{
pkgs,
lib,
self',
...
}:
{
packages = {
bump = pkgs.writeShellApplication {
name = "bump-arg-services";
text = ''
if [ "$#" -ne 1 ]; then
echo "Usage: $0 VERSION" >&2
exit 1
fi
# remove v prefix
version="''${1#v}"
versionTag="v$version"
# split into array
IFS="." read -ra versionArray <<< "$version"
if [ "''${#versionArray[@]}" -ne 3 ]; then
echo "Version must be in format x.y.z" >&2
exit 1
fi
minorVersion="''${versionArray[1]}"
patchVersion="''${versionArray[2]}"
commitPrefix="fix"
if [ "$patchVersion" -eq 0 ]; then
commitPrefix="feat"
fi
if [ "$patchVersion" -eq 0 ] && [ "$minorVersion" -eq 0 ]; then
commitPrefix="feat!"
fi
# update deps in buf.yaml
${lib.getExe pkgs.sd} -- '(buf.build/recap/arg-services):v.*' "\$1:$versionTag" */buf.gen.yaml
commitMessage="''${commitPrefix}(deps): bump arg-services to $versionTag"
# https://stackoverflow.com/a/1885534
read -p "Commit changes with message '$commitMessage' (y/n)? " -r shouldCommit
if [ "$shouldCommit" = "y" ]; then
${lib.getExe pkgs.mu-repo} ac "$commitMessage"
read -p "Push commit (y/n)? " -r shouldPush
if [ "$shouldPush" = "y" ]; then
${lib.getExe pkgs.mu-repo} p
fi
fi
'';
};
};
devShells.default = pkgs.mkShell {
packages = with pkgs; [ mu-repo ] ++ lib.attrValues self'.packages;
};
};
};
}