diff --git a/.github/workflows/test-install.yml b/.github/workflows/test-install.yml index 9750666..11d2a63 100644 --- a/.github/workflows/test-install.yml +++ b/.github/workflows/test-install.yml @@ -14,8 +14,6 @@ jobs: steps: - uses: actions/checkout@v6 - shell: bash - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | INSTALL_DIR="$HOME/.loops-test" sh install.sh latest "$INSTALL_DIR" @@ -34,8 +32,6 @@ jobs: steps: - uses: actions/checkout@v6 - shell: pwsh - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | $InstallDir = "$env:TEMP\loops-test" .\install.ps1 -InstallDir $InstallDir diff --git a/install.ps1 b/install.ps1 index 6da384a..25bea4c 100644 --- a/install.ps1 +++ b/install.ps1 @@ -18,11 +18,6 @@ $Arch = switch ($env:PROCESSOR_ARCHITECTURE) { default { throw "Unsupported architecture: $env:PROCESSOR_ARCHITECTURE" } } -$AuthHeader = @{} -if ($env:GITHUB_TOKEN) { - $AuthHeader["Authorization"] = "Bearer $env:GITHUB_TOKEN" -} - function Get-GithubRelease { param([string]$Repo, [string]$Version) $url = if ($Version -eq "latest") { @@ -30,7 +25,7 @@ function Get-GithubRelease { } else { "https://api.github.com/repos/$Repo/releases/tags/$Version" } - $response = Invoke-RestMethod -Uri $url -Headers $AuthHeader + $response = Invoke-RestMethod -Uri $url return $response.tag_name } @@ -61,8 +56,8 @@ $tmpDir = Join-Path $env:TEMP ([System.IO.Path]::GetRandomFileName()) New-Item -ItemType Directory -Path $tmpDir | Out-Null try { - Invoke-WebRequest -Uri $downloadUrl -OutFile "$tmpDir\$archiveName" -Headers $AuthHeader - Invoke-WebRequest -Uri $checksumsUrl -OutFile "$tmpDir\$checksumsName" -Headers $AuthHeader + Invoke-WebRequest -Uri $downloadUrl -OutFile "$tmpDir\$archiveName" + Invoke-WebRequest -Uri $checksumsUrl -OutFile "$tmpDir\$checksumsName" Confirm-Checksum -FilePath "$tmpDir\$archiveName" -ChecksumsPath "$tmpDir\$checksumsName" diff --git a/install.sh b/install.sh index 516552f..c75145d 100755 --- a/install.sh +++ b/install.sh @@ -14,14 +14,13 @@ echoerr() { github_release() { owner_repo=$1 version=$2 - header=$3 test -z "$version" && version="latest" if [ "$version" = "latest" ]; then giturl="https://api.github.com/repos/${owner_repo}/releases/latest" else giturl="https://api.github.com/repos/${owner_repo}/releases/tags/${version}" fi - json=$(http_copy "$giturl" "$header") + json=$(http_copy "$giturl") test -z "$json" && return 1 version=$(echo "$json" | tr -s '\n' ' ' | sed 's/.*"tag_name": *"//' | sed 's/".*//') test -z "$version" && return 1 @@ -31,12 +30,7 @@ github_release() { http_download_curl() { local_file=$1 source_url=$2 - header=$3 - if [ -z "$header" ]; then - code=$(curl -w '%{http_code}' -sL --proto '=https' --tlsv1.2 -o "$local_file" "$source_url") - else - code=$(curl -w '%{http_code}' -sL --proto '=https' --tlsv1.2 -H "$header" -o "$local_file" "$source_url") - fi + code=$(curl -w '%{http_code}' -sL --proto '=https' --tlsv1.2 -o "$local_file" "$source_url") if [ "$code" != "200" ]; then log_debug "http_download_curl received HTTP status $code" return 1 @@ -47,12 +41,7 @@ http_download_curl() { http_download_wget() { local_file=$1 source_url=$2 - header=$3 - if [ -z "$header" ]; then - wget -q -O "$local_file" "$source_url" - else - wget -q --header "$header" -O "$local_file" "$source_url" - fi + wget -q -O "$local_file" "$source_url" } http_download() { @@ -70,7 +59,7 @@ http_download() { http_copy() { tmp=$(mktemp) - http_download "${tmp}" "$1" "$2" || return 1 + http_download "${tmp}" "$1" || return 1 body=$(cat "$tmp") rm -f "${tmp}" echo "$body" @@ -222,11 +211,7 @@ TAG="${1-latest}" INSTALL_DIR="${2-$HOME/.local/bin}" PROJ_NAME="loops_cli" SHORT_BIN_NAME="loops" -AUTH_HEADER="" -if [ -n "$GITHUB_TOKEN" ]; then - AUTH_HEADER="Authorization: Bearer ${GITHUB_TOKEN}" -fi -GH_RELEASE=$(github_release "$GH_REPO" "$TAG" "$AUTH_HEADER") +GH_RELEASE=$(github_release "$GH_REPO" "$TAG") if [ "$OS" = "windows" ]; then GH_RELEASE_FILENAME="${PROJ_NAME}_${OS}_${ARCH}.zip" else @@ -239,11 +224,11 @@ CHECKSUMS_URL="${GH_ASSETS_URL}/${GH_RELEASE}/${CHECKSUMS_FILENAME}" execute() { TMPDIR=$(mktemp -d) - if ! http_download "${TMPDIR}/${GH_RELEASE_FILENAME}" "$DOWNLOAD_URL" "$AUTH_HEADER"; then + if ! http_download "${TMPDIR}/${GH_RELEASE_FILENAME}" "$DOWNLOAD_URL"; then log_err "Failed to download $DOWNLOAD_URL" return 1 fi - if ! http_download "${TMPDIR}/${CHECKSUMS_FILENAME}" "$CHECKSUMS_URL" "$AUTH_HEADER"; then + if ! http_download "${TMPDIR}/${CHECKSUMS_FILENAME}" "$CHECKSUMS_URL"; then log_err "Failed to download checksums from $CHECKSUMS_URL" return 1 fi