-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
action.yml
61 lines (51 loc) · 2.2 KB
/
action.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# This file is a part of the detect-pythons project.
# https://github.com/kurtmckee/detect-pythons
# Copyright 2023-2024 Kurt McKee <contactme@kurtmckee.org>
# SPDX-License-Identifier: MIT
author: "Kurt McKee"
name: "Detect installed Python interpreters"
description: |
Detect installed Python interpreters and output them as "python-identifiers".
This can be useful for cache busting of tox, virtual environments,
and other items that are sensitive to changes in Python implementations and versions.
Only Python interpreters named "python" in the $PATH will be found.
inputs:
identifiers-filename:
description: |
A filename to write the ``python-identifiers`` output to.
Suitable for use in with the ``hashFiles`` function.
To prevent any file from being written, use a blank string.
required: false
default: ".python-identifiers"
outputs:
python-identifiers:
description: |
A string of sorted Python identifiers.
In most cases the identifiers will be paths,
but for system Pythons, 'sysconfig.get_config_var("EXT_SUFFIX")' will be included.
The string will be separated by OS-specific PATH separators;
":" is used on Linux and macOS, and ";" is used on Windows.
value: "${{ steps.final-step.outputs.python-identifiers }}"
runs:
using: "composite"
steps:
- name: "Detect Pythons on Linux / macOS"
id: "linux"
if: "runner.os != 'Windows'"
shell: "bash"
run: 'bash ${GITHUB_ACTION_PATH}/src/detect_pythons/detector.sh > ${GITHUB_OUTPUT}'
- name: "Detect Pythons on Windows"
id: "windows"
if: "runner.os == 'Windows'"
shell: "pwsh"
run: '& $env:GITHUB_ACTION_PATH\src\detect_pythons\detector.ps1 > $env:GITHUB_OUTPUT'
- name: "Output"
id: "final-step"
shell: "bash"
run: |
COMBINED='${{ steps.linux.outputs.python-identifiers }}${{ steps.windows.outputs.python-identifiers }}'
echo "python-identifiers=${COMBINED}" > "$GITHUB_OUTPUT"
if [ ! -z '${{ inputs.identifiers-filename }}' ]; then
echo "Writing Python identifiers to '${{ inputs.identifiers-filename }}'"
echo "${COMBINED}" > '${{ inputs.identifiers-filename }}'
fi