-
Notifications
You must be signed in to change notification settings - Fork 0
71 lines (58 loc) · 1.79 KB
/
Copy pathpublish.yml
File metadata and controls
71 lines (58 loc) · 1.79 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
name: Publish
on:
push:
tags:
- "v*"
release:
types: [published]
permissions:
contents: read
jobs:
publish:
name: Publish to PyPI
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/project/shors-algorithm-simulation/
permissions:
contents: read
id-token: write
steps:
- name: Check out repository
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
cache: pip
- name: Verify tag matches package version
run: |
python - <<'PY'
import os
import tomllib
tag = os.environ["GITHUB_REF_NAME"]
with open("pyproject.toml", "rb") as handle:
version = tomllib.load(handle)["project"]["version"]
expected_tags = {version, f"v{version}"}
if tag not in expected_tags:
raise SystemExit(
f"Tag {tag!r} does not match pyproject version {version!r}. "
f"Expected one of: {', '.join(sorted(expected_tags))}"
)
PY
- name: Install build tools
run: |
python -m pip install --upgrade pip
python -m pip install build twine
- name: Build distributions
run: python -m build
- name: Check distributions
run: python -m twine check dist/*
- name: Smoke-test wheel
run: |
python -m venv /tmp/shors-wheel
/tmp/shors-wheel/bin/python -m pip install --upgrade pip
/tmp/shors-wheel/bin/python -m pip install dist/*.whl
/tmp/shors-wheel/bin/shors-sim --N 15 --a 2 --json
- name: Publish distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1