-
Notifications
You must be signed in to change notification settings - Fork 3
88 lines (76 loc) · 2.69 KB
/
python-package-create.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
name: Create Python Package
#######
# Creates a Python package via `tox -e package` and uploads it as an artifact named 'packages-<repo name>'.
#######
on:
workflow_call:
inputs:
python-version:
description: "Python version to use; defaults to latest Python release."
default: "3.X"
type: string
repository:
description: "GitHub repository to checkout; defaults to repo running this workflow."
default: ${{ github.repository }}
type: string
tox-source:
description: "The arguments for `pip install` to install tox; use ./path/to/package[dev] for the repo's pinned version."
default: ".[dev]"
type: string
build-subdirectory:
description: "The subdirectory to build as a wheel."
default: ""
type: string
distribution-path:
description: "Relative filepath to distribution(s); e.g. */dist/*"
default: "dist"
type: string
runner-os:
description: "Runner OS to use to run tox; defaults to ubuntu-latest"
default: "ubuntu-latest"
type: string
outputs:
artifact-name:
description: "Name of the uploaded artifact; use for artifact retrieval."
value: ${{ jobs.package.outputs.artifact-name }}
env:
FORCE_COLOR: "1"
jobs:
package:
name: Create Python Package
runs-on: ${{ inputs.runner-os }}
outputs:
artifact-name: packages-${{ steps.package.outputs.name }}
steps:
- name: Determine Package name
id: package
run: echo "name=$(basename '${{ inputs.repository }}')" >> ${GITHUB_OUTPUT}
- name: Checkout
uses: actions/checkout@v3.3.0
with:
repository: ${{ inputs.repository }}
fetch-depth: 0 # Fetch all refs so setuptools_scm can generate the correct version number
- name: Setup Python
uses: actions/setup-python@v4.6.0
with:
python-version: ${{ inputs.python-version }}
cache: "pip"
cache-dependency-path: |
**/setup.cfg
**/pyproject.toml
- name: Update pip
run: python -m pip install -U pip
- name: Install tox
run: python -m pip install ${{ inputs.tox-source }}
- name: Build wheels
if: inputs.build-subdirectory == ''
run: tox -e package
- name: Build wheels from subdirectory
if: inputs.build-subdirectory != ''
run: tox -e package -- ${{ inputs.build-subdirectory }}
- name: Upload Package
uses: actions/upload-artifact@v3.1.2
with:
name: packages-${{ steps.package.outputs.name }}
path: ${{ inputs.distribution-path }}
if-no-files-found: error