Debian Codegraph @

.github/workflows/build-and-upload.yml

raw symbols SCIP
1 # https://docs.github.com/en/actions/guides/building-and-testing-python#publishing-to-package-registries
2
3 # When executed manually, this will upload a ".devNNN" build to testpypi;
4 # when executed upon a release, it will upload a regular build to pypi.
5 #
6 # For pypi, you need to have the PYPI_USERNAME and PYPI_PASSWORD secrets configured.
7 # For testpypi, you'll need TESTPYPI_USERNAME and TESTPYPI_PASSWORD.
8
9 name: build & upload
10
11 on:
12 release:
13 types: [ published ]
14 workflow_dispatch: # manual execution
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 # https://github.com/pypa/manylinux
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 # just need ONE of them to do it
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 # for setup.py
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 # for setup.py
73
74 # downgraded to @v3 if using container: https://github.com/actions/checkout/issues/1487
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 # needed for container and self-hosted runners; see https://github.com/actions/checkout/issues/766
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 # MacOS > 14.2 requires Xcode >= 15.3; otherwise loading native extension modules fails with e.g.:
92 # dlopen(/opt/homebrew/lib/python3.11/site-packages/slipcover/probe.abi3.so, 0x0002): bad bind opcode 0x00
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 # https://github.com/actions/virtual-environments/issues/2557
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 # Invoking with "bash -c" works around the "bash.exe: ... could not find /tmp" issue on Windows.
126 # The issue is somehow related to git providing a sh.exe (the "git shell")
127 # See eg https://help.appveyor.com/discussions/problems/1531-having-issues-with-configured-git-bash
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/*