Set output venv when activate-environment is used (#627)

Closes: #622
This commit is contained in:
Kevin Stillhammer
2025-10-11 15:17:25 +02:00
committed by GitHub
parent 1a91c3851d
commit bd1f875aba
4 changed files with 26 additions and 9 deletions

View File

@@ -334,6 +334,7 @@ jobs:
with:
persist-credentials: false
- name: Install latest version
id: setup-uv
uses: ./
with:
python-version: 3.13.1t
@@ -348,6 +349,19 @@ jobs:
exit 1
fi
shell: bash
- name: Verify output venv is set
run: |
if [ -z "$UV_VENV" ]; then
echo "output venv is not set"
exit 1
fi
if [ ! -d "$UV_VENV" ]; then
echo "output venv not point to a directory: $UV_VENV"
exit 1
fi
shell: bash
env:
UV_VENV: ${{ steps.setup-uv.outputs.venv }}
test-musl:
runs-on: ubuntu-latest

View File

@@ -86,6 +86,8 @@ outputs:
description: "The path to the installed uvx binary."
cache-hit:
description: "A boolean value to indicate a cache entry was found"
venv:
description: "Path to the activated venv if activate-environment is true"
runs:
using: "node24"
main: "dist/setup/index.js"

8
dist/setup/index.js generated vendored
View File

@@ -129661,12 +129661,14 @@ async function activateEnvironment() {
const execArgs = ["venv", ".venv", "--directory", inputs_1.workingDirectory];
core.info("Activating python venv...");
await exec.exec("uv", execArgs);
let venvBinPath = `${inputs_1.workingDirectory}${path.sep}.venv${path.sep}bin`;
const venvPath = path.resolve(`${inputs_1.workingDirectory}${path.sep}.venv`);
let venvBinPath = `${venvPath}${path.sep}bin`;
if (process.platform === "win32") {
venvBinPath = `${inputs_1.workingDirectory}${path.sep}.venv${path.sep}Scripts`;
venvBinPath = `${venvPath}${path.sep}Scripts`;
}
core.addPath(path.resolve(venvBinPath));
core.exportVariable("VIRTUAL_ENV", path.resolve(`${inputs_1.workingDirectory}${path.sep}.venv`));
core.exportVariable("VIRTUAL_ENV", venvPath);
core.setOutput("venv", venvPath);
}
}
function setCacheDir() {

View File

@@ -213,15 +213,14 @@ async function activateEnvironment(): Promise<void> {
core.info("Activating python venv...");
await exec.exec("uv", execArgs);
let venvBinPath = `${workingDirectory}${path.sep}.venv${path.sep}bin`;
const venvPath = path.resolve(`${workingDirectory}${path.sep}.venv`);
let venvBinPath = `${venvPath}${path.sep}bin`;
if (process.platform === "win32") {
venvBinPath = `${workingDirectory}${path.sep}.venv${path.sep}Scripts`;
venvBinPath = `${venvPath}${path.sep}Scripts`;
}
core.addPath(path.resolve(venvBinPath));
core.exportVariable(
"VIRTUAL_ENV",
path.resolve(`${workingDirectory}${path.sep}.venv`),
);
core.exportVariable("VIRTUAL_ENV", venvPath);
core.setOutput("venv", venvPath);
}
}