generated from uw-ssec/python-project-template
-
Notifications
You must be signed in to change notification settings - Fork 1
98 lines (84 loc) · 2.5 KB
/
cd.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
name: CD
on:
workflow_dispatch:
push:
branches:
- main
release:
types:
- published
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
FORCE_COLOR: 3
jobs:
dist:
name: Distribution build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Build sdist and wheel
run: pipx run build
- uses: actions/upload-artifact@v4
with:
path: dist
- name: Check products
run: pipx run twine check dist/*
test-built-dist:
needs: [dist]
name: Test built distribution
runs-on: ubuntu-latest
permissions:
id-token: write
steps:
- uses: actions/[email protected]
name: Install Python
with:
python-version: "3.10"
- uses: actions/download-artifact@v4
with:
name: artifact
path: dist
- name: List contents of built dist
run: |
ls -ltrh
ls -ltrh dist
- name: Publish to Test PyPI
uses: pypa/[email protected]
with:
repository-url: https://test.pypi.org/legacy/
verbose: true
skip-existing: true
- name: Check pypi packages
run: |
sleep 3
python -m pip install --upgrade pip
echo "=== Testing wheel file ==="
# Install wheel to get dependencies and check import
python -m pip install --extra-index-url https://test.pypi.org/simple --upgrade --pre prospecpy
python -c "import prospecpy; print(prospecpy.__version__)"
echo "=== Done testing wheel file ==="
echo "=== Testing source tar file ==="
# Install tar gz and check import
python -m pip uninstall --yes prospecpy
python -m pip install --extra-index-url https://test.pypi.org/simple --upgrade --pre --no-binary=prospecpy prospecpy
python -c "import prospecpy; print(prospecpy.__version__)"
echo "=== Done testing source tar file ==="
publish:
needs: [dist, test-built-dist]
name: Publish to PyPI
environment: pypi
permissions:
id-token: write
runs-on: ubuntu-latest
if: github.event_name == 'release' && github.event.action == 'published'
steps:
- uses: actions/download-artifact@v4
with:
name: artifact
path: dist
- uses: pypa/[email protected]
if: startsWith(github.ref, 'refs/tags')