Skip to content

Commit 2f20155

Browse files
authored
fix: update python-semantic-release to fix release process (#1426)
1 parent 1596145 commit 2f20155

2 files changed

Lines changed: 57 additions & 19 deletions

File tree

.github/workflows/ci.yml

Lines changed: 37 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -93,36 +93,54 @@ jobs:
9393
token: ${{ secrets.CODECOV_TOKEN }}
9494

9595
release:
96-
runs-on: ubuntu-latest
97-
environment: release
98-
if: github.ref == 'refs/heads/master'
9996
needs:
10097
- test
10198
- lint
10299
- commitlint
103100

101+
runs-on: ubuntu-latest
102+
environment: release
103+
concurrency: release
104+
permissions:
105+
id-token: write
106+
contents: write
107+
outputs:
108+
released: ${{ steps.release.outputs.released }}
109+
104110
steps:
105-
- uses: actions/checkout@v3
111+
- uses: actions/checkout@v4
106112
with:
107113
fetch-depth: 0
114+
ref: ${{ github.head_ref || github.ref_name }}
108115

109-
# Run semantic release:
110-
# - Update CHANGELOG.md
111-
# - Update version in code
112-
# - Create git tag
113-
# - Create GitHub release
114-
# - Publish to PyPI
115-
- name: Python Semantic Release
116-
uses: relekang/python-semantic-release@v7.34.6
117-
# env:
118-
# REPOSITORY_URL: https://test.pypi.org/legacy/
119-
# TWINE_REPOSITORY_URL: https://test.pypi.org/legacy/
116+
# Do a dry run of PSR
117+
- name: Test release
118+
uses: python-semantic-release/python-semantic-release@v9.12.0
119+
if: github.ref_name != 'master'
120+
with:
121+
root_options: --noop
122+
123+
# On main branch: actual PSR + upload to PyPI & GitHub
124+
- name: Release
125+
uses: python-semantic-release/python-semantic-release@v9.12.0
126+
id: release
127+
if: github.ref_name == 'master'
128+
with:
129+
github_token: ${{ secrets.GITHUB_TOKEN }}
130+
131+
- name: Publish package distributions to PyPI
132+
uses: pypa/gh-action-pypi-publish@release/v1
133+
if: steps.release.outputs.released == 'true'
134+
135+
- name: Publish package distributions to GitHub Releases
136+
uses: python-semantic-release/upload-to-gh-release@main
137+
if: steps.release.outputs.released == 'true'
120138
with:
121139
github_token: ${{ secrets.GITHUB_TOKEN }}
122-
pypi_token: ${{ secrets.PYPI_TOKEN }}
123140

124141
build_wheels:
125142
needs: [release]
143+
if: needs.release.outputs.released == 'true'
126144

127145
name: Build wheels on ${{ matrix.os }}
128146
runs-on: ${{ matrix.os }}
@@ -139,6 +157,8 @@ jobs:
139157
# Used to host cibuildwheel
140158
- name: Set up Python
141159
uses: actions/setup-python@v5
160+
with:
161+
python-version: "3.11"
142162

143163
- name: Install python-semantic-release
144164
run: pipx install python-semantic-release==7.34.6
@@ -161,7 +181,7 @@ jobs:
161181
platforms: arm64
162182

163183
- name: Build wheels
164-
uses: pypa/cibuildwheel@v2.20.0
184+
uses: pypa/cibuildwheel@v2.21.3
165185
# to supply options, put them in 'env', like:
166186
env:
167187
CIBW_SKIP: cp36-* cp37-* pp36-* pp37-* *p38-*_aarch64 cp38-*_arm64 *p39-*_aarch64 *p310-*_aarch64 pp*_aarch64 *musllinux*_aarch64

pyproject.toml

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,29 @@ script = "build_ext.py"
4646

4747
[tool.semantic_release]
4848
branch = "master"
49-
version_toml = "pyproject.toml:tool.poetry.version"
50-
version_variable = "src/zeroconf/__init__.py:__version__"
49+
version_toml = ["pyproject.toml:tool.poetry.version"]
50+
version_variables = [
51+
"src/zeroconf/__init__.py:__version__"
52+
]
5153
build_command = "pip install poetry && poetry build"
5254
tag_format = "{version}"
5355

56+
[tool.semantic_release.changelog]
57+
exclude_commit_patterns = [
58+
"chore*",
59+
"ci*",
60+
]
61+
62+
[tool.semantic_release.changelog.environment]
63+
keep_trailing_newline = true
64+
65+
[tool.semantic_release.branches.master]
66+
match = "master"
67+
68+
[tool.semantic_release.branches.noop]
69+
match = "(?!master$)"
70+
prerelease = true
71+
5472
[tool.poetry.dependencies]
5573
python = "^3.8"
5674
async-timeout = {version = ">=3.0.0", python = "<3.11"}

0 commit comments

Comments
 (0)