From bcc483974835eab150f76d2ba34d292569cecc19 Mon Sep 17 00:00:00 2001 From: Mike Landau Date: Wed, 5 Mar 2025 14:04:47 -0800 Subject: [PATCH 1/6] Allow url as devbox-version --- .github/workflows/test.yaml | 13 +++++++++++++ action.yml | 24 ++++++++++++++++++++++-- 2 files changed, 35 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 6e5259f..2891d09 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -94,3 +94,16 @@ jobs: sha256-checksum: '169836de22c41a1c68ac5a43e0514d4021137647c7c08ee8bd921faa430ee286' project-path: 'testdata' disable-nix-access-token: "${{ github.ref != 'refs/heads/main' }}" + + + test-action-with-url-version: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Install devbox + uses: ./ + with: + devbox-version: http://nightly-ubuntu.dev-jetify.com/ + refresh-cli: true + project-path: 'testdata' + disable-nix-access-token: "${{ github.ref != 'refs/heads/main' }}" diff --git a/action.yml b/action.yml index bc317e6..beeb854 100644 --- a/action.yml +++ b/action.yml @@ -15,7 +15,7 @@ inputs: description: 'Specify whether the CLI should be redownloaded' default: 'false' devbox-version: # version of the devbox cli - description: 'Specify devbox CLI version you want to pin to. Default to latest' + description: 'Specify devbox CLI version you want to pin to. Default to latest release. If version is URL, the URL will be downloaded and used as the devbox binary, assumed to be zipped.' default: '' sha256-checksum: # the expected SHA256 checksum of the devbox binary. description: 'Specify an explicit checksum for the devbox binary. For extra security on top of the existing checks in the devbox launch script' @@ -35,7 +35,27 @@ runs: DEVBOX_USE_VERSION: ${{ inputs.devbox-version }} run: | if [[ -n $DEVBOX_USE_VERSION ]]; then - echo "latest_version=$DEVBOX_USE_VERSION" >> $GITHUB_ENV + if [[ "$DEVBOX_USE_VERSION" =~ ^https?:// ]]; then + # If version is a URL, download and extract it + tmp_dir=$(mktemp -d) + tmp_zip="${tmp_dir}/devbox.zip" + echo "Downloading devbox from URL: $DEVBOX_USE_VERSION" + curl --fail --silent --location --output "${tmp_zip}" "${DEVBOX_USE_VERSION}" + unzip -q "${tmp_zip}" -d "${tmp_dir}" + # Find the devbox binary in the extracted files + DEVBOX_BINARY=$(find "${tmp_dir}" -type f -name "devbox") + if [[ ! -f "${DEVBOX_BINARY}" ]]; then + echo "ERROR: Could not find devbox binary in downloaded archive" + exit 1 + fi + mkdir -p ~/.local/bin + mv "${DEVBOX_BINARY}" ~/.local/bin/devbox + chmod +x ~/.local/bin/devbox + rm -rf "${tmp_dir}" + echo "latest_version=$DEVBOX_USE_VERSION" >> $GITHUB_ENV + else + echo "latest_version=$DEVBOX_USE_VERSION" >> $GITHUB_ENV + fi else tmp_file=$(mktemp) latest_url="https://releases.jetify.com/devbox/stable/version" From b4c8255b4c857fdf2fd085e767c89bf4d75c7822 Mon Sep 17 00:00:00 2001 From: Mike Landau Date: Wed, 5 Mar 2025 14:08:54 -0800 Subject: [PATCH 2/6] Add debug echos --- action.yml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/action.yml b/action.yml index beeb854..215ed80 100644 --- a/action.yml +++ b/action.yml @@ -38,19 +38,28 @@ runs: if [[ "$DEVBOX_USE_VERSION" =~ ^https?:// ]]; then # If version is a URL, download and extract it tmp_dir=$(mktemp -d) + echo "Created temp directory: ${tmp_dir}" tmp_zip="${tmp_dir}/devbox.zip" echo "Downloading devbox from URL: $DEVBOX_USE_VERSION" curl --fail --silent --location --output "${tmp_zip}" "${DEVBOX_USE_VERSION}" + echo "Download complete, zip file size: $(ls -lh ${tmp_zip} | awk '{print $5}')" + echo "Extracting zip file to ${tmp_dir}" unzip -q "${tmp_zip}" -d "${tmp_dir}" + echo "Extraction complete, contents of temp dir:" + ls -la "${tmp_dir}" # Find the devbox binary in the extracted files DEVBOX_BINARY=$(find "${tmp_dir}" -type f -name "devbox") + echo "Found devbox binary at: ${DEVBOX_BINARY}" if [[ ! -f "${DEVBOX_BINARY}" ]]; then echo "ERROR: Could not find devbox binary in downloaded archive" exit 1 fi mkdir -p ~/.local/bin + echo "Moving binary to ~/.local/bin/devbox" mv "${DEVBOX_BINARY}" ~/.local/bin/devbox chmod +x ~/.local/bin/devbox + echo "Binary permissions set, final location:" + ls -la ~/.local/bin/devbox rm -rf "${tmp_dir}" echo "latest_version=$DEVBOX_USE_VERSION" >> $GITHUB_ENV else From 30ab23e990c3d715ac5efefb0a13c880f1260300 Mon Sep 17 00:00:00 2001 From: Mike Landau Date: Wed, 5 Mar 2025 14:10:24 -0800 Subject: [PATCH 3/6] Remove silent --- action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yml b/action.yml index 215ed80..54b8579 100644 --- a/action.yml +++ b/action.yml @@ -41,7 +41,7 @@ runs: echo "Created temp directory: ${tmp_dir}" tmp_zip="${tmp_dir}/devbox.zip" echo "Downloading devbox from URL: $DEVBOX_USE_VERSION" - curl --fail --silent --location --output "${tmp_zip}" "${DEVBOX_USE_VERSION}" + curl --fail --location --output "${tmp_zip}" "${DEVBOX_USE_VERSION}" echo "Download complete, zip file size: $(ls -lh ${tmp_zip} | awk '{print $5}')" echo "Extracting zip file to ${tmp_dir}" unzip -q "${tmp_zip}" -d "${tmp_dir}" From 5b2304967deb0d634fae5ea772e02e12c842bbb8 Mon Sep 17 00:00:00 2001 From: Mike Landau Date: Wed, 5 Mar 2025 14:11:39 -0800 Subject: [PATCH 4/6] Use https --- .github/workflows/test.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 2891d09..faa076b 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -103,7 +103,7 @@ jobs: - name: Install devbox uses: ./ with: - devbox-version: http://nightly-ubuntu.dev-jetify.com/ + devbox-version: https://nightly-ubuntu.dev-jetify.com/ refresh-cli: true project-path: 'testdata' disable-nix-access-token: "${{ github.ref != 'refs/heads/main' }}" From a2efec53cb8820acc8a758b9e9706cc48c028456 Mon Sep 17 00:00:00 2001 From: Mike Landau Date: Wed, 5 Mar 2025 14:13:58 -0800 Subject: [PATCH 5/6] Echo curl --- action.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/action.yml b/action.yml index 54b8579..01d00c3 100644 --- a/action.yml +++ b/action.yml @@ -41,6 +41,7 @@ runs: echo "Created temp directory: ${tmp_dir}" tmp_zip="${tmp_dir}/devbox.zip" echo "Downloading devbox from URL: $DEVBOX_USE_VERSION" + echo curl --fail --location --output "${tmp_zip}" "${DEVBOX_USE_VERSION}" curl --fail --location --output "${tmp_zip}" "${DEVBOX_USE_VERSION}" echo "Download complete, zip file size: $(ls -lh ${tmp_zip} | awk '{print $5}')" echo "Extracting zip file to ${tmp_dir}" From 2436e5d0524e9ab4ee28239c108d759e2ec2f149 Mon Sep 17 00:00:00 2001 From: Mike Landau Date: Wed, 5 Mar 2025 14:30:44 -0800 Subject: [PATCH 6/6] Add github token --- action.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/action.yml b/action.yml index 01d00c3..1a6cfc5 100644 --- a/action.yml +++ b/action.yml @@ -41,8 +41,7 @@ runs: echo "Created temp directory: ${tmp_dir}" tmp_zip="${tmp_dir}/devbox.zip" echo "Downloading devbox from URL: $DEVBOX_USE_VERSION" - echo curl --fail --location --output "${tmp_zip}" "${DEVBOX_USE_VERSION}" - curl --fail --location --output "${tmp_zip}" "${DEVBOX_USE_VERSION}" + curl --fail --location --header "Authorization: Bearer ${{ github.token }}" --output "${tmp_zip}" "${DEVBOX_USE_VERSION}" echo "Download complete, zip file size: $(ls -lh ${tmp_zip} | awk '{print $5}')" echo "Extracting zip file to ${tmp_dir}" unzip -q "${tmp_zip}" -d "${tmp_dir}"