Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use release tag as project version when creating a release #326

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions .github/workflows/publish-to-pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,37 @@ name: Publish releases to PyPI

on:
release:
types: [published, prereleased]
types: [published]

jobs:
build-and-publish:
name: Builds and publishes releases to PyPI
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
- name: Get tag
id: vars
run: echo "tag=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT
- name: Set up Python 3.10
uses: actions/[email protected]
with:
python-version: "3.10"
- name: Install build
run: >-
pip install build
pip install build tomli tomli-w
- name: Set Python project version from tag
shell: python
run: |-
import tomli
import tomli_w

with open("pyproject.toml", "rb") as f:
pyproject = tomli.load(f)

pyproject["project"]["version"] = "${{ steps.vars.outputs.tag }}"

with open("pyproject.toml", "wb") as f:
tomli_w.dump(pyproject, f)
- name: Build
run: >-
python3 -m build
Expand Down
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ build-backend = "setuptools.build_meta"

[project]
name = "python-matter-server"
version = "3.5.1"
# The version is set by GH action on release
version = "0.0.0"
agners marked this conversation as resolved.
Show resolved Hide resolved
license = {text = "Apache-2.0"}
description = "Python Matter WebSocket Server"
readme = "README.md"
Expand Down