#!/usr/bin/env zsh
-set -e
+setopt ERR_EXIT
vcsurl=$1
vcspath=$2
modname=$3
version=$4
-signkey=$5
dst=$modname/@v
mkdir -p $dst
cd $dst
-[[ -s $version.zip ]] && exit
+[[ ! -s $version.zip ]] || exit 0
root=$0:h:a
zipcreate=$root/zip-create
ziphash=$root/zip-hash
zmodload -F zsh/datetime b:strftime
git -C $vcspath cat-file -p $version | while read line ; do
- [[ $line =~ ^object ]] && hsh=${${=line}[-1]}
- [[ $line =~ ^tagger ]] && {
+ [[ ! $line =~ ^object ]] || hsh=${${=line}[-1]}
+ [[ ! $line =~ ^tagger ]] || {
strftime -s sec -r "%s %z" "${${=line}[-2,-1]}"
break
}
unzip -p $version.zip ${modname}@${version}/go.mod > $version.mod
printf '{"Version":"%s","Time":"%s","Origin":{"VCS":"git","URL":"%s","Ref":"refs/tags/%s","Hash":"%s"}}' \
$version $when $vcsurl $version $hsh > $version.info
-totouch=($version.info $version.mod $version.zip $version.ziphash)
-[[ -z $signkey ]] || {
- ssh-keygen -Y sign -f $signkey -n file $version.ziphash
- totouch=($totouch $version.ziphash.sig)
-}
-touch -d $when $totouch
+touch -d $when $version.info $version.mod $version.zip $version.ziphash