Skip to content

Commit 142b9ce

Browse files
committed
pypi publish workflow (theochem#101)
* New try publish to pypi * Continue with new tests
1 parent c330e3a commit 142b9ce

File tree

1 file changed

+59
-21
lines changed

1 file changed

+59
-21
lines changed

.github/workflows/build_wheels.yml

Lines changed: 59 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -162,26 +162,64 @@ jobs:
162162
echo "Contents of wheelhouse:"
163163
ls -l wheelhouse/
164164
165-
- name: Upload to PyPI
166-
env:
167-
TWINE_USERNAME: "__token__"
168-
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
169-
run: |
170-
if [ "$(ls -A wheelhouse)" ]; then
171-
python -m pip install --upgrade twine
172-
python -m twine upload --repository-url https://upload.pypi.org/legacy/ wheelhouse/*
173-
else
174-
echo "No wheel files to upload"
175-
fi
165+
- uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
166+
with:
167+
path: ./wheelhouse/*.whl
168+
name: ${{ matrix.python[0] }}-${{ matrix.buildplat[1] }}
169+
${{ matrix.buildplat[2] }} ${{ matrix.buildplat[3] }}
170+
${{ matrix.buildplat[4] }}
171+
172+
publish-to-pypi:
173+
name: Publish Python distribution to PyPI
174+
# only publish to PyPI on tag pushes
175+
if: startsWith(github.ref, 'refs/tags/')
176+
needs:
177+
- build_wheels
178+
runs-on: ubuntu-latest
179+
environment:
180+
name: pypi-release
181+
url: https://pypi.org/project/${{ env.PYPI_NAME }}
182+
permissions:
183+
id-token: write
176184

177-
- name: Upload to TestPyPI
178-
env:
179-
TWINE_USERNAME: "__token__"
180-
TWINE_PASSWORD: ${{ secrets.TEST_PYPI_TOKEN }}
185+
steps:
186+
- name: Download all the dists
187+
uses: actions/download-artifact@v4
188+
with:
189+
path: dist/
190+
merge-multiple: true # Merge all artifacts into the dist/ directory
191+
192+
- name: Check dist contents
181193
run: |
182-
if [ "$(ls -A wheelhouse)" ]; then
183-
python -m pip install --upgrade twine
184-
python -m twine upload --repository-url https://test.pypi.org/legacy/ wheelhouse/*
185-
else
186-
echo "No wheel files to upload"
187-
fi
194+
echo "Contents of dist:"
195+
ls -l dist/
196+
197+
- name: Publish distribution to PyPI
198+
uses: pypa/gh-action-pypi-publish@release/v1
199+
with:
200+
attestations: false
201+
verbose: true
202+
203+
# - name: Upload to PyPI
204+
# env:
205+
# TWINE_USERNAME: "__token__"
206+
# TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
207+
# run: |
208+
# if [ "$(ls -A wheelhouse)" ]; then
209+
# python -m pip install --upgrade twine
210+
# python -m twine upload --repository-url https://upload.pypi.org/legacy/ wheelhouse/*
211+
# else
212+
# echo "No wheel files to upload"
213+
# fi
214+
215+
# - name: Upload to TestPyPI
216+
# env:
217+
# TWINE_USERNAME: "__token__"
218+
# TWINE_PASSWORD: ${{ secrets.TEST_PYPI_TOKEN }}
219+
# run: |
220+
# if [ "$(ls -A wheelhouse)" ]; then
221+
# python -m pip install --upgrade twine
222+
# python -m twine upload --repository-url https://test.pypi.org/legacy/ wheelhouse/*
223+
# else
224+
# echo "No wheel files to upload"
225+
# fi

0 commit comments

Comments
 (0)