]> Cypherpunks.ru repositories - prepro.git/blob - mk-mod
Initial commit
[prepro.git] / mk-mod
1 #!/usr/bin/env zsh
2
3 set -e
4
5 vcsurl=$1
6 vcspath=$2
7 modname=$3
8 version=$4
9
10 dst=$modname/@v
11 mkdir -p $dst
12 cd $dst
13 [[ -s $version.zip ]] && exit
14
15 prepro=$0:h:a/prepro
16 zmodload -F zsh/datetime b:strftime
17 git -C $vcspath cat-file -p $version | while read line ; do
18     [[ $line =~ ^object ]] && hsh=${${=line}[-1]}
19     [[ $line =~ ^tagger ]] && {
20         strftime -s sec -r "%s %z" "${${=line}[-2,-1]}"
21         break
22     }
23 done
24 [[ -n $hsh ]]
25 [[ -n $sec ]]
26 strftime -s when %Y-%m-%dT%H:%M:%SZ $sec
27
28 $prepro -vcs $vcspath -mod $modname -version $version > $version.zip
29 unzip -p $version.zip ${modname}@${version}/go.mod > $version.mod
30 printf '{"Version":"%s","Time":"%s","Origin":{"VCS":"git","URL":"%s","Ref":"refs/tags/%s","Hash":"%s"}}' \
31     $version $when $vcsurl $version $hsh > $version.info
32 touch -d $when $version.info $version.mod $version.zip