4

I have a Github Action that builds Windows wheels. At the end of the build it installs the wheels to make sure everything's OK, but right now the version is hard coded in the filename. I saw this question that deals with releases, but I'd like to run this on every push to master to check that things are OK.

Right now there's a line in my action looks like this:

pip install "fugashi-0.1.9rc1-cp${{ matrix.py-short }}-cp${{ matrix.py-short2 }}-win_amd64.whl"

I don't want to have to update the action every time the version changes, so I would like the line to look like this:

pip install "fugashi-$VERSION-cp${{ matrix.py-short }}-cp${{ matrix.py-short2 }}-win_amd64.whl"

But I do not know how to get the version into the environment of the github action.

Is there some way I can get the version number from setup.py in an environment variable for the job?

polm23
  • 14,456
  • 7
  • 35
  • 59
  • Why is it a problem that the version is defined in setup.py? Are you looking to change the version in `setup.py`? – smac89 Jan 07 '20 at 05:05
  • It's not a problem that the version number is in setup.py, the problem is the version number isn't in the environment. I edited the question to clarify what I want to change. – polm23 Jan 07 '20 at 05:36

1 Answers1

5

This ended up being much simpler than I thought. You can just get the version from setup.py itself and use that.

VERSION=$(python setup.py --version)
pip install "dist/fugashi-$VERSION-cp${{ matrix.py-short }}-cp${{ matrix.py-short2 }}-win_amd64.whl"

Trying to change the Github Action environment was a distraction.

polm23
  • 14,456
  • 7
  • 35
  • 59