Skip to content

check-project-version does not reliably set expected-version #13

@bkeryan

Description

@bkeryan

Bug Report

check-project-version sets expected-version to ${{ github.ref_name }} by default, but this does not work reliably and is sometimes empty.

Repro or Code Sample

Publish a release of a Python package.

Expected Behavior

https://github.com/ni/nitypes-python/actions/runs/15688966947/job/44199278452

Run ni/python-actions/check-project-version@97860b52be87c788fb6df812bd8d1ca68c7aa885
  with:
    project-directory: /home/runner/work/nitypes-python/nitypes-python
    expected-version: 0.1.0-dev[2](https://github.com/ni/nitypes-python/actions/runs/15688966947/job/44199278452#step:5:2)
  env:
    dist-artifact-name: nitypes-distribution-packages
    environment: pypi
    environment-info: {
    "pypi": {
      "base-url": "https://pypi.org",
      "upload-url": "https://upload.pypi.org/legacy/"
    },
    "testpypi": {
      "base-url": "https://test.pypi.org",
      "upload-url": "https://test.pypi.org/legacy/"
    }
  }
  
    pythonLocation: /opt/hostedtoolcache/Python/[3](https://github.com/ni/nitypes-python/actions/runs/15688966947/job/44199278452#step:5:3).11.9/x64
    PKG_CONFIG_PATH: /opt/hostedtoolcache/Python/3.11.9/x6[4](https://github.com/ni/nitypes-python/actions/runs/15688966947/job/44199278452#step:5:4)/lib/pkgconfig
    Python_ROOT_DIR: /opt/hostedtoolcache/Python/3.11.9/x[6](https://github.com/ni/nitypes-python/actions/runs/15688966947/job/44199278452#step:5:6)4
    Python2_ROOT_DIR: /opt/hostedtoolcache/Python/3.11.9/x64
    Python3_ROOT_DIR: /opt/hostedtoolcache/Python/3.11.[9](https://github.com/ni/nitypes-python/actions/runs/15688966947/job/44199278452#step:5:9)/x64
    LD_LIBRARY_PATH: /opt/hostedtoolcache/Python/3.[11](https://github.com/ni/nitypes-python/actions/runs/15688966947/job/44199278452#step:5:11).9/x64/lib
    POETRY_BIN_DIR: /home/runner/.local/poetry/bin
    POETRY_HOME: /home/runner/.local/poetry/home
    POETRY_HOME_BIN: /home/runner/.local/poetry/home/bin
Run project_version="$(poetry version --short)"

Current Behavior

https://github.com/ni/hightime/actions/runs/15888571253/job/44806407584

Run ni/python-actions/check-project-version@49cd7a9a4098c459b90ba97e8e56bf5cd80997bb
  with:
    project-directory: /home/runner/work/hightime/hightime
  env:
    dist-artifact-name: hightime-distribution-packages
    environment: pypi
    environment-info: {
    "pypi": {
      "base-url": "https://pypi.org",
      "upload-url": "https://upload.pypi.org/legacy/"
    },
    "testpypi": {
      "base-url": "https://test.pypi.org",
      "upload-url": "https://test.pypi.org/legacy/"
    }
  }
  
    pythonLocation: /opt/hostedtoolcache/Python/3.11.9/x64
    PKG_CONFIG_PATH: /opt/hostedtoolcache/Python/3.11.9/x64/lib/pkgconfig
    Python_ROOT_DIR: /opt/hostedtoolcache/Python/3.11.9/x64
    Python[2](https://github.com/ni/hightime/actions/runs/15888571253/job/44806407584#step:5:2)_ROOT_DIR: /opt/hostedtoolcache/Python/[3](https://github.com/ni/hightime/actions/runs/15888571253/job/44806407584#step:5:3).11.9/x64
    Python3_ROOT_DIR: /opt/hostedtoolcache/Python/3.11.9/x6[4](https://github.com/ni/hightime/actions/runs/15888571253/job/44806407584#step:5:4)
    LD_LIBRARY_PATH: /opt/hostedtoolcache/Python/3.11.9/x[6](https://github.com/ni/hightime/actions/runs/15888571253/job/44806407584#step:5:6)4/lib
    pythonVersion: 3.11.9
    POETRY_BIN_DIR: /home/runner/.local/poetry/bin
    POETRY_HOME: /home/runner/.local/poetry/home
    POETRY_HOME_BIN: /home/runner/.local/poetry/home/bin
Run project_version="$(poetry version --short)"
Error: The project version in pyproject.toml does not match the expected version.

If this workflow was triggered by a GitHub release, verify that the
release was tagged with the correct version. If they don't match, you
should either update pyproject.toml or delete and re-create the release
with the correct tag.

Project version: 0.3.0-dev0
Expected version: 
Error: Process completed with exit code 1.

Possible Solution

https://github.com/orgs/community/discussions/64528 says to use github.event.release.tag_name.

actions/runner#2788 has more discussion of github.ref and related variables being unset for release events.

Context

Releasing a Python package.

Your Environment

  • ni/python-actions version: v0.4.0
  • Python version: 3.11.9

AB#3176680

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions