|
1 | | -name: build flux-python |
| 1 | +name: flux-python |
2 | 2 |
|
3 | 3 | on: |
4 | 4 | pull_request: {} |
|
20 | 20 | default: "https://github.com/flux-framework/flux-core" |
21 | 21 |
|
22 | 22 | jobs: |
23 | | - build-manual: |
24 | | - runs-on: ubuntu-latest |
| 23 | + build: |
| 24 | + name: ${{ matrix.os }} Python ${{ matrix.python }} |
| 25 | + runs-on: ${{ matrix.os }} |
25 | 26 | strategy: |
26 | 27 | fail-fast: false |
27 | 28 | matrix: |
| 29 | + # The matrix now includes both os and python |
| 30 | + os: [ubuntu-latest, macos-latest] |
28 | 31 | python: ["3.8", "3.9", "3.10", "3.11"] |
29 | | - container: |
30 | | - image: fluxrm/testenv:jammy |
| 32 | + |
31 | 33 | steps: |
32 | 34 | - uses: actions/checkout@v4 |
33 | | - - name: Setup Python |
| 35 | + |
| 36 | + # Allow linux (gnu) style sed patterns for Mac. |
| 37 | + - name: Install GNU sed (macOS) |
| 38 | + if: runner.os == 'macOS' |
| 39 | + run: brew install gnu-sed |
| 40 | + |
| 41 | + # Only run original script on the Linux runner |
| 42 | + - name: Setup Python (Linux) |
| 43 | + if: runner.os == 'Linux' |
34 | 44 | env: |
35 | 45 | python_version: ${{ matrix.python }} |
36 | | - # Installs to /opt/conda/envs/build/bin/python3 |
37 | | - run: /bin/bash ./docker/install-mamba.sh ${python_version} |
| 46 | + run: /bin/bash ./docker/install-mamba.sh ${{ matrix.python }} |
| 47 | + |
| 48 | + # Use micromamba for MacOS and hope someone else figured this out :) |
| 49 | + - name: Setup Python (macOS) |
| 50 | + if: runner.os == 'macOS' |
| 51 | + uses: mamba-org/setup-micromamba@v1 |
| 52 | + with: |
| 53 | + environment-name: build-env |
| 54 | + create-args: python=${{ matrix.python }} |
38 | 55 |
|
| 56 | + # The login shell ensures the mamba env is active |
39 | 57 | - name: Build Flux Core Branch |
| 58 | + shell: bash -l {0} |
40 | 59 | env: |
41 | 60 | FLUX_RELEASE_VERSION: ${{ inputs.release_version }} |
42 | 61 | FLUX_VERSION: ${{ inputs.version }} |
43 | 62 | run: /bin/bash .github/scripts/setup.sh |
44 | 63 |
|
45 | 64 | - name: Build Python Bindings |
| 65 | + shell: bash -l {0} |
46 | 66 | env: |
47 | 67 | FLUX_BRANCH: ${{ inputs.branch }} |
48 | 68 | FLUX_REPO: ${{ inputs.repo }} |
49 | | - shell: bash |
50 | 69 | run: | |
51 | | - echo "Flux Repo: ${FLUX_REPO}" |
52 | | - echo "Flux Branch: ${FLUX_BRANCH}" |
53 | | - if [[ "${FLUX_REPO}" == "" ]]; then |
54 | | - FLUX_REPO="https://github.com/flux-framework/flux-core" |
55 | | - fi |
56 | | - if [[ "${FLUX_BRANCH}" == "" ]]; then |
57 | | - FLUX_BRANCH="master" |
| 70 | + echo "Flux Repo: ${{ inputs.repo }}" |
| 71 | + echo "Flux Branch: ${{ inputs.branch }}" |
| 72 | + |
| 73 | + # Use default values if inputs are empty |
| 74 | + FLUX_REPO_URL=${FLUX_REPO:-"https://github.com/flux-framework/flux-core"} |
| 75 | + FLUX_BRANCH_NAME=${FLUX_BRANCH:-"master"} |
| 76 | +
|
| 77 | + git clone -b ${FLUX_BRANCH_NAME} ${FLUX_REPO_URL} /tmp/flux-core |
| 78 | + mv /tmp/flux-core/src/bindings/python/flux ./flux |
| 79 | + python setup.py sdist |
| 80 | +
|
| 81 | + # I think ldconfig is Linux-specific |
| 82 | + if [[ "${{ runner.os }}" == "Linux" ]]; then |
| 83 | + sudo ldconfig |
58 | 84 | fi |
59 | | - git clone -b ${FLUX_BRANCH} ${FLUX_REPO} /tmp/flux-core |
60 | | - mv /tmp/flux-core/src/bindings/python/flux ./flux |
61 | | - /opt/conda/envs/build/bin/python3 setup.py sdist |
62 | | - sudo ldconfig |
63 | 85 |
|
64 | 86 | - name: Build Python Wheels |
| 87 | + shell: bash -l {0} |
65 | 88 | env: |
66 | 89 | build_number: ${{ inputs.rc }} |
67 | 90 | python_version: ${{ matrix.python }} |
68 | 91 | run: | |
69 | | - /bin/bash ./docker/build-wheels.sh ${build_number} ${python_version} |
| 92 | + /bin/bash ./docker/build-wheels.sh ${{ env.build_number }} ${{ env.python_version }} |
70 | 93 | ls ./dist |
71 | 94 |
|
72 | 95 | - name: Upload distributions |
73 | | - if: success() |
74 | 96 | uses: actions/upload-artifact@v4 |
75 | 97 | with: |
76 | | - name: ${{ matrix.python }} |
| 98 | + # The artifact name must be unique for each job in the matrix |
| 99 | + name: dist-${{ matrix.python }}-${{ matrix.os }} |
77 | 100 | path: ./dist |
78 | 101 |
|
79 | 102 | upload: |
80 | 103 | runs-on: ubuntu-latest |
81 | | - needs: [build-manual] |
| 104 | + # This job now needs the entire build matrix to complete successfully |
| 105 | + needs: [build] |
82 | 106 | steps: |
83 | 107 | - name: Download Artifacts |
84 | 108 | uses: actions/download-artifact@v4 |
85 | | - # If name unspecified, all artifacts download for run |
| 109 | + with: |
| 110 | + # Download all artifacts created by the build jobs |
| 111 | + path: artifacts |
86 | 112 |
|
87 | | - - name: Show Files |
| 113 | + - name: Show and Organize Files |
88 | 114 | run: | |
89 | | - ls */ |
90 | | - # We just need one of these |
91 | | - first_dir=$(ls . | head -n 1) |
| 115 | + ls -R artifacts |
92 | 116 | mkdir -p ./dist |
93 | | - mv */*.whl ./dist/ |
94 | | - cp ${first_dir}/*.tar.gz ./dist/ |
| 117 | + # This command finds all wheel and tar.gz files in all subdirectories |
| 118 | + # and moves them into a single ./dist directory for upload. |
| 119 | + find artifacts -type f \( -name "*.whl" -o -name "*.tar.gz" \) -exec mv {} ./dist/ \; |
95 | 120 | echo |
96 | 121 | echo "Files to distribute:" |
97 | 122 | ls ./dist |
98 | 123 |
|
99 | 124 | - name: Build and publish |
| 125 | + # Ensure this only runs on pushes to a main branch, not PRs |
100 | 126 | if: (github.event_name != 'pull_request') |
101 | 127 | env: |
102 | 128 | TWINE_USERNAME: ${{ secrets.PYPI_USER }} |
103 | 129 | TWINE_PASSWORD: ${{ secrets.PYPI_PASS }} |
104 | 130 | run: | |
105 | | - ls dist/ |
106 | | - python3 -m pip install setuptools wheel |
107 | | - python3 -m pip install twine==6.0.1 |
108 | | - python3 -m pip install --upgrade pkginfo |
109 | | - twine upload --skip-existing dist/flux_python* |
| 131 | + python3 -m pip install --upgrade twine |
| 132 | + twine upload --skip-existing dist/* |
0 commit comments