Skip to content

Commit 6b3e36c

Browse files
committed
feat: support Windows runner by using platform-specific Python command and venv activate path
- Use variable (python on Windows, python3 on Linux/macOS) - Use for correct venv activation path (venv/Scripts/activate on Windows, venv/bin/activate on Linux/macOS) - Keep DEB_PYTHON_INSTALL_LAYOUT Linux-specific The action now works on all three GitHub-hosted runner OSes: ubuntu-latest, macos-latest, and windows-latest.
1 parent 60e903b commit 6b3e36c

1 file changed

Lines changed: 16 additions & 8 deletions

File tree

‎action.yml‎

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,17 +43,25 @@ runs:
4343
- name: Install dependencies and run commit-check
4444
shell: bash
4545
run: |
46-
if [[ "$RUNNER_OS" == "Linux" ]]; then
47-
# https://github.com/pypa/setuptools/issues/3269
48-
export DEB_PYTHON_INSTALL_LAYOUT=deb
46+
# Platform-specific settings
47+
if [[ "$RUNNER_OS" == "Windows" ]]; then
48+
PYTHON_CMD="python"
49+
VENV_ACTIVATE="venv/Scripts/activate"
50+
else
51+
if [[ "$RUNNER_OS" == "Linux" ]]; then
52+
# https://github.com/pypa/setuptools/issues/3269
53+
export DEB_PYTHON_INSTALL_LAYOUT=deb
54+
fi
55+
PYTHON_CMD="python3"
56+
VENV_ACTIVATE="venv/bin/activate"
4957
fi
5058
5159
# Set up virtual environment
52-
python3 -m venv venv
53-
source venv/bin/activate
60+
$PYTHON_CMD -m venv venv
61+
source "$VENV_ACTIVATE"
5462
5563
# Download artifact
56-
python3 -m pip download -r "$GITHUB_ACTION_PATH/requirements.txt"
64+
$PYTHON_CMD -m pip download -r "$GITHUB_ACTION_PATH/requirements.txt"
5765
5866
# Verify artifact attestations
5967
if ! gh attestation verify commit_check-*.whl -R commit-check/commit-check; then
@@ -62,9 +70,9 @@ runs:
6270
fi
6371
6472
# Install artifact
65-
python3 -m pip install commit_check-*.whl pygithub-*.whl
73+
$PYTHON_CMD -m pip install commit_check-*.whl pygithub-*.whl
6674
67-
python3 "$GITHUB_ACTION_PATH/main.py"
75+
$PYTHON_CMD "$GITHUB_ACTION_PATH/main.py"
6876
env:
6977
MESSAGE: ${{ inputs.message }}
7078
BRANCH: ${{ inputs.branch }}

0 commit comments

Comments
 (0)