@@ -24,27 +24,76 @@ jobs:
2424 - uses : actions/checkout@v4
2525
2626 - name : Allow workspace
27- run : git config --global --add safe.directory "$GITHUB_WORKSPACE"
27+ run : |
28+ git config --global --add safe.directory "$GITHUB_WORKSPACE"
2829
2930 - name : Build sdist
30- run : pipx run build --sdist
31+ run : |
32+ pipx run build --sdist
3133
3234 - name : Validate sdist
33- run : pipx run twine check dist/*.tar.gz
35+ run : |
36+ pipx run twine check dist/*.tar.gz
3437
3538 - uses : actions/upload-artifact@v4
3639 with :
3740 path : dist/*.tar.gz
3841 retention-days : 5
3942
43+ build_test_sdist :
44+ name : Build test source distribution
45+ runs-on : ubuntu-latest
46+ env :
47+ PYTHON_VERSION : " 3.10"
48+ container :
49+ image : ghcr.io/linux-nvme/debian.python:latest
50+ steps :
51+ - name : Check out repository (with tags)
52+ uses : actions/checkout@v4
53+ with :
54+ fetch-depth : 0 # Required for `git describe`
55+
56+ - name : Allow workspace
57+ run : |
58+ git config --global --add safe.directory "$GITHUB_WORKSPACE"
59+
60+ - name : Compute dev version from git
61+ id : version
62+ run : |
63+ TAG=$(git describe --tags --abbrev=0)
64+ REV=$(git rev-list "$TAG"..HEAD --count)
65+ BASE_VERSION="${TAG#v}"
66+ VERSION="${BASE_VERSION}.dev${REV}"
67+ echo "dev_version=$VERSION" >> $GITHUB_OUTPUT
68+ echo "Computed dev version: $VERSION"
69+
70+ - name : Patch version in pyproject.toml
71+ run : |
72+ sed -i "s/^version = .*/version = \"${{ steps.version.outputs.dev_version }}\"/" pyproject.toml
73+
74+ - name : Build sdist
75+ run : |
76+ pipx run build --sdist
77+
78+ - name : Validate sdist
79+ run : |
80+ pipx run twine check dist/*.tar.gz
81+
82+ - uses : actions/upload-artifact@v4
83+ with :
84+ name : test_pypi
85+ path : dist/*.tar.gz
86+ retention-days : 5
87+
4088 upload_test_pypi :
41- needs : [build_sdist ]
89+ needs : [build_test_sdist ]
4290 runs-on : ubuntu-latest
4391 env :
4492 PYTHON_VERSION : " 3.10"
4593 environment : pypi
4694 permissions :
4795 id-token : write
96+ if : github.repository == 'linux-nvme/libnvme'
4897 steps :
4998 - name : Check out repository (with tags)
5099 uses : actions/checkout@v4
56105
57106 - uses : actions/download-artifact@v4
58107 with :
59- name : artifact
108+ name : test_pypi
60109 path : dist
61110
62111 - name : Extract sdist for patching
0 commit comments