Skip to content

Commit

Permalink
Gzip binaries (#174)
Browse files Browse the repository at this point in the history
  • Loading branch information
mitsuhiko authored May 16, 2023
1 parent ffdd58d commit 51423d6
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 11 deletions.
11 changes: 7 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,11 @@ jobs:
create-release:
name: create-release
runs-on: ubuntu-22.04
env:
# Set to force version number, e.g., when no tag exists.
RYE_VERSION: 0.0.0

## Set to force version number, e.g., when no tag exists for testing
#env:
# RYE_VERSION: 0.0.0

outputs:
upload_url: ${{ steps.release.outputs.upload_url }}
rye_version: ${{ env.RYE_VERSION }}
Expand Down Expand Up @@ -153,7 +155,8 @@ jobs:
echo "ASSET=$bin.exe" >> $GITHUB_ENV
else
cp "target/${{ matrix.target }}/release/rye" "$bin"
echo "ASSET=$bin" >> $GITHUB_ENV
gzip "$bin"
echo "ASSET=$bin.gz" >> $GITHUB_ENV
fi
- name: Upload release archive
Expand Down
20 changes: 13 additions & 7 deletions scripts/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@ if [[ $PLATFORM == "Darwin" ]]; then
PLATFORM="macos"
elif [[ $PLATFORM == "Linux" ]]; then
PLATFORM="linux"
else
echo "error: Unsupported platform $PLATFORM";
exit 1
fi

if [[ $ARCH == armv8* ]] || [[ $ARCH == arm64* ]] || [[ $ARCH == aarch64* ]]; then
Expand All @@ -27,9 +24,9 @@ BINARY="rye-${ARCH}-${PLATFORM}"

# Oddly enough GitHub has different URLs for latest vs specific version
if [[ $VERSION == "latest" ]]; then
DOWNLOAD_URL=https://github.com/${REPO}/releases/latest/download/${BINARY}
DOWNLOAD_URL=https://github.com/${REPO}/releases/latest/download/${BINARY}.gz
else
DOWNLOAD_URL=https://github.com/${REPO}/releases/download/${VERSION}/${BINARY}
DOWNLOAD_URL=https://github.com/${REPO}/releases/download/${VERSION}/${BINARY}.gz
fi

echo "This script will automatically download and install rye (${VERSION}) for you."
Expand All @@ -42,18 +39,27 @@ if ! hash curl 2> /dev/null; then
exit 1
fi

if ! hash gunzip 2> /dev/null; then
echo "error: you do not have 'gunzip' installed which is required for this script."
exit 1
fi

TEMP_FILE=`mktemp "${TMPDIR:-/tmp}/.ryeinstall.XXXXXXXX"`
TEMP_FILE_GZ="${TEMP_FILE}.gz"

cleanup() {
rm -f "$TEMP_FILE"
rm -f "$TEMP_FILE_GZ"
}

trap cleanup EXIT
HTTP_CODE=$(curl -SL --progress-bar "$DOWNLOAD_URL" --output "$TEMP_FILE" --write-out "%{http_code}")
HTTP_CODE=$(curl -SL --progress-bar "$DOWNLOAD_URL" --output "$TEMP_FILE_GZ" --write-out "%{http_code}")
if [[ ${HTTP_CODE} -lt 200 || ${HTTP_CODE} -gt 299 ]]; then
echo "error: your platform and architecture (${PLATFORM}-${ARCH}) is unsupported."
echo "error: platform ${PLATFORM} (${ARCH}) is unsupported."
exit 1
fi

rm -f "$TEMP_FILE"
gunzip "$TEMP_FILE_GZ"
chmod +x "$TEMP_FILE"
"$TEMP_FILE" self install

0 comments on commit 51423d6

Please sign in to comment.