Skip to content

Commit a9af369

Browse files
authored
Merge pull request #88 from sphinx-contrib/trusted-publishing
Add a deploy.yml that supports trusted publishing.
2 parents 529a4eb + 8c4a652 commit a9af369

File tree

3 files changed

+86
-7
lines changed

3 files changed

+86
-7
lines changed

.github/workflows/deploy.yml

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
name: Deploy
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
release:
8+
types:
9+
- published
10+
workflow_dispatch:
11+
12+
permissions:
13+
contents: read
14+
15+
jobs:
16+
# Always build & lint package.
17+
build-package:
18+
name: Build & verify package
19+
runs-on: ubuntu-latest
20+
21+
steps:
22+
- uses: actions/checkout@v4
23+
with:
24+
fetch-depth: 0
25+
26+
- uses: hynek/build-and-inspect-python-package@v1
27+
28+
# Upload to Test PyPI on every commit on main.
29+
release-test-pypi:
30+
name: Publish in-dev package to test.pypi.org
31+
if: |
32+
github.repository_owner == 'sphinx-contrib'
33+
&& github.event_name == 'push'
34+
&& github.ref == 'refs/heads/main'
35+
runs-on: ubuntu-latest
36+
needs: build-package
37+
38+
permissions:
39+
id-token: write
40+
41+
steps:
42+
- name: Download packages built by build-and-inspect-python-package
43+
uses: actions/download-artifact@v3
44+
with:
45+
name: Packages
46+
path: dist
47+
48+
- name: Upload package to Test PyPI
49+
uses: pypa/gh-action-pypi-publish@release/v1
50+
with:
51+
repository-url: https://test.pypi.org/legacy/
52+
53+
# Upload to real PyPI on GitHub Releases.
54+
release-pypi:
55+
name: Publish released package to pypi.org
56+
if: |
57+
github.repository_owner == 'sphinx-contrib'
58+
&& github.event.action == 'published'
59+
runs-on: ubuntu-latest
60+
needs: build-package
61+
62+
permissions:
63+
id-token: write
64+
65+
steps:
66+
- name: Download packages built by build-and-inspect-python-package
67+
uses: actions/download-artifact@v3
68+
with:
69+
name: Packages
70+
path: dist
71+
72+
- name: Upload package to PyPI
73+
uses: pypa/gh-action-pypi-publish@release/v1

pyproject.toml

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
[build-system]
2-
requires = ["setuptools", "wheel"]
3-
build-backend = "setuptools.build_meta"
2+
build-backend = "hatchling.build"
3+
requires = [
4+
"hatch-vcs",
5+
"hatchling",
6+
]
47

58
[project]
69
name = "sphinx-lint"
@@ -33,10 +36,11 @@ repository = "https://github.com/sphinx-contrib/sphinx-lint"
3336
[project.scripts]
3437
sphinx-lint = "sphinxlint.__main__:main"
3538

36-
[tool.setuptools]
37-
packages = ["sphinxlint"]
38-
include-package-data = false
39-
dynamic.version.attr = "sphinxlint.__version__"
39+
[tool.hatch]
40+
version.source = "vcs"
41+
42+
[tool.hatch.version.raw-options]
43+
local_scheme = "no-local-version"
4044

4145
[tool.black]
4246

sphinxlint/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
"""Sphinx linter."""
22

3-
__version__ = "0.6.8"
3+
import importlib.metadata
44

55
from sphinxlint.sphinxlint import check_file, check_text
66

7+
__version__ = importlib.metadata.version("sphinx_lint")
8+
79
__all__ = ["check_text", "check_file"]

0 commit comments

Comments
 (0)