|
| 1 | +name: PyPI |
| 2 | + |
| 3 | +# Nightly builds on schedule; release builds triggered manually via workflow_dispatch |
| 4 | +on: |
| 5 | + schedule: |
| 6 | + - cron: '5 3 * * *' |
| 7 | + workflow_dispatch: |
| 8 | + inputs: |
| 9 | + acts_ref: |
| 10 | + description: 'Acts ref to build (e.g. v39.3.0) — leave empty to trigger a nightly build' |
| 11 | + required: false |
| 12 | + type: string |
| 13 | + |
| 14 | +env: |
| 15 | + CCACHE_DIR: ${{ github.workspace }}/ccache |
| 16 | + CCACHE_KEY_SUFFIX: r2 |
| 17 | + SETUP_CMD: "bash {package}/CI/dependencies/setup.sh -t v19.0.0 -d deps -e env.sh" |
| 18 | + |
| 19 | +permissions: {} |
| 20 | + |
| 21 | +jobs: |
| 22 | + # Prepare step: get unique time-stamp and checkout of the repo (otherwise main |
| 23 | + # could get updated during matrix jobs and code could differ between builds) |
| 24 | + prepare: |
| 25 | + runs-on: ubuntu-latest |
| 26 | + permissions: {} |
| 27 | + steps: |
| 28 | + - name: Set build version |
| 29 | + if: github.event_name != 'workflow_dispatch' || github.event.inputs.acts_ref == '' |
| 30 | + run: echo "dev$(date +%Y%m%d%H%M%S)" > build_version.txt |
| 31 | + |
| 32 | + - uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 |
| 33 | + if: github.event_name != 'workflow_dispatch' || github.event.inputs.acts_ref == '' |
| 34 | + with: |
| 35 | + name: build-version |
| 36 | + path: build_version.txt |
| 37 | + |
| 38 | + - uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5.0.1 |
| 39 | + with: |
| 40 | + ref: ${{ github.event.inputs.acts_ref || 'main' }} |
| 41 | + path: acts |
| 42 | + persist-credentials: false |
| 43 | + |
| 44 | + - name: Package source as tarball |
| 45 | + run: tar czf acts-source.tar.gz acts/ |
| 46 | + |
| 47 | + - uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 |
| 48 | + with: |
| 49 | + name: acts-source |
| 50 | + path: acts-source.tar.gz |
| 51 | + |
| 52 | + build_wheels: |
| 53 | + needs: prepare |
| 54 | + name: Build wheels on ${{ matrix.os }} |
| 55 | + runs-on: ${{ matrix.os }} |
| 56 | + permissions: {} |
| 57 | + strategy: |
| 58 | + max-parallel: 1 |
| 59 | + fail-fast: false |
| 60 | + matrix: |
| 61 | + os: |
| 62 | + - ubuntu-latest |
| 63 | + # - ubuntu-24.04-arm |
| 64 | + # - macos-15-intel |
| 65 | + - macos-latest |
| 66 | + |
| 67 | + steps: |
| 68 | + - name: Download source tarball |
| 69 | + uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0 |
| 70 | + with: |
| 71 | + name: acts-source |
| 72 | + |
| 73 | + - name: Extract source tarball |
| 74 | + run: tar xzf acts-source.tar.gz |
| 75 | + |
| 76 | + - name: Download build version |
| 77 | + if: github.event_name != 'workflow_dispatch' || github.event.inputs.acts_ref == '' |
| 78 | + uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0 |
| 79 | + with: |
| 80 | + name: build-version |
| 81 | + |
| 82 | + - name: print build version |
| 83 | + if: github.event_name != 'workflow_dispatch' || github.event.inputs.acts_ref == '' |
| 84 | + run: cat build_version.txt |
| 85 | + |
| 86 | + |
| 87 | + - name: Restore ccache |
| 88 | + id: ccache-restore |
| 89 | + uses: actions/cache/restore@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5 |
| 90 | + with: |
| 91 | + path: ${{ env.CCACHE_DIR }} |
| 92 | + key: ccache-${{ runner.os }}-${{ github.job }}-${{ env.CCACHE_KEY_SUFFIX }}-${{ github.sha }} |
| 93 | + restore-keys: | |
| 94 | + ccache-${{ runner.os }}-${{ github.job }}-${{ env.CCACHE_KEY_SUFFIX }}- |
| 95 | +
|
| 96 | + - name: Build wheels |
| 97 | + uses: pypa/cibuildwheel@298ed2fb2c105540f5ed055e8a6ad78d82dd3a7e # v3.3.1 |
| 98 | + with: |
| 99 | + package-dir: acts |
| 100 | + env: |
| 101 | + CIBW_MANYLINUX_X86_64_IMAGE: manylinux_2_34 # based on almalinux9 |
| 102 | + CIBW_BUILD: "cp311-* cp310-* cp312-* cp313-* cp314-*" |
| 103 | + CIBW_SKIP: "*-musllinux* *-manylinux_i686" |
| 104 | + CIBW_BEFORE_ALL_LINUX: dnf install -y bc ccache && ${{ env.SETUP_CMD }} |
| 105 | + CIBW_BEFORE_ALL_MACOS: brew install ninja ccache && ${{ env.SETUP_CMD }} |
| 106 | + CIBW_ENVIRONMENT: GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }} |
| 107 | + CIBW_ENVIRONMENT_PASS: CI |
| 108 | + CIBW_BEFORE_BUILD: ccache -z |
| 109 | + CIBW_ENVIRONMENT_LINUX: CMAKE_PREFIX_PATH=$PWD/deps/venv:$PWD/deps/view CCACHE_DIR=/host/${{ env.CCACHE_DIR }} |
| 110 | + CIBW_ENVIRONMENT_MACOS: CMAKE_PREFIX_PATH=$PWD/deps/venv:$PWD/deps/view MACOSX_DEPLOYMENT_TARGET=15.0 |
| 111 | + CIBW_BEFORE_TEST: ccache -s |
| 112 | + CIBW_TEST_COMMAND: python {project}/acts/Examples/Scripts/Python/track_finding_python_only.py |
| 113 | + |
| 114 | + - name: Set up Python |
| 115 | + uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0 |
| 116 | + with: |
| 117 | + python-version: "3.13" |
| 118 | + |
| 119 | + - name: Patch version to dev version |
| 120 | + if: github.event_name != 'workflow_dispatch' || github.event.inputs.acts_ref == '' |
| 121 | + run: | |
| 122 | + PATCHED_VERSION="$(cat acts/version_number).$(cat build_version.txt)" |
| 123 | + echo "Patch to version $PATCHED_VERSION" |
| 124 | + python3 -m pip install change-wheel-version==0.6.0 |
| 125 | + cd wheelhouse |
| 126 | + for f in ./*.whl; do |
| 127 | + change_wheel_version $f --version $PATCHED_VERSION --delete-old-wheel |
| 128 | + done |
| 129 | +
|
| 130 | + - uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 |
| 131 | + with: |
| 132 | + name: cibw-wheels-${{ matrix.os }}-${{ strategy.job-index }} |
| 133 | + path: ./wheelhouse/*.whl |
| 134 | + |
| 135 | + - name: Save ccache |
| 136 | + uses: actions/cache/save@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5 |
| 137 | + if: always() |
| 138 | + with: |
| 139 | + path: ${{ github.workspace }}/ccache |
| 140 | + key: ${{ steps.ccache-restore.outputs.cache-primary-key }} |
| 141 | + |
| 142 | + |
| 143 | + upload_pypi_test: |
| 144 | + needs: build_wheels |
| 145 | + if: github.event_name != 'workflow_dispatch' || github.event.inputs.acts_ref == '' |
| 146 | + environment: |
| 147 | + name: testpypi |
| 148 | + url: https://test.pypi.org/project/pyacts |
| 149 | + permissions: |
| 150 | + id-token: write |
| 151 | + runs-on: ubuntu-latest |
| 152 | + steps: |
| 153 | + - name: Get wheels |
| 154 | + uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5.0.0 |
| 155 | + with: |
| 156 | + pattern: cibw-* |
| 157 | + path: dist |
| 158 | + merge-multiple: true |
| 159 | + |
| 160 | + - name: Publish package distributions to PyPI |
| 161 | + uses: pypa/gh-action-pypi-publish@cef221092ed1bacb1cc03d23a2d87d1d172e277b # v1.14.0 |
| 162 | + with: |
| 163 | + packages-dir: dist |
| 164 | + repository-url: https://test.pypi.org/legacy/ |
| 165 | + skip-existing: true |
| 166 | + verbose: true |
| 167 | + |
| 168 | + upload_pypi: |
| 169 | + needs: build_wheels |
| 170 | + if: github.event_name == 'workflow_dispatch' && github.event.inputs.acts_ref != '' |
| 171 | + environment: |
| 172 | + name: pypi |
| 173 | + url: https://pypi.org/project/pyacts |
| 174 | + permissions: |
| 175 | + id-token: write |
| 176 | + runs-on: ubuntu-latest |
| 177 | + steps: |
| 178 | + - name: Get wheels |
| 179 | + uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5.0.0 |
| 180 | + with: |
| 181 | + pattern: cibw-* |
| 182 | + path: dist |
| 183 | + merge-multiple: true |
| 184 | + |
| 185 | + - name: Publish package distributions to PyPI |
| 186 | + uses: pypa/gh-action-pypi-publish@cef221092ed1bacb1cc03d23a2d87d1d172e277b # v1.14.0 |
| 187 | + with: |
| 188 | + packages-dir: dist |
| 189 | + skip-existing: true |
| 190 | + verbose: true |
0 commit comments