-
Notifications
You must be signed in to change notification settings - Fork 0
/
action.yaml
88 lines (80 loc) · 2.76 KB
/
action.yaml
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
name: pypi-deployment
description: Package and deploy to PyPi or TestPyPi
inputs:
test_submission:
description: 'True if this should be sent to TestPypi instead of PyPi.'
default: false
required: true
wheels:
description: 'If Python wheels also be built alongside the source distribution.'
default: true
required: false
tests:
description: 'If there should be an attempt to pull down the newly uploaded package and run tests. Note: assumes testing via pytest --pyargs <package_name>.'
default: true
required: false
test_deps:
descriptions: 'Extra dependencies to install for testing the new package.'
default: 'pytest'
required: false
package_name:
description: 'Name of package on PyPi, only needed if testing package post-upload. Used for pip installing.'
default: 'MDAnalysis'
required: false
module_name:
description: 'Name of package directory, only needed if testing package post-upload. Used for pytest pyargs. If unset will use `package_name`.'
default: null
required: false
runs:
using: "composite"
steps:
- uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Current Python environment info
shell: bash
run: |
which python
python --version
- name: install_deps
shell: bash
run: |
python -m pip install pipx
- name: build
shell: bash
run: |
PIPX_OPTS="--sdist"
if [[ "${{ inputs.wheels }}" == "true" ]]; then
PIPX_OPTS="${PIPX_OPTS} --wheel"
fi
python -m pipx run build ${PIPX_OPTS}
- if: "${{ inputs.test_submission == 'true' }}"
id: pypi_upload
uses: pypa/gh-action-pypi-publish@v1.11.0
with:
repository-url: https://test.pypi.org/legacy/
skip-existing: true
- if: "${{ inputs.test_submission == 'false' }}"
id: testpypi_upload
uses: pypa/gh-action-pypi-publish@v1.11.0
with:
skip-existing: true
- name: run_pytest
if: "${{ inputs.tests == 'true' }}"
shell: bash
run: |
# sleep for 10 seconds to make sure things are refreshing upstream
sleep 10
# Assign the right URL if tests
if [[ "${{ inputs.test_submission }}" == "true" ]]; then
PIP_URLS="--index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple"
fi
# Install via pipx and run tests
python -m pip install ${PIP_URLS} ${{ inputs.package_name }}
python -m pip install ${{ inputs.test_deps }}
if [[ "${{ inputs.module_name }}" == "null" ]]; then
PACKAGEDIR="${{ inputs.package_name }}"
else
PACKAGEDIR="${{ inputs.module_name }}"
fi
python -m pytest --pyargs $PACKAGEDIR