Skip to content

Commit f2f4cf5

Browse files
committed
feat(installer): [#73] Allow specifying version with DETERMINISTIC_ZIP_VERSION env var
1 parent 634e841 commit f2f4cf5

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ deterministic-zip
3434
bash <(curl -sS https://raw.githubusercontent.com/timo-reymann/deterministic-zip/main/installer)
3535
```
3636

37+
> Set the environment variable `DETERMINISTIC_ZIP_VERSION` to install a specific version
38+
3739
### Manual
3840

3941
#### Linux (64-bit)

installer

100644100755
Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ _ok() {
1515
SYS_ENV_PLATFORM=linux_arm
1616
else
1717
echo "This installer does not currently support your platform. If you believe it should, please consider opening an issue on the GitHub repository:"
18-
echo "https://github.com/timo-reymann/circleci-orb-deterministic-zip/issues/new"
18+
echo "https://github.com/timo-reymann/deterministic-zip/issues/new"
1919
exit 1
2020
fi
2121

@@ -28,9 +28,16 @@ _ok() {
2828
_ok
2929
fi
3030

31-
echo -n "Fetch the latest version from GitHub ... "
32-
# shellcheck disable=SC1083
33-
latest_version="$(curl -Lso /dev/null -w %{url_effective} https://github.com/timo-reymann/deterministic-zip/releases/latest | grep -o '[^/]*$')"
31+
if [ -n "$DETERMINISTIC_ZIP_VERSION" ];
32+
then
33+
echo -n "Using version from DETERMINISTIC_ZIP_VERSION ..."
34+
version="$DETERMINISTIC_ZIP_VERSION"
35+
else
36+
echo -n "Fetch the latest version from GitHub ... "
37+
# shellcheck disable=SC1083
38+
version="$(curl -Lso /dev/null -w %{url_effective} https://github.com/timo-reymann/deterministic-zip/releases/latest | grep -o '[^/]*$')"
39+
fi
40+
3441
_ok
3542

3643
echo -n "Determine artifact to download based on host OS ... "
@@ -48,8 +55,8 @@ _ok() {
4855
esac
4956
_ok
5057

51-
echo -n "Download binary for ${latest_version} ... "
52-
curl -LsS https://github.com/timo-reymann/deterministic-zip/releases/download/${latest_version}/${artifact} -o /tmp/deterministic-zip.${_pid}
58+
echo -n "Download binary for ${version} ... "
59+
curl --fail -LsS https://github.com/timo-reymann/deterministic-zip/releases/download/${version}/${artifact} -o /tmp/deterministic-zip.${_pid} || { echo -e "\n\033[0;31mERR: Failed to download from https://github.com/timo-reymann/deterministic-zip/releases/download/${version}/${artifact}\033[0m" && exit 2; }
5360
_ok
5461

5562
echo -n "Installing to /usr/local/bin ..."

0 commit comments

Comments
 (0)