Build NEURON Python wheels for nightly upload #469
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build NEURON Python wheels for nightly upload | |
| on: | |
| schedule: | |
| - cron: "0 0 * * *" | |
| workflow_dispatch: | |
| inputs: | |
| upload: | |
| description: "Upload wheels to PyPI" | |
| required: false | |
| default: "false" | |
| type: boolean | |
| os: | |
| description: "Comma-separated list of OSes" | |
| required: false | |
| default: "macos-14,ubuntu-24.04-arm" | |
| python_versions: | |
| description: "Comma-separated list of Python versions" | |
| required: false | |
| default: "3.10,3.11,3.12,3.13,3.14" | |
| commit: | |
| description: The commit of NEURON for which to build the wheel | |
| required: false | |
| default: "master" | |
| jobs: | |
| fetch-latest-commit: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| commit: ${{ steps.save-commit.outputs.commit }} | |
| steps: | |
| - name: Save commit ref | |
| id: save-commit | |
| run: | | |
| commit="${{ github.event.inputs.commit }}" | |
| if [[ -n "${commit}" ]]; then | |
| echo "commit=${commit}" >> "$GITHUB_OUTPUT" | |
| else | |
| git ls-remote origin refs/heads/master | cut -f1 | xargs -I{} echo "commit={}" >> "$GITHUB_OUTPUT" | |
| fi | |
| generate-matrix: | |
| name: Generate platform and Python matrix | |
| runs-on: ubuntu-latest | |
| outputs: | |
| matrix: ${{ steps.set-matrix.outputs.matrix }} | |
| steps: | |
| - id: set-matrix | |
| run: | | |
| OS_INPUT="${{ github.event.inputs.os || 'macos-14,ubuntu-24.04-arm' }}" | |
| PY_INPUT="${{ github.event.inputs.python_versions || '3.10,3.11,3.12,3.13,3.14' }}" | |
| OS_JSON=$(echo "$OS_INPUT" | jq -R 'split(",")') | |
| PY_JSON=$(echo "$PY_INPUT" | jq -R 'split(",")') | |
| echo "matrix=$(jq -c -n --argjson os "$OS_JSON" --argjson py "$PY_JSON" '{os: $os, python_version: $py}')" >> "$GITHUB_OUTPUT" | |
| build-test: | |
| name: Build and test for nightly | |
| needs: [fetch-latest-commit, generate-matrix] | |
| uses: ./.github/workflows/wheels-template.yml | |
| with: | |
| platform: ${{ matrix.os }} | |
| python_version: ${{ matrix.python_version }} | |
| optimize_rxd: true | |
| clone_depth: '0' | |
| commit: ${{ needs.fetch-latest-commit.outputs.commit }} | |
| strategy: | |
| matrix: ${{ fromJson(needs.generate-matrix.outputs.matrix) }} | |
| merge: | |
| name: Merge artifacts | |
| runs-on: ubuntu-latest | |
| needs: [build-test] | |
| steps: | |
| - name: Merge Artifacts | |
| id: merge-artifacts | |
| uses: actions/upload-artifact/merge@v4 | |
| with: | |
| delete-merged: true | |
| name: wheels | |
| pattern: wheels-* | |
| pypi-publish: | |
| name: Upload wheels to PyPI | |
| if: github.event_name == 'schedule' || (github.event_name == 'workflow_dispatch' && github.event.inputs.upload == 'true') | |
| needs: merge | |
| runs-on: ubuntu-latest | |
| environment: | |
| name: pypi | |
| url: https://pypi.org/p/neuron-nightly | |
| permissions: | |
| id-token: write # IMPORTANT: this permission is mandatory for trusted publishing | |
| steps: | |
| - name: Download wheels from artifact | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: wheels | |
| path: dist/ | |
| - name: Publish package distributions to PyPI | |
| uses: pypa/gh-action-pypi-publish@release/v1 | |
| with: | |
| skip-existing: true |