88 lines (74 loc) · 2.4 KB
/
build-package.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: Build and publish package
on:
workflow_call: # Make workflow reusable
inputs:
enable_dev_dependencies:
required: false
type: string
secrets:
PYPI_USER:
required: true
PYPI_PASSWORD:
required: true
PYPI_HOST:
required: true
PYPI_PORT:
required: false
env:
PYPI_USER: ${{ secrets.PYPI_USER }}
PYPI_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
PYPI_HOST: ${{ secrets.PYPI_HOST }}
PYPI_PORT: ${{ secrets.PYPI_PORT }}
ENABLE_DEV_DEPENDENCIES: ${{ inputs.enable_dev_dependencies }}
permissions:
contents: read
jobs:
build_sdk:
runs-on: [self-hosted, sdk-runner]
steps:
- name: Checkout code with caching for Git LFS
uses: nschloe/action-cached-lfs-checkout@v1.2.0
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.9
- name: Install package with dev and notebook requirements
run: |
python -m pip install --upgrade pip
if [[ $ENABLE_DEV_DEPENDENCIES = 1 ]]; then
pip install ".[dev,notebooks]" --pre
else
pip install ".[dev,notebooks]"
fi
- name: Install build tools
run: pip install build twine
- name: Build package
run: python -m build
- name: Check package contents
run: twine check dist/*
- name: Upload wheel and source files as github artifact
# Publish the built wheel and source tarball to github
uses: actions/upload-artifact@v3
if: ${{ always() }}
with:
name: geti_sdk
path: dist
- name: Publish SDK package to pypi
run: |
if [[ $PYPI_HOST != "pypi.org" && $PYPI_HOST != "test.pypi.org" ]]; then
export no_proxy=$PYPI_HOST
export REPOSITORY_URL=http://$PYPI_HOST:$PYPI_PORT
twine upload --repository-url $REPOSITORY_URL dist/* -u $PYPI_USER -p $PYPI_PASSWORD
elif [[ $PYPI_HOST = "test.pypi.org" ]]; then
twine upload -r testpypi dist/* -u $PYPI_USER -p $PYPI_PASSWORD
else
twine upload dist/* -u $PYPI_USER -p $PYPI_PASSWORD
fi
- name: Clean up dist directory if it was created
if: ${{ always() }}
run: |
if OUTPUT=$(ls | grep -c dist)
then
echo "Cleaning up dist directory"
rm -r dist
fi