From b7e92f2344dda18bade55bc12810eaf831b399b9 Mon Sep 17 00:00:00 2001 From: Patrick Dawkins Date: Tue, 17 Nov 2026 14:24:55 +0000 Subject: [PATCH 1/2] fix(installer): upgrade the CLI when its package is already installed Re-running the installer is the documented way to upgrade an install made with it, but on dnf and apk systems it left an installed package at its old version. - yum/dnf: expire the metadata cache, then run `yum install` and `yum upgrade` for the CLI package only. `dnf install` (Fedora) reports "already installed" instead of upgrading. - apk: add `--upgrade` to `apk add`, which otherwise keeps the installed version. - apt already upgrades with `apt-get update` and `apt-get install`. The installer tests (local script and workflow) gain an upgrade case per package manager: install the 5.16.0 release package, run the installer, and check that the version changed. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/test-installer.yml | 50 ++++++++++++++++++++++++++++ installer.sh | 5 +-- scripts/test/installer.sh | 21 +++++++++++- 3 files changed, 73 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test-installer.yml b/.github/workflows/test-installer.yml index 5466f655..5717f93f 100644 --- a/.github/workflows/test-installer.yml +++ b/.github/workflows/test-installer.yml @@ -59,6 +59,56 @@ jobs: - name: Verify installation run: upsun --version + # Upgrade flow: an older release's package is installed first, and the + # installer must upgrade it. + linux-upgrade: + runs-on: ubuntu-latest + container: ${{ matrix.image }} + defaults: + run: + shell: sh + env: + OLD_VERSION: 5.16.0 + strategy: + fail-fast: false + matrix: + include: + - image: debian:bookworm + prereqs: apt-get update && apt-get install -y curl ca-certificates + ext: deb + install: apt-get install -y + - image: fedora:41 + prereqs: yum install -y curl + ext: rpm + install: yum install -y + - image: alpine:3.21 + prereqs: apk add --no-cache curl ca-certificates + ext: apk + install: apk add --allow-untrusted + + steps: + - name: Install prerequisites + run: ${{ matrix.prereqs }} + + - name: Install an older release + run: | + curl -fsSL -o "/tmp/old.${{ matrix.ext }}" "https://github.com/upsun/cli/releases/download/v${OLD_VERSION}/upsun-cli_${OLD_VERSION}_linux_amd64.${{ matrix.ext }}" + ${{ matrix.install }} "/tmp/old.${{ matrix.ext }}" + upsun --version + + - name: Check out repository + uses: actions/checkout@v7 + + - name: Run installer + env: + CI: "" + run: sh installer.sh + + - name: Verify upgrade + run: | + upsun --version + test "$(upsun --version)" != "Upsun CLI ${OLD_VERSION}" + # Raw install on Linux: setting VERSION triggers the raw method. # Without a VERSION input the installer queries the GitHub API for the # latest release. diff --git a/installer.sh b/installer.sh index 7a5f89ef..22df6c53 100644 --- a/installer.sh +++ b/installer.sh @@ -701,7 +701,8 @@ gpgkey=https://repositories.upsun.com/gpg.key" output "\nInstalling the $vendor_name CLI" "heading" - if ! call_root "yum install -y $package"; then + # Refresh metadata, install, and upgrade an installed package (dnf's install may not). + if ! call_root "yum clean expire-cache" || ! call_root "yum install -y $package" || ! call_root "yum upgrade -y $package"; then output " could not install the CLI" "error" exit_with_error fi @@ -767,7 +768,7 @@ install_apk() { output "\nInstalling the $vendor_name CLI" "heading" - if ! call_root "apk add $package --update-cache"; then + if ! call_root "apk add --upgrade --update-cache $package"; then output " could not install the CLI" "error" exit_with_error fi diff --git a/scripts/test/installer.sh b/scripts/test/installer.sh index a76384ba..05c9a0b2 100755 --- a/scripts/test/installer.sh +++ b/scripts/test/installer.sh @@ -28,7 +28,7 @@ run_test() { -v "$(pwd)/installer.sh:/installer.sh:ro" \ "$@" \ "$image" \ - sh -c "${prereqs}sh /installer.sh && upsun --version"; then + sh -c "${prereqs}sh /installer.sh && ${check:-upsun --version}"; then echo "--- PASS: ${label} ---" pass=$((pass + 1)) else @@ -55,6 +55,25 @@ run_test "fedora:41 (default)" "fedora:41" \ run_test "alpine:3.21 (default)" "alpine:3.21" \ "apk add -q --no-cache curl ca-certificates && " +# Upgrade tests: install an older release's package first, then check that the installer upgrades it. +old_version="5.16.0" +old_url="https://github.com/upsun/cli/releases/download/v${old_version}/upsun-cli_${old_version}_linux_amd64" +check="upsun --version && test \"\$(upsun --version)\" != 'Upsun CLI ${old_version}'" + +run_test "debian:bookworm (upgrade)" "debian:bookworm" \ + "apt-get update -qq && apt-get install -y -qq curl ca-certificates && curl -fsSL -o /tmp/old.deb ${old_url}.deb && apt-get install -y -qq /tmp/old.deb && " \ + --platform linux/amd64 + +run_test "fedora:41 (upgrade)" "fedora:41" \ + "yum install -y -q curl && curl -fsSL -o /tmp/old.rpm ${old_url}.rpm && yum install -y -q /tmp/old.rpm && " \ + --platform linux/amd64 + +run_test "alpine:3.21 (upgrade)" "alpine:3.21" \ + "apk add -q --no-cache curl ca-certificates && curl -fsSL -o /tmp/old.apk ${old_url}.apk && apk add -q --allow-untrusted /tmp/old.apk && " \ + --platform linux/amd64 + +check="" + # Raw install test: setting VERSION triggers the raw method on Linux. if [ -n "$VERSION" ]; then run_test "debian:bookworm (raw, VERSION=$VERSION)" "debian:bookworm" \ From c1cf9d1c929a3cd7d24dbd27af4634e38b759069 Mon Sep 17 00:00:00 2001 From: Patrick Dawkins Date: Tue, 17 Nov 2026 14:31:54 +0000 Subject: [PATCH 2/2] fix(installer): refresh only the upsun repository's metadata `yum clean expire-cache` expired the metadata of every repository, so each re-run downloaded it all again. Pass `--setopt=upsun.metadata_expire=0` to the install and upgrade commands instead: yum 3, dnf4 and dnf5 then refresh only the upsun repository. (`clean` with `--disablerepo='*' --enablerepo=upsun` is scoped on yum 3, but not on dnf4 or dnf5.) The upgrade tests also check that the older release is installed before the installer runs, so they cannot pass without an upgrade. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/test-installer.yml | 1 + installer.sh | 5 +++-- scripts/test/installer.sh | 7 ++++--- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/.github/workflows/test-installer.yml b/.github/workflows/test-installer.yml index 5717f93f..164b8002 100644 --- a/.github/workflows/test-installer.yml +++ b/.github/workflows/test-installer.yml @@ -95,6 +95,7 @@ jobs: curl -fsSL -o "/tmp/old.${{ matrix.ext }}" "https://github.com/upsun/cli/releases/download/v${OLD_VERSION}/upsun-cli_${OLD_VERSION}_linux_amd64.${{ matrix.ext }}" ${{ matrix.install }} "/tmp/old.${{ matrix.ext }}" upsun --version + test "$(upsun --version)" = "Upsun CLI ${OLD_VERSION}" - name: Check out repository uses: actions/checkout@v7 diff --git a/installer.sh b/installer.sh index 22df6c53..cb555e07 100644 --- a/installer.sh +++ b/installer.sh @@ -701,8 +701,9 @@ gpgkey=https://repositories.upsun.com/gpg.key" output "\nInstalling the $vendor_name CLI" "heading" - # Refresh metadata, install, and upgrade an installed package (dnf's install may not). - if ! call_root "yum clean expire-cache" || ! call_root "yum install -y $package" || ! call_root "yum upgrade -y $package"; then + # Refresh this repository's metadata only, and upgrade an installed package (dnf's install may not). + opts="-y --setopt=upsun.metadata_expire=0" + if ! call_root "yum install $opts $package" || ! call_root "yum upgrade $opts $package"; then output " could not install the CLI" "error" exit_with_error fi diff --git a/scripts/test/installer.sh b/scripts/test/installer.sh index 05c9a0b2..31ccb082 100755 --- a/scripts/test/installer.sh +++ b/scripts/test/installer.sh @@ -58,18 +58,19 @@ run_test "alpine:3.21 (default)" "alpine:3.21" \ # Upgrade tests: install an older release's package first, then check that the installer upgrades it. old_version="5.16.0" old_url="https://github.com/upsun/cli/releases/download/v${old_version}/upsun-cli_${old_version}_linux_amd64" +old_check="test \"\$(upsun --version)\" = 'Upsun CLI ${old_version}'" check="upsun --version && test \"\$(upsun --version)\" != 'Upsun CLI ${old_version}'" run_test "debian:bookworm (upgrade)" "debian:bookworm" \ - "apt-get update -qq && apt-get install -y -qq curl ca-certificates && curl -fsSL -o /tmp/old.deb ${old_url}.deb && apt-get install -y -qq /tmp/old.deb && " \ + "apt-get update -qq && apt-get install -y -qq curl ca-certificates && curl -fsSL -o /tmp/old.deb ${old_url}.deb && apt-get install -y -qq /tmp/old.deb && ${old_check} && " \ --platform linux/amd64 run_test "fedora:41 (upgrade)" "fedora:41" \ - "yum install -y -q curl && curl -fsSL -o /tmp/old.rpm ${old_url}.rpm && yum install -y -q /tmp/old.rpm && " \ + "yum install -y -q curl && curl -fsSL -o /tmp/old.rpm ${old_url}.rpm && yum install -y -q /tmp/old.rpm && ${old_check} && " \ --platform linux/amd64 run_test "alpine:3.21 (upgrade)" "alpine:3.21" \ - "apk add -q --no-cache curl ca-certificates && curl -fsSL -o /tmp/old.apk ${old_url}.apk && apk add -q --allow-untrusted /tmp/old.apk && " \ + "apk add -q --no-cache curl ca-certificates && curl -fsSL -o /tmp/old.apk ${old_url}.apk && apk add -q --allow-untrusted /tmp/old.apk && ${old_check} && " \ --platform linux/amd64 check=""