Use Python-compatible versions

See https://packaging.python.org/en/latest/specifications/version-specifiers/#examples-of-compliant-version-schemes

Signed-off-by: Nic Cope <nicc@rk0n.org>
This commit is contained in:
Nic Cope 2024-01-03 18:29:58 -08:00
parent 29edf77d58
commit c1e5e20bef
3 changed files with 11 additions and 10 deletions

View File

@ -9,14 +9,14 @@ on:
workflow_dispatch: workflow_dispatch:
inputs: inputs:
version: version:
description: PyPI project version (e.g. 0.1.0 - no 'v') description: PyPI project version (e.g. v0.1.0)
required: false required: false
env: env:
# Common versions # Common versions
PYTHON_VERSION: '3.11.5' PYTHON_VERSION: '3.11.5'
# The PyPi project version to push. The default is 0.0.0-gitdate-gitsha. # The PyPi project version to push. The default is v0.0.0+gitdate-gitsha.
PYPI_VERSION: ${{ inputs.version }} PYPI_VERSION: ${{ inputs.version }}
jobs: jobs:
@ -70,12 +70,12 @@ jobs:
run: pipx install hatch==1.7.0 run: pipx install hatch==1.7.0
# If a version wasn't explicitly passed as a workflow_dispatch input we # If a version wasn't explicitly passed as a workflow_dispatch input we
# default to version v0.0.0-<git-commit-date>-<git-short-sha>, for example # default to version v0.0.0+<git-commit-date>-<git-short-sha>, for example
# v0.0.0-20231101115142-1091066df799. This is a simple implementation of # v0.0.0+20231101115142-1091066df799. This is a simple implementation of
# Go's pseudo-versions: https://go.dev/ref/mod#pseudo-versions. # Go's pseudo-versions: https://go.dev/ref/mod#pseudo-versions.
- name: Set Default PyPI Project Version - name: Set Default PyPI Project Version
if: env.PYPI_VERSION == '' if: env.PYPI_VERSION == ''
run: echo "PYPI_VERSION=0.0.0-$(date -d@$(git show -s --format=%ct) +%Y%m%d%H%M%S)-$(git rev-parse --short=12 HEAD)" >> $GITHUB_ENV run: echo "PYPI_VERSION=v0.0.0+$(date -d@$(git show -s --format=%ct) +%Y%m%d%H%M%S)-$(git rev-parse --short=12 HEAD)" >> $GITHUB_ENV
- name: Set PyPI Project Version - name: Set PyPI Project Version
run: hatch version ${{ env.PYPI_VERSION }} run: hatch version ${{ env.PYPI_VERSION }}

View File

@ -12,5 +12,7 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
"""The version of function-sdk-python."""
# This is set at build time, using "hatch version" # This is set at build time, using "hatch version"
__version__ = "0.0.0" __version__ = "0.0.0"

View File

@ -1,9 +1,9 @@
[build-system] [build-system]
requires = ["hatchling", "hatch-semver"] requires = ["hatchling"]
build-backend = "hatchling.build" build-backend = "hatchling.build"
[project] [project]
name = "function-sdk-python" name = "crossplane-function-sdk-python"
description = 'The Python SDK for Crossplane composition functions' description = 'The Python SDK for Crossplane composition functions'
readme = "README.md" readme = "README.md"
requires-python = ">=3.11" requires-python = ">=3.11"
@ -31,8 +31,7 @@ Source = "https://github.com/crossplane/function-sdk-python"
[tool.hatch.version] [tool.hatch.version]
path = "crossplane/function/__version__.py" path = "crossplane/function/__version__.py"
scheme = "semver" validate-bump = false # Allow going from 0.0.0.dev0+x to 0.0.0.dev0+y.
validate-bump = false # Allow going from 0.0.0-x to 0.0.0-y.
[tool.hatch.envs.default] [tool.hatch.envs.default]
type = "virtual" type = "virtual"