-
Notifications
You must be signed in to change notification settings - Fork 5
/
action.yml
105 lines (95 loc) · 3.28 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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
name: 'Build Python Source and Wheel Distributions'
description: 'Build source distribution for any Python package and wheels for Python packages without extensions.'
branding:
icon: package
color: blue
inputs:
test_extras:
description: Any extras_requires modifier that should be used to install the package for testing
required: false
default: ''
type: string
test_command:
description: The command to run to test the package (will be run in a temporary directory)
required: false
default: ''
type: string
pure_python_wheel:
description: Whether to build a pure Python wheel in addition to the source distribution
required: false
default: false
type: string
python-version:
description: The Python version to use for building and testing
required: false
default: '3.x'
type: string
runs:
using: "composite"
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-python@v5
with:
python-version: ${{ inputs.python-version }}
- name: Install python-build and twine
shell: bash
run: python -m pip install pip build twine --upgrade
- name: Build source distribution
shell: bash
run: python -m build --sdist .
- name: Test source distribution
shell: bash
run: |
python -m venv test-sdist
source test-sdist/bin/activate
which python
python -m pip install --force-reinstall `find dist -name "*.tar.gz"`[${{ inputs.test_extras }}]
cd ${{ runner.temp }}
${{ inputs.test_command }}
if: ${{ inputs.test_command != '' && inputs.test_extras != '' }}
- name: Test source distribution
shell: bash
run: |
python -m venv test-sdist
source test-sdist/bin/activate
which python
python -m pip install --force-reinstall `find dist -name "*.tar.gz"`
cd ${{ runner.temp }}
${{ inputs.test_command }}
if: ${{ inputs.test_command != '' && inputs.test_extras == '' }}
- name: Build pure Python wheel distribution
shell: bash
run: python -m build --wheel .
if: ${{ inputs.pure_python_wheel == 'true' }}
- name: Verify that one pure Python wheel was built
shell: bash
run: |
ls -1 dist/*
if [ $(ls -1 dist/*.whl 2>/dev/null | wc -l) != 1 ] ||
[ $(ls -1 dist/*none-any.whl 2>/dev/null | wc -l) != 1 ]; then
echo "::error ::Build failed because package is not pure Python."
exit 1
fi
if: ${{ inputs.pure_python_wheel == 'true' }}
- name: Test pure Python wheel distribution
shell: bash
run: |
python -m venv test-wheel
source test-wheel/bin/activate
which python
python -m pip install --force-reinstall `find dist -name "*.whl"`[${{ inputs.test_extras }}]
cd ${{ runner.temp }}
${{ inputs.test_command }}
if: ${{ inputs.pure_python_wheel == 'true' && inputs.test_command != '' && inputs.test_extras != '' }}
- name: Test pure Python wheel distribution
shell: bash
run: |
python -m venv test-wheel
source test-wheel/bin/activate
which python
python -m pip install --force-reinstall `find dist -name "*.whl"`
cd ${{ runner.temp }}
${{ inputs.test_command }}
if: ${{ inputs.pure_python_wheel == 'true' && inputs.test_command != '' && inputs.test_extras == '' }}