Skip to content

Commit ec3c237

Browse files
authored
chore: update release process to used trusted publishing (#9)
1 parent 464c110 commit ec3c237

File tree

10 files changed

+111
-58
lines changed

10 files changed

+111
-58
lines changed

.github/workflows/ci.yml

+57-36
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,30 @@ on:
66
- main
77
pull_request:
88

9+
concurrency:
10+
group: ${{ github.head_ref || github.run_id }}
11+
cancel-in-progress: true
12+
913
jobs:
1014
lint:
1115
runs-on: ubuntu-latest
1216
steps:
13-
- uses: actions/checkout@v2
14-
- uses: actions/setup-python@v2
17+
- uses: actions/checkout@v4
18+
- uses: actions/setup-python@v5
1519
with:
16-
python-version: "3.11"
17-
- uses: pre-commit/action@v2.0.3
20+
python-version: 3.x
21+
- uses: pre-commit/action@v3.0.0
22+
23+
# Make sure commit messages follow the conventional commits convention:
24+
# https://www.conventionalcommits.org
25+
commitlint:
26+
name: Lint Commit Messages
27+
runs-on: ubuntu-latest
28+
steps:
29+
- uses: actions/checkout@v4
30+
with:
31+
fetch-depth: 0
32+
- uses: wagoid/commitlint-github-action@v5.4.4
1833

1934
test:
2035
strategy:
@@ -28,57 +43,63 @@ jobs:
2843
- ubuntu-latest
2944
runs-on: ${{ matrix.os }}
3045
steps:
31-
- uses: actions/checkout@v2
46+
- uses: actions/checkout@v4
3247
- name: Set up Python
33-
uses: actions/setup-python@v2
48+
uses: actions/setup-python@v5
3449
with:
3550
python-version: ${{ matrix.python-version }}
36-
- uses: snok/install-poetry@v1
51+
- uses: snok/install-poetry@v1.3.4
3752
- name: Install Dependencies
3853
run: poetry install
54+
shell: bash
3955
- name: Test with Pytest
40-
run: poetry run pytest --cov=./aiosteamist --cov-report=xml --cov-report=term-missing tests/test_init.py
56+
run: poetry run pytest --cov-report=xml
57+
shell: bash
4158
- name: Upload coverage to Codecov
42-
uses: codecov/codecov-action@v2
59+
uses: codecov/codecov-action@v3
4360
with:
4461
token: ${{ secrets.CODECOV_TOKEN }}
4562

46-
docs:
47-
runs-on: ubuntu-latest
48-
steps:
49-
- uses: actions/checkout@v2
50-
- name: Set up Python
51-
uses: actions/setup-python@v2
52-
with:
53-
python-version: "3.9"
54-
- uses: snok/install-poetry@v1
55-
- name: Install Dependencies
56-
run: poetry install -E docs
57-
- name: Build docs
58-
working-directory: docs
59-
run: poetry run make html
60-
6163
release:
62-
runs-on: ubuntu-latest
63-
environment: release
64-
if: github.ref == 'refs/heads/main'
6564
needs:
6665
- test
6766
- lint
67+
- commitlint
68+
69+
runs-on: ubuntu-latest
70+
environment: release
71+
concurrency: release
72+
permissions:
73+
id-token: write
74+
contents: write
6875

6976
steps:
7077
- uses: actions/checkout@v4
7178
with:
7279
fetch-depth: 0
80+
ref: ${{ github.head_ref || github.ref_name }}
81+
82+
# Do a dry run of PSR
83+
- name: Test release
84+
uses: python-semantic-release/python-semantic-release@v8.7.2
85+
if: github.ref_name != 'main'
86+
with:
87+
root_options: --noop
88+
89+
# On main branch: actual PSR + upload to PyPI & GitHub
90+
- name: Release
91+
uses: python-semantic-release/python-semantic-release@v8.7.2
92+
id: release
93+
if: github.ref_name == 'main'
94+
with:
95+
github_token: ${{ secrets.GITHUB_TOKEN }}
96+
97+
- name: Publish package distributions to PyPI
98+
uses: pypa/gh-action-pypi-publish@release/v1
99+
if: steps.release.outputs.released == 'true'
73100

74-
# Run semantic release:
75-
# - Update CHANGELOG.md
76-
# - Update version in code
77-
# - Create git tag
78-
# - Create GitHub release
79-
# - Publish to PyPI
80-
- name: Python Semantic Release
81-
uses: relekang/python-semantic-release@v7.34.3
101+
- name: Publish package distributions to GitHub Releases
102+
uses: python-semantic-release/upload-to-gh-release@main
103+
if: steps.release.outputs.released == 'true'
82104
with:
83105
github_token: ${{ secrets.GITHUB_TOKEN }}
84-
pypi_token: ${{ secrets.PYPI_TOKEN }}

.pre-commit-config.yaml

+35-9
Original file line numberDiff line numberDiff line change
@@ -9,32 +9,58 @@ ci:
99

1010
repos:
1111
- repo: https://github.com/commitizen-tools/commitizen
12-
rev: v2.27.1
12+
rev: v2.37.0
1313
hooks:
1414
- id: commitizen
1515
stages: [commit-msg]
1616
- repo: https://github.com/pre-commit/pre-commit-hooks
17-
rev: v4.3.0
17+
rev: v4.4.0
1818
hooks:
19-
- id: trailing-whitespace
20-
- id: end-of-file-fixer
21-
- id: check-yaml
19+
- id: debug-statements
20+
- id: check-builtin-literals
21+
- id: check-case-conflict
22+
- id: check-docstring-first
2223
- id: check-json
24+
- id: check-toml
25+
- id: check-xml
26+
- id: check-yaml
27+
- id: detect-private-key
28+
- id: end-of-file-fixer
29+
- id: trailing-whitespace
2330
- id: debug-statements
31+
- repo: https://github.com/pre-commit/mirrors-prettier
32+
rev: v2.7.1
33+
hooks:
34+
- id: prettier
35+
args: ["--tab-width", "2"]
2436
- repo: https://github.com/asottile/pyupgrade
25-
rev: v2.34.0
37+
rev: v3.2.2
2638
hooks:
2739
- id: pyupgrade
2840
args: [--py37-plus]
2941
- repo: https://github.com/PyCQA/isort
30-
rev: 5.12.0
42+
rev: 5.13.0
3143
hooks:
3244
- id: isort
3345
- repo: https://github.com/psf/black
34-
rev: 22.3.0
46+
rev: 22.10.0
3547
hooks:
3648
- id: black
49+
- repo: https://github.com/codespell-project/codespell
50+
rev: v2.2.2
51+
hooks:
52+
- id: codespell
3753
- repo: https://github.com/PyCQA/flake8
38-
rev: 4.0.1
54+
rev: 6.0.0
3955
hooks:
4056
- id: flake8
57+
- repo: https://github.com/pre-commit/mirrors-mypy
58+
rev: v0.931
59+
hooks:
60+
- id: mypy
61+
additional_dependencies: []
62+
- repo: https://github.com/PyCQA/bandit
63+
rev: 1.7.4
64+
hooks:
65+
- id: bandit
66+
args: [-x, tests]

CONTRIBUTING.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ Report bugs at <https://github.com/bdraco/aiosteamist/issues>.
1212

1313
If you are reporting a bug, please include:
1414

15-
- Your operating system name and version.
16-
- Any details about your local setup that might be helpful in troubleshooting.
17-
- Detailed steps to reproduce the bug.
15+
- Your operating system name and version.
16+
- Any details about your local setup that might be helpful in troubleshooting.
17+
- Detailed steps to reproduce the bug.
1818

1919
### Fix Bugs
2020

@@ -34,9 +34,9 @@ The best way to send feedback is to file an issue at <https://github.com/bdraco/
3434

3535
If you are proposing a feature:
3636

37-
- Explain in detail how it would work.
38-
- Keep the scope as narrow as possible, to make it easier to implement.
39-
- Remember that this is a volunteer-driven project, and that contributions are welcome :)
37+
- Explain in detail how it would work.
38+
- Keep the scope as narrow as possible, to make it easier to implement.
39+
- Remember that this is a volunteer-driven project, and that contributions are welcome :)
4040

