Bump pypa/cibuildwheel from 2.21.3 to 2.22.0 #110
Workflow file for this run
This file contains 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 wheels | |
on: | |
push: | |
tags: '*' | |
pull_request: ~ | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} | |
cancel-in-progress: false | |
jobs: | |
generate_wheels_matrix: | |
name: Generate wheels matrix | |
runs-on: ubuntu-latest | |
outputs: | |
include: ${{ steps.set-matrix.outputs.include }} | |
mypy_version: ${{ steps.mypy-version.outputs.mypy_version }} | |
mypy_sha: ${{ steps.mypy-version.outputs.mypy_sha }} | |
tag_version: ${{ steps.tag-version.outputs.tag_version }} | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
submodules: recursive | |
- uses: actions/setup-python@v5 | |
name: Install Python | |
with: | |
python-version: "3.13" | |
- name: Install cibuildwheel and pypyp | |
run: | | |
pipx install cibuildwheel==2.22.0 | |
pipx install pypyp==1.2.0 | |
- id: set-matrix | |
run: | | |
MATRIX=$( | |
{ | |
cibuildwheel --config-file=cibuildwheel.toml --print-build-identifiers --platform linux mypy \ | |
| pyp 'json.dumps({"only": x, "os": "ubuntu-latest"})' \ | |
&& cibuildwheel --config-file=cibuildwheel.toml --print-build-identifiers --platform macos mypy \ | |
| pyp 'json.dumps({"only": x, "os": "macos-14"})' \ | |
&& cibuildwheel --config-file=cibuildwheel.toml --print-build-identifiers --platform windows mypy \ | |
| pyp 'json.dumps({"only": x, "os": "windows-latest"})' | |
} | pyp 'json.dumps(list(map(json.loads, lines)))' | |
) | |
echo "include=$MATRIX" | tee -a $GITHUB_OUTPUT | |
env: | |
CIBW_ARCHS_LINUX: x86_64 | |
CIBW_ARCHS_MACOS: x86_64 arm64 | |
CIBW_ARCHS_WINDOWS: AMD64 | |
- name: Get mypy version | |
id: mypy-version | |
run: | | |
cd mypy | |
mypy_version=$(python -c "from mypy.version import __version__; print(__version__)") | |
mypy_sha=$(python -c "from mypy.git import git_revision as rev; print(rev('.').decode('utf-8'))") | |
echo "mypy_version: ${mypy_version}" | |
echo "mypy_version=${mypy_version}" >> $GITHUB_OUTPUT | |
echo "mypy_sha: ${mypy_sha}" | |
echo "mypy_sha=${mypy_sha}" >> $GITHUB_OUTPUT | |
- name: Get version tag | |
id: tag-version | |
run: | | |
if [[ "${{ github.event_name }}" == "push" ]]; then | |
echo "github_ref: ${{ github.ref }}" | |
tag_version=$(echo "${{ github.ref }}" | cut -d "/" -f3) | |
echo "tag_version: ${tag_version}" | |
mypy_base=$(echo "${{ steps.mypy-version.outputs.mypy_version }}" | cut -d "+" -f1) | |
echo "mypy_base: ${mypy_base}" | |
if [[ "${tag_version}" != "${mypy_base}"* ]]; then | |
echo "Base tag_version does not match base mypy_version!" | |
exit 1 | |
fi | |
else | |
echo "Pull request or workflow dispatch" | |
echo "Set placeholder version" | |
tag_version=1.0.0 | |
echo "tag_version: ${tag_version}" | |
fi | |
echo "tag_version=${tag_version}" >> $GITHUB_OUTPUT | |
build_wheels: | |
name: Build ${{ matrix.only }} | |
needs: generate_wheels_matrix | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
include: ${{ fromJson(needs.generate_wheels_matrix.outputs.include) }} | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
submodules: recursive | |
- uses: actions/setup-python@v5 | |
name: Install Python | |
with: | |
python-version: "3.13" | |
- name: Modify setup.py | |
run: | | |
pip install -U -r requirements.txt | |
python scripts/modify_setup.py ${{ needs.generate_wheels_matrix.outputs.tag_version }} | |
- uses: pypa/[email protected] | |
with: | |
config-file: cibuildwheel.toml | |
package-dir: mypy | |
only: ${{ matrix.only }} | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: dist-${{ matrix.only }} | |
path: ./wheelhouse/*.whl | |
overwrite: true | |
build_sdist_python_wheel: | |
name: sdist and python wheel | |
needs: generate_wheels_matrix | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
submodules: recursive | |
- uses: actions/setup-python@v5 | |
name: Install Python | |
with: | |
python-version: "3.13" | |
- name: Modify setup.py | |
run: | | |
pip install -U -r requirements.txt | |
python scripts/modify_setup.py ${{ needs.generate_wheels_matrix.outputs.tag_version }} | |
- name: Build sdist and wheel | |
run: | | |
cd mypy | |
pip install --upgrade setuptools build | |
python -m build | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: dist-sdist_python_wheel | |
path: | | |
mypy/dist/*.whl | |
mypy/dist/*.tar.gz | |
overwrite: true | |
release: | |
name: Create release and upload assets | |
needs: | |
- generate_wheels_matrix | |
- build_wheels | |
- build_sdist_python_wheel | |
runs-on: ubuntu-latest | |
environment: | |
name: Release | |
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') | |
permissions: | |
contents: write # Required to upload release assets | |
steps: | |
- name: Download artifact | |
uses: actions/download-artifact@v4 | |
with: | |
pattern: dist-* | |
path: dist | |
merge-multiple: true | |
- name: Release | |
uses: actions/github-script@v7 | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
script: | | |
// https://github.com/actions/upload-release-asset/issues/47 | |
const fs = require('fs').promises; | |
const { repo: { owner, repo }, sha } = context; | |
console.log('environment', process.versions); | |
console.log({ owner, repo, sha }); | |
let releaseId; | |
let assetNames = []; | |
const tagName = process.env.GITHUB_REF.split("/").pop(); | |
const body = ( | |
'Tracking mypy version: `${{ needs.generate_wheels_matrix.outputs.mypy_version }}`' | |
+ '\n\n' + 'https://github.com/python/mypy/commit/${{ needs.generate_wheels_matrix.outputs.mypy_sha }}' | |
); | |
try { | |
const response = await github.rest.repos.getReleaseByTag({ | |
owner, repo, | |
tag: tagName, | |
}); | |
assetNames = response.data.assets.map((asset) => asset.name); | |
releaseId = response.data.id; | |
console.log('found an existing release', releaseId); | |
console.log('found existing release assets', assetNames); | |
} catch (e) {} | |
if (releaseId == undefined) { | |
const release = await github.rest.repos.createRelease({ | |
owner, repo, | |
tag_name: tagName, | |
name: tagName, | |
body: body, | |
}); | |
console.log('created release', { release }); | |
releaseId = release.data.id; | |
} | |
for (let file of await fs.readdir('dist')) { | |
if (assetNames.find((name) => name == file) != undefined) { | |
console.log('asset already exists, skipping', file) | |
continue; | |
} | |
console.log('uploading', file); | |
await github.rest.repos.uploadReleaseAsset({ | |
owner, repo, | |
release_id: releaseId, | |
name: file, | |
data: await fs.readFile(`./dist/${file}`) | |
}); | |
} | |
upload: | |
name: Upload release to PyPI | |
needs: | |
- release | |
runs-on: ubuntu-latest | |
environment: | |
name: PyPI | |
url: https://pypi.org/project/mypy-dev/ | |
steps: | |
- name: Download artifact | |
uses: actions/download-artifact@v4 | |
with: | |
pattern: dist-* | |
path: dist | |
merge-multiple: true | |
- uses: actions/setup-python@v5 | |
name: Install Python | |
with: | |
python-version: "3.13" | |
- name: Install twine | |
run: | | |
pip install twine | |
- name: Upload to PyPI | |
env: | |
TWINE_REPOSITORY: pypi | |
TWINE_USERNAME: __token__ | |
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }} | |
run: | | |
twine upload --verbose --skip-existing dist/* |