| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
name: build & upload |
| 10 |
|
| 11 |
on: |
| 12 |
release: |
| 13 |
types: [ published ] |
| 14 |
workflow_dispatch: |
| 15 |
|
| 16 |
jobs: |
| 17 |
pick-devN: |
| 18 |
name: create .devN build date coordinated across all matrix jobs |
| 19 |
runs-on: ubuntu-latest |
| 20 |
steps: |
| 21 |
- run: TZ='America/New_York' date '+%Y%m%d%H%M' > devN.txt |
| 22 |
|
| 23 |
- uses: actions/upload-artifact@v4 |
| 24 |
with: |
| 25 |
name: devN |
| 26 |
path: devN.txt |
| 27 |
|
| 28 |
build-and-upload: |
| 29 |
needs: pick-devN |
| 30 |
strategy: |
| 31 |
matrix: |
| 32 |
python_version: ['3.9', '3.10', '3.11', '3.12', '3.13'] |
| 33 |
plat: ['manylinux_2_28', 'macos-13', 'macos-latest', 'windows-latest'] |
| 34 |
include: |
| 35 |
- plat: manylinux_2_28 |
| 36 |
os: ubuntu-latest |
| 37 |
container: quay.io/pypa/manylinux_2_28_x86_64 |
| 38 |
|
| 39 |
- plat: macos-13 |
| 40 |
os: macos-13 |
| 41 |
|
| 42 |
- plat: macos-latest |
| 43 |
os: macos-latest |
| 44 |
|
| 45 |
- plat: macos-latest |
| 46 |
os: macos-latest |
| 47 |
python_version: 3.11 |
| 48 |
upload_source: true |
| 49 |
|
| 50 |
- plat: windows-latest |
| 51 |
os: windows-latest |
| 52 |
|
| 53 |
exclude: |
| 54 |
- plat: windows-latest |
| 55 |
python_version: 3.11 |
| 56 |
|
| 57 |
runs-on: ${{ matrix.os }} |
| 58 |
container: ${{ matrix.container }} |
| 59 |
|
| 60 |
steps: |
| 61 |
- name: get coordinated .devN |
| 62 |
uses: actions/download-artifact@v4 |
| 63 |
with: |
| 64 |
name: devN |
| 65 |
|
| 66 |
- name: make dev build if not a release (non-Windows version) |
| 67 |
if: github.event_name != 'release' && matrix.os != 'windows-latest' |
| 68 |
run: echo "DEV_BUILD=$(cat devN.txt)" >> $GITHUB_ENV |
| 69 |
|
| 70 |
- name: make dev build if not a release (Windows version) |
| 71 |
if: github.event_name != 'release' && matrix.os == 'windows-latest' |
| 72 |
run: ("DEV_BUILD=" + (get-content devN.txt)) >> $env:GITHUB_ENV |
| 73 |
|
| 74 |
|
| 75 |
- uses: actions/checkout@v3 |
| 76 |
if: matrix.container != '' |
| 77 |
|
| 78 |
- uses: actions/checkout@v4 |
| 79 |
if: matrix.container == '' |
| 80 |
|
| 81 |
- name: Mark workspace safe for git |
| 82 |
|
| 83 |
if: matrix.container != '' |
| 84 |
run: | |
| 85 |
git config --global --add safe.directory "$GITHUB_WORKSPACE" |
| 86 |
# setuptool's bdist uses 'git archive' to find files, and fails silently if it can't, |
| 87 |
# leading to missing files in the archive. Run it separately to force a failure in that case. |
| 88 |
(cd scalene; git archive --prefix scalene/ HEAD | tar -t > /dev/null) |
| 89 |
|
| 90 |
- name: select Xcode version |
| 91 |
|
| 92 |
|
| 93 |
if: startsWith(matrix.os, 'macos-') |
| 94 |
run: | |
| 95 |
if [ -d /Applications/Xcode_15.3.app/Contents/Developer ]; then sudo xcode-select --switch /Applications/Xcode_15.3.app/Contents/Developer; fi |
| 96 |
clang++ --version |
| 97 |
g++ --version |
| 98 |
|
| 99 |
- name: Set up python (script version) |
| 100 |
if: matrix.container == '' |
| 101 |
uses: actions/setup-python@v5 |
| 102 |
with: |
| 103 |
python-version: ${{ matrix.python_version }} |
| 104 |
|
| 105 |
- name: Set up python (container version) |
| 106 |
if: matrix.container != '' |
| 107 |
run: | |
| 108 |
PYV=`echo "${{ matrix.python_version }}" | tr -d "."`; ls -d -1 /opt/python/cp$PYV*/bin | head -n 1 >> $GITHUB_PATH |
| 109 |
cat $GITHUB_PATH |
| 110 |
|
| 111 |
- name: Install dependencies |
| 112 |
run: | |
| 113 |
pip3 install --upgrade setuptools wheel twine build virtualenv |
| 114 |
|
| 115 |
- name: Work around arm64 support on MacOS |
| 116 |
|
| 117 |
if: matrix.os == 'macos-latest' |
| 118 |
run: sudo rm -Rf /Library/Developer/CommandLineTools/SDKs/* |
| 119 |
|
| 120 |
- name: Build source dist |
| 121 |
if: matrix.upload_source |
| 122 |
run: make sdist |
| 123 |
|
| 124 |
- name: Build binary dist |
| 125 |
|
| 126 |
|
| 127 |
|
| 128 |
run: bash -c "make bdist" |
| 129 |
|
| 130 |
- name: Check that all required platforms are included |
| 131 |
if: matrix.os == 'macos-latest' |
| 132 |
run: | |
| 133 |
for P in x86_64 arm64 arm64e; do |
| 134 |
for F in build/lib.*/scalene/*.so ; do |
| 135 |
file $F | grep -q "\\b$P\\b" |
| 136 |
if [ $? != 0 ]; then |
| 137 |
echo "$P missing" |
| 138 |
exit 1 |
| 139 |
fi |
| 140 |
done |
| 141 |
done |
| 142 |
|
| 143 |
- name: Non-release (dev) upload |
| 144 |
if: github.event_name != 'release' |
| 145 |
env: |
| 146 |
TWINE_REPOSITORY: testpypi |
| 147 |
TWINE_USERNAME: __token__ |
| 148 |
TWINE_PASSWORD: ${{ secrets.TESTPYPI_TOKEN }} |
| 149 |
run: twine upload --verbose dist/* |
| 150 |
|
| 151 |
- name: Release upload |
| 152 |
if: github.event_name == 'release' |
| 153 |
env: |
| 154 |
TWINE_USERNAME: __token__ |
| 155 |
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }} |
| 156 |
run: twine upload --verbose dist/* |