4141
## Get Started!
4242

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
<img src="https://img.shields.io/pypi/l/aiosteamist.svg?style=flat-square" alt="License">
3131
</p>
3232

33-
3433
Control Steamist steam systems
3534

3635
## Installation
@@ -48,6 +47,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
4847
<!-- markdownlint-disable -->
4948
<!-- markdownlint-enable -->
5049
<!-- prettier-ignore-end -->
50+
5151
<!-- ALL-CONTRIBUTORS-LIST:END -->
5252

5353
This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!

aiosteamist/__init__.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
STEAM_ON_LED = 6
2424
STEAM_OFF_LED = 7
2525

26-
NEVER_TIME = -1200
26+
NEVER_TIME = -1200.0
2727

2828

2929
@dataclass
@@ -50,7 +50,7 @@ def __init__(
5050
self._timeout = timeout
5151
self._host = host
5252
self._auth_invalid = 0
53-
self._url = URL(f"http://{self._host}")
53+
self._url = URL(f"http://{self._host}") # noqa
5454

5555
async def _get(self, endpoint: str, params=None) -> str:
5656
"""Make a get request."""

docs/source/changelog.md

+1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
```{include} ../../CHANGELOG.md
2+
23
```

docs/source/conf.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
# import os
1414
# import sys
1515
# sys.path.insert(0, os.path.abspath('.'))
16-
16+
from typing import Any, List
1717

1818
# -- Project information -----------------------------------------------------
1919

@@ -40,7 +40,7 @@
4040
# List of patterns, relative to source directory, that match files and
4141
# directories to ignore when looking for source files.
4242
# This pattern also affects html_static_path and html_extra_path.
43-
exclude_patterns = []
43+
exclude_patterns: List[Any] = []
4444

4545

4646
# -- Options for HTML output -------------------------------------------------

docs/source/contributing.md

+1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
```{include} ../../CONTRIBUTING.md
2+
23
```

docs/source/index.md

+1
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,5 @@ contributing
1717
```
1818

1919
```{include} ../../README.md
20+
2021
```

pyproject.toml

+5-2
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,13 @@ pytest-asyncio = ">=0.23.4"
5151

5252
[tool.semantic_release]
5353
branch = "main"
54-
version_toml = "pyproject.toml:tool.poetry.version"
55-
version_variable = "aiosteamist/__init__.py:__version__"
54+
version_toml = ["pyproject.toml:tool.poetry.version"]
55+
version_variables = [
56+
"src/aiosteamist/__init__.py:__version__",
57+
]
5658
build_command = "pip install poetry && poetry build"
5759

60+
5861
[tool.pytest.ini_options]
5962
addopts = "-v -Wdefault --cov=aiosteamist"
6063

0 commit comments

Comments
 (0)