-
Notifications
You must be signed in to change notification settings - Fork 76
85 lines (70 loc) · 2.24 KB
/
Copy pathpython-publish.yml
File metadata and controls
85 lines (70 loc) · 2.24 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
# Publishes a new version to PyPI whenever a `v*` tag is pushed.
#
# To cut a release, just tag and push:
# git tag v2.9 && git push origin v2.9
#
# The tag is the only place a version is written. setuptools-scm derives the
# package version from it at build time, so there is nothing to keep in sync
# and no file to edit.
#
# Publishing uses PyPI Trusted Publishing (OIDC), so no API token is stored
# here. This requires a one-time setup on PyPI: on
# https://pypi.org/manage/project/pypdb/settings/publishing/ add a publisher
# with owner `williamgilpin`, repository `pypdb`, workflow
# `python-publish.yml`, and environment `pypi`.
name: Upload Python Package
on:
push:
tags:
- "v*"
# Allows publishing manually from the Actions tab if a tag push is missed
workflow_dispatch:
permissions:
contents: read
jobs:
release-build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
# setuptools-scm derives the version from the git tag, so it needs
# the full history rather than a shallow clone.
fetch-depth: 0
- uses: actions/setup-python@v5
with:
python-version: "3.x"
- name: Install dependencies
run: python -m pip install build pytest requests
- name: Run tests
run: pytest
- name: Build release distributions
run: python -m build
- name: Show the version that will be published
run: ls dist/
- name: Upload distributions
uses: actions/upload-artifact@v4
with:
name: release-dists
path: dist/
pypi-publish:
runs-on: ubuntu-latest
needs:
- release-build
permissions:
# IMPORTANT: this permission is mandatory for trusted publishing
id-token: write
# The environment name must match the one registered with the PyPI
# trusted publisher.
environment:
name: pypi
url: https://pypi.org/p/pypdb
steps:
- name: Retrieve release distributions
uses: actions/download-artifact@v4
with:
name: release-dists
path: dist/
- name: Publish release distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: dist/