Skip to content

Commit 72a8ed2

Browse files
FindHaofacebook-github-bot
authored andcommitted
Update nightly PyPI workflow to improve version computation (#99)
Summary: - Refactor version computation logic to ensure it fails gracefully if no tags are found, providing a clear error message. - Change the nightly version format to use the next patch version based on the latest tag, appending a timestamp for uniqueness. - Ensure build tools are installed before the build step. These changes fixes the bug that the nightly version is older than stable version, and enhance the reliability and clarity of the nightly build process. Pull Request resolved: #99 Reviewed By: sfzhu93 Differential Revision: D82224384 Pulled By: FindHao fbshipit-source-id: 6bfd2f447e3be585da9047e46ce1de01163cca48
1 parent ad917ac commit 72a8ed2

1 file changed

Lines changed: 18 additions & 9 deletions

File tree

.github/workflows/nightly-pypi.yml

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,23 +23,32 @@ jobs:
2323
- uses: actions/setup-python@v5
2424
with:
2525
python-version: "3.11"
26-
27-
- name: Install build tools
28-
run: |
29-
python -m pip install --upgrade pip
30-
pip install build setuptools-scm
31-
32-
- name: Compute nightly version from latest tag (per-second)
26+
- name: Compute nightly version from latest tag (next patch + timestamp)
3327
id: ver
3428
if: github.ref_type != 'tag'
3529
run: |
36-
TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo 0.1.0)
30+
# Get latest tag; allow 'v' prefix; fail if none
31+
if ! TAG=$(git describe --tags --abbrev=0 2>/dev/null); then
32+
echo "::error title=No git tag found::Repository has no tags. Add a semver tag like v0.1.0"
33+
exit 1
34+
fi
3735
BASE=${TAG#v}
36+
# Keep only X.Y.Z form (strip rc/a/b/post/dev suffixes)
37+
BASE=$(printf "%s\n" "$BASE" | sed -E 's/^([0-9]+)\.([0-9]+)\.([0-9]+).*/\1.\2.\3/')
38+
IFS='.' read -r MAJ MIN PAT <<EOF
39+
$BASE
40+
EOF
41+
# Use next patch version as the nightly base
42+
PAT=$((PAT + 1))
43+
NEXT="$MAJ.$MIN.$PAT"
3844
DATE=$(date -u +%Y%m%d%H%M%S)
39-
echo "NVER=${BASE}.dev${DATE}" >> $GITHUB_OUTPUT
45+
echo "NVER=${NEXT}.dev${DATE}" >> "$GITHUB_OUTPUT"
46+
echo "Computed nightly version: ${NEXT}.dev${DATE}"
4047
4148
- name: Build sdist/wheel
4249
run: |
50+
python -m pip install --upgrade pip
51+
pip install build setuptools-scm
4352
if [ "${{ github.ref_type }}" != "tag" ]; then
4453
export SETUPTOOLS_SCM_PRETEND_VERSION=${{ steps.ver.outputs.NVER }}
4554
fi

0 commit comments

Comments
 (0)