-
-
Notifications
You must be signed in to change notification settings - Fork 1
98 lines (93 loc) · 3.19 KB
/
Copy pathpublish.yml
File metadata and controls
98 lines (93 loc) · 3.19 KB
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: PyPI release
# Builds the package on every PR/push to main to catch breakages early, but
# only publishes on a version tag push (e.g. 0.4.1). release.yml creates the
# GitHub Release from the same tag push, but GITHUB_TOKEN cannot trigger
# downstream workflows, so publish.yml listens directly for the tag push.
on:
workflow_dispatch:
pull_request:
branches: [main]
push:
branches: [main]
tags:
- "*.*.*"
release:
types: [published]
permissions: {}
jobs:
build:
name: Build source distribution
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
persist-credentials: false
- name: Install uv
uses: astral-sh/setup-uv@v8.2.0
- name: Build the sdist and the wheel
run: uv build
- name: Check the sdist installs and imports
run: |
uv venv venv-sdist
uv pip install --python venv-sdist/bin/python dist/tidydraws*.tar.gz
echo "Checking import and version number"
venv-sdist/bin/python -c "import tidydraws; print(tidydraws.__version__)"
- name: Check the bdist installs and imports
run: |
uv venv venv-bdist
uv pip install --python venv-bdist/bin/python dist/tidydraws*.whl
echo "Checking import and version number"
venv-bdist/bin/python -c "import tidydraws; print(tidydraws.__version__)"
- uses: actions/upload-artifact@v4
with:
name: artifact
path: dist/*
test-publish:
name: Upload to Test PyPI
permissions:
id-token: write
needs: [build]
runs-on: ubuntu-latest
if: >
(github.event_name == 'release' && github.event.action == 'published') ||
(github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')) ||
(github.event_name == 'workflow_dispatch' && startsWith(github.ref, 'refs/tags/'))
steps:
- uses: actions/download-artifact@v4
with:
name: artifact
path: dist
- uses: pypa/gh-action-pypi-publish@v1.14.0
with:
skip_existing: true
repository_url: https://test.pypi.org/legacy/
- name: Test pip install from test.pypi
run: |
sleep 5s
python -m venv venv-test-pypi
venv-test-pypi/bin/python -m pip install \
--index-url https://test.pypi.org/simple/ \
--extra-index-url https://pypi.org/simple \
tidydraws
echo "Checking import and version number"
venv-test-pypi/bin/python -c "import tidydraws; print(tidydraws.__version__)"
publish:
environment: release
permissions:
id-token: write
name: Upload release to PyPI
needs: [build, test-publish]
runs-on: ubuntu-latest
if: >
(github.event_name == 'release' && github.event.action == 'published') ||
(github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')) ||
(github.event_name == 'workflow_dispatch' && startsWith(github.ref, 'refs/tags/'))
steps:
- uses: actions/download-artifact@v4
with:
name: artifact
path: dist
- uses: pypa/gh-action-pypi-publish@v1.14.0