3030
3131v=$( cargo metadata --format-version=1 --no-deps | jq -r ' .packages[] | select(.name=="icp-cli-network-launcher") | .version' )
3232source=$( cargo metadata --format-version=1 --no-deps | jq -r ' .packages[] | select(.name=="icp-cli-network-launcher") | .dependencies[] | select(.name=="pocket-ic") | .source' )
33- if [[ " $v " = * " +" * ]]; then
33+ reg=' ([0-9.]+)(-((r[0-9]+$)|([0-9-]+(\.(r[0-9]+)))))?'
34+ if [[ " $v " =~ $reg ]]; then
35+ pkgver=${BASH_REMATCH[1]}
36+ icdate=${BASH_REMATCH[5]:- }
37+ patchrel=${BASH_REMATCH[4]:- ${BASH_REMATCH[7]:- } }
38+ else
39+ die " could not parse package version $v - should be 1.2.3[-r1] or 1.2.3-2026-01-29-16-08[.r1]"
40+ fi
41+ if [[ " $v " = * " -" * ]]; then
3442 [[ " $source " = " git+" * ]] || die " package.version is patch but pocket-ic dependency is not git"
35- revstr=${source# " git+https://github.com/dfinity/ic?" }
36- [[ " $revstr " =~ ' rev=' [0-9a-f]{40} ]] || die " use the full hash in the pocket-ic version"
37- sha=${revstr# " rev=" }
3843else
3944 [[ " $source " != " git+" * ]] || die " package.version is not patch but pocket-ic dependency is git"
4045fi
@@ -44,10 +49,11 @@ outdir="${1-"dist/${name}"}"
4449cargo build --release
4550mkdir -p " ${outdir} "
4651cp " target/release/icp-cli-network-launcher" " ${outdir} /"
47- if [[ -z " $sha " ]]; then
48- curl --proto ' =https' -sSfL --tlsv1.2 " https://github.com/dfinity/pocketic/releases/download/${v} /pocket-ic-${arch} -${os} .gz" -o " ${outdir} /pocket-ic.gz" ${GITHUB_TOKEN: + -H " Authorization: Bearer ${GITHUB_TOKEN} " }
52+ if [[ -z " $icdate " ]]; then
53+ icver=$( sed ' s/-/_/3' <<< " ${icdate}" )
54+ curl --proto ' =https' -sSfL --tlsv1.2 " https://github.com/dfinity/pocketic/releases/download/${pkgver} /pocket-ic-${arch} -${os} .gz" -o " ${outdir} /pocket-ic.gz" ${GITHUB_TOKEN: + -H " Authorization: Bearer ${GITHUB_TOKEN} " }
4955else
50- curl --proto ' =https' -sSfL --tlsv1.2 " https://download. dfinity.systems /ic/${sha} /binaries/ ${arch} -${os} /pocket-ic .gz" -o " ${outdir} /pocket-ic.gz"
56+ curl --proto ' =https' -sSfL --tlsv1.2 " https://github.com/ dfinity/ic/releases/download/release- ${icver} -base/pocket-ic- ${arch} -${os} .gz" -o " ${outdir} /pocket-ic.gz" ${GITHUB_TOKEN : + -H " Authorization: Bearer ${GITHUB_TOKEN} " }
5157fi
5258gunzip -f " ${outdir} /pocket-ic.gz"
5359chmod a+x " ${outdir} /pocket-ic"
0 commit comments