Skip to content

Commit b3db6ca

Browse files
committed
Test Git tag / package version coherence
Put this check as the last step of the `test` job and have it conditioned by the workflow being launched on a Git tag, in order to easily factor it out among the 3 potential target release "channels" (GitHub, Test PyPI, and PyPI).
1 parent fa9ca21 commit b3db6ca

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

.github/workflows/pip.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,9 @@ jobs:
9090
name: pip-package
9191
- name: Install package
9292
run: |
93+
# Allow Pip to write to its cache
94+
mkdir -p /github/home/.cache/pip
95+
chown -R $(whoami) /github/home/.cache/pip
9396
pip install --upgrade pip
9497
pip install $(ls khiops*.tar.gz)
9598
- name: Run tests
@@ -120,6 +123,21 @@ jobs:
120123
# The MPI command is not always named mpiexec, but can be orterun etc
121124
# (as given by khiops_env)
122125
kh-status | grep "MPI command" | grep -vwq "<empty>"
126+
- name: Test package / Git tag version coherence
127+
shell: bash
128+
if: github.ref_type == 'tag'
129+
run: |
130+
# Don't exit on first error: print relevant error message
131+
set +e
132+
PACKAGE_VERSION=$(pip show khiops | awk 'BEGIN {FS = ": "} $1 ~ /^Version$/ {print $2}')
133+
# Convert pre-release version specification to the Pip format
134+
echo ${{ github.ref_name }} | tr -d '-' | rev | sed 's/\.//' | rev | \
135+
grep -wq $PACKAGE_VERSION
136+
if [[ $? -ne 0 ]]
137+
then
138+
echo "::error::Python package version $PACKAGE_VERSION does not match Git tag ${{ github.ref_name }}"
139+
false
140+
fi
123141
# The implementation of a unique release job with multiple conditional steps
124142
# for each publishing mode is not chosen
125143
# because of the required job environment verified for Trusted Publishing

0 commit comments

Comments
 (0)