Repository navigation
54 lines (44 loc) · 1.53 KB
/
Copy pathrelease.yml
File metadata and controls
54 lines (44 loc) · 1.53 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
name: Release
# Publishes to PyPI when a version tag is pushed (for example `v0.3.0`).
# Uses PyPI Trusted Publishing (OIDC), so no API token is stored in the repo.
# One-time setup: add a trusted publisher on https://pypi.org/manage/account/publishing/
# owner: Shellghostt, repository: WebVac, workflow: release.yml
# The tag must match `webvac.__version__` in `webvac/__init__.py`.
on:
push:
tags:
- "v*"
permissions:
contents: read
id-token: write
jobs:
publish:
name: Build and publish to PyPI
runs-on: ubuntu-latest
steps:
- name: Check out the repository
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Check tag matches package version
run: |
python - <<'PY'
import os
import pathlib
import re
source = pathlib.Path("webvac/__init__.py").read_text(encoding="utf-8")
version = re.search(r'__version__\s*=\s*"([^"]+)"', source).group(1)
tag = os.environ["GITHUB_REF_NAME"]
if tag != f"v{version}":
raise SystemExit(f"tag {tag!r} does not match package version v{version}")
print(f"Tag and package version agree: v{version}")
PY
- name: Build sdist and wheel
run: |
python -m pip install --upgrade build twine
python -m build
python -m twine check dist/*
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1