Skip to content

Commit 9aefa5b

Browse files
committed
CI: Add trusted publishing for PyPI and TestPyPI
1 parent 100da04 commit 9aefa5b

2 files changed

Lines changed: 57 additions & 102 deletions

File tree

.github/workflows/build_wheel.yml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,3 +89,59 @@ jobs:
8989
with state.State(quiet=False) as p_state:
9090
pass
9191
EOF
92+
93+
deploy-testpypi:
94+
name: Deploy to TestPyPI
95+
if: github.ref == 'refs/heads/develop'
96+
needs: ['build_wheels', 'install_wheels']
97+
environment: 'publish-testpypi'
98+
runs-on: ubuntu-latest
99+
permissions:
100+
id-token: write
101+
102+
steps:
103+
- uses: actions/download-artifact@v4
104+
with:
105+
name: cibw-wheels-ubuntu-latest
106+
path: dist
107+
108+
- uses: actions/download-artifact@v4
109+
with:
110+
name: cibw-wheels-macos-latest
111+
path: dist
112+
113+
- uses: actions/download-artifact@v4
114+
with:
115+
name: cibw-wheels-windows-latest
116+
path: dist
117+
118+
- name: Publish package distributions to PyPI
119+
uses: pypa/gh-action-pypi-publish@release/v1
120+
with:
121+
repository-url: https://test.pypi.org/legacy/
122+
123+
deploy-pypi:
124+
name: Deploy to PyPI
125+
if: github.ref == 'refs/heads/master'
126+
needs: ['build_wheels', 'install_wheels']
127+
environment: 'publish-pypi'
128+
runs-on: ubuntu-latest
129+
130+
steps:
131+
- uses: actions/download-artifact@v4
132+
with:
133+
name: cibw-wheels-ubuntu-latest
134+
path: dist
135+
136+
- uses: actions/download-artifact@v4
137+
with:
138+
name: cibw-wheels-macos-latest
139+
path: dist
140+
141+
- uses: actions/download-artifact@v4
142+
with:
143+
name: cibw-wheels-windows-latest
144+
path: dist
145+
146+
- name: Publish package distributions to PyPI
147+
uses: pypa/gh-action-pypi-publish@release/v1

.github/workflows/ci.yml

Lines changed: 1 addition & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -774,107 +774,6 @@ jobs:
774774
path: ui-cpp/ui-imgui/webapp/
775775
if-no-files-found: error
776776

777-
build-pypi:
778-
if: github.event_name != 'pull_request'
779-
needs:
780-
- lint
781-
- test-gcc
782-
- test-clang
783-
- test-nvcpp
784-
- test-msvc
785-
- test-debug
786-
- test-coverage
787-
runs-on: ${{ matrix.os }}
788-
strategy:
789-
fail-fast: false
790-
matrix:
791-
include:
792-
- platform: linux
793-
os: ubuntu-latest
794-
- platform: macos
795-
os: macos-latest
796-
- platform: windows
797-
os: windows-latest
798-
env:
799-
BUILD_TYPE: Release
800-
CMAKE_FLAGS: -DSPIRIT_UI_USE_IMGUI=OFF -DSPIRIT_UI_CXX_USE_QT=OFF
801-
SPIRIT_ADD_VERSION_SUFFIX: true
802-
803-
steps:
804-
- uses: actions/checkout@v4
805-
- uses: actions/setup-python@v5
806-
with:
807-
python-version: '3.x'
808-
809-
- name: ⚙ Configure environment
810-
shell: bash
811-
if: github.ref == 'refs/heads/master'
812-
run: echo "SPIRIT_ADD_VERSION_SUFFIX=false" >> $GITHUB_ENV
813-
814-
- name: 📁 Create build folder
815-
run: cmake -E make_directory ${{runner.workspace}}/build
816-
817-
- name: ⚙ Configure
818-
shell: bash
819-
working-directory: ${{runner.workspace}}/build
820-
run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE $CMAKE_FLAGS
821-
822-
- name: 🛠 Build
823-
shell: bash
824-
working-directory: ${{runner.workspace}}/build
825-
run: cmake --build . --config $BUILD_TYPE -j 2
826-
827-
- name: 📚 Install necessary packages
828-
run: |
829-
python -m pip install --upgrade pip
830-
python -m pip install numpy setuptools wheel twine
831-
832-
- name: 🛠 Build Python package
833-
shell: bash
834-
working-directory: ./core/python
835-
run: |
836-
echo "Python package build"
837-
echo "Add suffix to spirit version tag for python package $SPIRIT_ADD_VERSION_SUFFIX"
838-
python setup.py sdist bdist_wheel
839-
840-
- uses: actions/upload-artifact@v4
841-
with:
842-
name: dist-${{ matrix.platform }}
843-
path: ./core/python/dist
844-
if-no-files-found: error
845-
846-
deploy-pypi:
847-
if: github.event_name != 'pull_request'
848-
needs: ['build-pypi']
849-
environment: 'publish'
850-
runs-on: ubuntu-latest
851-
strategy:
852-
fail-fast: false
853-
matrix:
854-
os: [ubuntu-latest, macos-latest, windows-latest]
855-
856-
steps:
857-
- uses: actions/download-artifact@v4
858-
859-
- name: 📚 Install necessary packages
860-
run: |
861-
python -m pip install --upgrade pip
862-
python -m pip install twine
863-
864-
- name: 🚀 Deploy to TestPyPI
865-
env:
866-
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
867-
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
868-
if: github.ref != 'refs/heads/master'
869-
run: twine upload --skip-existing --repository testpypi dist/*
870-
871-
- name: 🚀 Deploy to PyPI
872-
env:
873-
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
874-
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
875-
if: github.ref == 'refs/heads/master'
876-
run: twine upload --skip-existing dist/*
877-
878777
deploy-package:
879778
if: github.event_name != 'pull_request'
880779
needs:
@@ -950,7 +849,7 @@ jobs:
950849

951850
draft-release:
952851
if: github.event_name == 'push' && startsWith( github.ref, 'refs/tags/' )
953-
needs: [deploy-pypi, deploy-package, build-webapp]
852+
needs: [deploy-package, build-webapp]
954853
runs-on: ubuntu-latest
955854
env:
956855
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)