Skip to content

Commit

Permalink
build-wheel: use multiple versions of a pr in testpipy (#2709)
Browse files Browse the repository at this point in the history
  • Loading branch information
marcelotduarte authored Nov 30, 2024
1 parent 443ca14 commit d2c0829
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 10 deletions.
13 changes: 5 additions & 8 deletions .github/workflows/build-wheel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,17 +49,14 @@ jobs:
git config user.email marcelotduarte@users.noreply.github.com
SOURCE_DATE_EPOCH=$(git log -1 --pretty=%ct)
VERSION=$(bump-my-version show current_version 2>/dev/null)
if ! (echo $VERSION | grep -q "\-dev"); then
bump-my-version bump --no-tag patch 2>/dev/null
VERSION=$(bump-my-version show current_version 2>/dev/null)
fi
VERSION_BASE=$(python -c "print('$VERSION'.rsplit('-',1)[0])")
if [ "${{ github.event_name }}" == "pull_request" ]; then
BUILD_NUMBER=${{ github.event.number }}
OPTIONAL=".${{ github.event.number }}"
else
BUILD_NUMBER=$SOURCE_DATE_EPOCH
OPTIONAL=""
fi
NEWVERSION=$(python -c "print('$VERSION'.rsplit('.',1)[0])").$BUILD_NUMBER
bump-my-version bump --no-tag build --new-version=$NEWVERSION 2>/dev/null
VERSION_NEW=$VERSION_BASE$OPTIONAL-dev.$SOURCE_DATE_EPOCH
bump-my-version bump --no-tag build --new-version=$VERSION_NEW 2>/dev/null
git log -1
- name: Build sdist and wheels
Expand Down
6 changes: 5 additions & 1 deletion ci/build-wheel.sh
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,11 @@ fi
echo "::endgroup::"

if ! [ "$CI" == "true" ]; then
VERSION_OK=$($PYTHON -c "print(''.join('$VERSION'.replace('-','.').rsplit('.',1)), end='')")
if [[ $VERSION == *-* ]]; then
VERSION_OK=$($PYTHON -c "print(''.join('$VERSION'.replace('-','.').rsplit('.',1)), end='')")
else
VERSION_OK=$VERSION
fi
echo "::group::Install cx_Freeze $VERSION_OK"
UV_PYTHON=$UV_PYTHON UV_PRERELEASE=allow \
uv pip install "cx_Freeze==$VERSION_OK" --no-index --no-deps -f wheelhouse --reinstall
Expand Down
15 changes: 14 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,21 @@ target-version = ["py39"]
commit = true
current_version = "7.3.0-dev.1"
message = "Bump version: {current_version} → {new_version} [ci skip]"
parse = "(?P<major>\\d+)\\.(?P<minor>\\d+)\\.(?P<patch>\\d+)(\\-(?P<pre>[a-z]+)\\.(?P<build>\\d+))?"
parse = """(?x)
(?P<major>0|[1-9]\\d*)\\.
(?P<minor>0|[1-9]\\d*)\\.
(?P<patch>0|[1-9]\\d*)
(?:
\\.(?P<optional>0|[1-9]\\d*) # pull request number (optional)
)?
(?:
- # dash separator for pre-release section
(?P<pre>[a-zA-Z-]+)\\. # pre-release label
(?P<build>0|[1-9]\\d*) # pre-release version number
)? # pre-release section is optional
"""
serialize = [
"{major}.{minor}.{patch}.{optional}-{pre}.{build}",
"{major}.{minor}.{patch}-{pre}.{build}",
"{major}.{minor}.{patch}"
]
Expand Down

0 comments on commit d2c0829

Please sign in to comment.