Skip to content
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
21 changes: 7 additions & 14 deletions .github/workflows/release-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,25 +49,18 @@ jobs:
uses: pdm-project/setup-pdm@v4
with:
python-version: "3.14"
cache: true

- name: Install dependencies
if: github.event_name == 'workflow_run'
run: pdm install

- name: Get version
id: version
run: |
if [ "${{ github.event_name }}" == "workflow_run" ]; then
# PDM SCM is the single source of truth for version numbers.
# It reads git tags and produces a PEP 440 version string.
pep440_version=$(pdm show --version)

# Convert PEP 440 → SemVer for Velopack (e.g. 0.1.0.dev47 → 0.1.0-dev.47)
installer_version=$(python3 -c "
from packaging.version import Version
v = Version('${pep440_version}')
base = f'{v.major}.{v.minor}.{v.micro}'
print(f'{base}-dev.{v.dev}' if v.dev is not None else base)
")

echo "version=${pep440_version}" >> $GITHUB_OUTPUT
echo "installer-version=${installer_version}" >> $GITHUB_OUTPUT
# pdm run version outputs version=<pep440> and installer-version=<semver>
pdm run version >> $GITHUB_OUTPUT
echo "channel=dev" >> $GITHUB_OUTPUT
echo "tag=dev" >> $GITHUB_OUTPUT
echo "is-dev=true" >> $GITHUB_OUTPUT
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ dev = { call = "tool.scripts.dev:main" }
format = "ruff format"
lint = { composite = ["analyze", "format", "type-check"] }
package = { call = "tool.scripts.package:main" }
version = { call = "tool.scripts.version:main" }
post_install = { call = "tool.scripts.setup_dev:main" }
test = "pytest --cov=synodic_client --verbose tests"
type-check = "pyrefly check"
Expand Down
23 changes: 23 additions & 0 deletions tool/scripts/version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
"""Print project version in PEP 440 and SemVer formats.

Outputs ``version=<pep440>`` and ``installer-version=<semver>`` lines,
one per line. In CI these can be appended directly to ``$GITHUB_OUTPUT``.

Usage examples:
pdm run version
pdm run python -m tool.scripts.version
"""

from synodic_client import __version__
from synodic_client.updater import pep440_to_semver


def main() -> None:
"""Entry point for the version script."""
semver = pep440_to_semver(__version__)
print(f'version={__version__}')
print(f'installer-version={semver}')


if __name__ == '__main__':
main()