diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 6e5259f..faa076b 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: https://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..1a6cfc5 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,36 @@ 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) + echo "Created temp directory: ${tmp_dir}" + tmp_zip="${tmp_dir}/devbox.zip" + echo "Downloading devbox from URL: $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}" + 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 + echo "latest_version=$DEVBOX_USE_VERSION" >> $GITHUB_ENV + fi else tmp_file=$(mktemp) latest_url="https://releases.jetify.com/devbox/stable/version"