File tree Expand file tree Collapse file tree 1 file changed +21
-4
lines changed
pkgs/by-name/co/copywrite Expand file tree Collapse file tree 1 file changed +21
-4
lines changed Original file line number Diff line number Diff line change 55 fetchFromGitHub ,
66 installShellFiles ,
77 versionCheckHook ,
8+ writeScript ,
89} :
910
1011let
11- commitHash = "6ed520a710166c6094098b786c63f212604654a4 " ; # matches tag release
12+ commitHash = "9d021bf61a094a5eac6ae3084ceed2dda4700a73 " ; # matches tag release
1213 shortCommitHash = builtins . substring 0 7 commitHash ;
1314in
1415buildGoModule rec {
1516 pname = "copywrite" ;
16- version = "0.19 .0" ;
17+ version = "0.21 .0" ;
1718
1819 src = fetchFromGitHub {
1920 owner = "hashicorp" ;
2021 repo = "copywrite" ;
2122 tag = "v${ version } " ;
22- hash = "sha256-DmlPioaw/wMk8GoBYNG24P4J1C6h0bjVjjOuMYW6Tgo =" ;
23+ hash = "sha256-TGis7rreRen+vk3tUDehRkyas4xrBBxKlA70+VqoGWY =" ;
2324 } ;
2425
25- vendorHash = "sha256-ZIu0/fue3xi+YVE9GFsVjCNs8t3c3TWH8O0xUzJdim8 =" ;
26+ vendorHash = "sha256-Qxp6BwN/Y6Xb1BwFGT/T8WYsXGPgN27mzoTE0i6cS1Q =" ;
2627
2728 ldflags = [
2829 "-s"
@@ -44,6 +45,22 @@ buildGoModule rec {
4445 nativeInstallCheckInputs = [ versionCheckHook ] ;
4546 doInstallCheck = true ;
4647
48+ passthru . updateScript = writeScript "update-copywrite" ''
49+ #!/usr/bin/env nix-shell
50+ #!nix-shell -i bash -p curl jq nix-update
51+
52+ set -eu -o pipefail
53+
54+ gh_metadata="$(curl -sS https://api.github.com/repos/hashicorp/copywrite/tags)"
55+ version="$(echo "$gh_metadata" | jq -r '.[] | .name' | sort --version-sort | tail -1)"
56+ commit_hash="$(echo "$gh_metadata" | jq -r --arg ver "$version" '.[] | select(.name == $ver).commit.sha')"
57+
58+ filename="$(nix-instantiate --eval -E "with import ./. {}; (builtins.unsafeGetAttrPos \"version\" copywrite).file" | tr -d '"')"
59+ sed -i "s/commitHash = \"[^\"]*\"/commitHash = \"$commit_hash\"/" $filename
60+
61+ nix-update copywrite
62+ '' ;
63+
4764 meta = {
4865 description = "Automate copyright headers and license files at scale" ;
4966 mainProgram = "copywrite" ;
You can’t perform that action at this time.
0 commit comments