Skip to content

ci: pin GitHub Actions to full commit SHAs #461

ci: pin GitHub Actions to full commit SHAs

ci: pin GitHub Actions to full commit SHAs #461

Workflow file for this run

name: build
on: [push]
jobs:
build_wheels:
name: Build ${{ matrix.archs }} ${{ matrix.build }} wheels on ${{ matrix.os }}
runs-on: "${{ matrix.os }}${{ (startsWith(matrix.archs, 'aarch64') || startsWith(matrix.archs, 'armv7l')) && '-arm' || '' }}"
strategy:
matrix:
os: [ubuntu-24.04]
archs: ["x86_64, i686", "aarch64", "ppc64le", "s390x", "riscv64", "armv7l"]
build: ["manylinux", "musllinux"]
platform: ["auto"]
include:
- os: windows-2022
archs: "AMD64"
- os: windows-2022
archs: "x86"
- os: windows-11-arm
archs: "ARM64"
- os: macos-15-intel
archs: "x86_64"
- os: macos-14
archs: "arm64"
- os: ubuntu-24.04
archs: "arm64_v8a, x86_64"
platform: "android"
- os: macos-14
archs: "arm64_iphoneos,arm64_iphonesimulator"
platform: "ios"
- os: macos-15-intel
archs: "x86_64_iphonesimulator"
platform: "ios"
- os: ubuntu-24.04
archs: "wasm32"
platform: "pyodide"
steps:
- name: Disable git autocrlf
run: |
git config --global core.autocrlf false
git config --global core.eol lf
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0
submodules: recursive
- name: Set up QEMU
uses: docker/setup-qemu-action@96fe6ef7f33517b61c61be40b68a1882f3264fb8 # v4.2.0
if: runner.os == 'Linux'
- name: Install uv
uses: astral-sh/setup-uv@c771a70e6277c0a99b617c7a806ffedaca235ff9 # v9.0.0
- name: Build wheels
uses: pypa/cibuildwheel@4726cd35bb13f7bde50cf2761f2499ac7b3aa32c # v4.1.1
env:
CIBW_ARCHS: "${{ matrix.archs }}"
CIBW_BUILD: "${{ matrix.build && '*-' || ''}}${{ matrix.build }}*"
CIBW_PLATFORM: "${{ matrix.platform }}"
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: wheels-${{ matrix.os }}-${{ matrix.build }}-${{ matrix.archs }}
path: ./wheelhouse/*.whl
build_sdist:
name: Build sdist
runs-on: ubuntu-24.04
strategy:
matrix:
python-version: ['3.10']
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0
submodules: recursive
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: python -m pip install -U pip 'setuptools>=45'
- name: Build sdist
run: python setup.py build sdist
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: wheels-dist
path: dist/*.tar.gz
upload_test_pypi:
name: Upload to Test PyPI (${{ matrix.group }})
needs: [build_wheels, build_sdist]
runs-on: ubuntu-24.04
if: github.event_name == 'push' && github.repository == 'ifduyue/python-xxhash' && !startsWith(github.ref, 'refs/tags/v')
strategy:
fail-fast: false
matrix:
group:
- 1-of-7
- 2-of-7
- 3-of-7
- 4-of-7
- 5-of-7
- 6-of-7
- 7-of-7
environment:
name: test-pypi
url: https://test.pypi.org/project/xxhash/
permissions:
id-token: write
steps:
- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
pattern: wheels-*
path: dist
merge-multiple: true
- name: Select this group's distributions
run: |
set -euo pipefail
index=$(( $(echo "${{ matrix.group }}" | cut -d- -f1) - 1 ))
count=$(echo "${{ matrix.group }}" | cut -d- -f3)
mkdir -p dist_group
shopt -s nullglob
mapfile -t all < <(printf '%s\n' dist/*.whl dist/*.tar.gz | LC_ALL=C sort)
i=0
for f in "${all[@]}"; do
if [ "$(( i % count ))" -eq "${index}" ]; then
mv -- "$f" dist_group/
fi
i=$(( i + 1 ))
done
echo "Group ${index} of ${count}: ${#all[@]} dists total, kept $(ls dist_group | wc -l) dist(s)"
- name: Upload to Test PyPI
uses: pypa/gh-action-pypi-publish@dc37677b2e1c63e2034f94d8a5b11f265b73ba33 # v1.14.2
with:
packages-dir: dist_group
skip-existing: true
repository-url: https://test.pypi.org/legacy/
upload_pypi:
name: Upload to PyPI (${{ matrix.group }})
needs: [build_wheels, build_sdist]
runs-on: ubuntu-24.04
if: github.event_name == 'push' && github.repository == 'ifduyue/python-xxhash' && startsWith(github.ref, 'refs/tags/v')
strategy:
fail-fast: false
matrix:
group:
- 1-of-7
- 2-of-7
- 3-of-7
- 4-of-7
- 5-of-7
- 6-of-7
- 7-of-7
environment:
name: pypi
url: https://pypi.org/project/xxhash/
permissions:
contents: write
id-token: write
env:
TAG: ${{ github.ref_name }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
if: ${{ strategy.job-index == 0 }}
with:
fetch-depth: 0
- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
pattern: wheels-*
path: dist
merge-multiple: true
- name: Select this group's distributions
id: group
run: |
set -euo pipefail
index=$(( $(echo "${{ matrix.group }}" | cut -d- -f1) - 1 ))
count=$(echo "${{ matrix.group }}" | cut -d- -f3)
mkdir -p dist_group
shopt -s nullglob
mapfile -t all < <(printf '%s\n' dist/*.whl dist/*.tar.gz | LC_ALL=C sort)
i=0
for f in "${all[@]}"; do
if [ "$(( i % count ))" -eq "${index}" ]; then
mv -- "$f" dist_group/
fi
i=$(( i + 1 ))
done
echo "Group ${index} of ${count}: ${#all[@]} dists total, kept $(ls dist_group | wc -l) dist(s)"
- name: Check whether the GitHub Release already exists
if: ${{ strategy.job-index == 0 }}
id: check-release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
set -euo pipefail
if gh api "repos/${GITHUB_REPOSITORY}/releases/tags/${TAG}" \
--silent 2>err; then
echo 'exists=true' >> "${GITHUB_OUTPUT}"
elif grep -q 'HTTP 404' err; then
echo 'exists=false' >> "${GITHUB_OUTPUT}"
else
cat err >&2
exit 1
fi
- name: Create GitHub Release
if: ${{ strategy.job-index == 0 && steps.check-release.outputs.exists != 'true' }}
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAG: ${{ github.ref_name }}
REPO: ${{ github.repository }}
run: |
set -euo pipefail
python3 .github/workflows/create_release_notes.py
gh release create "${TAG}" \
--repo "${GITHUB_REPOSITORY}" \
--title "${TAG}" \
--notes-file release_notes.md
- name: Wait for the GitHub Release
if: ${{ strategy.job-index != 0 }}
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
set -euo pipefail
for _ in $(seq 1 150); do
if gh api "repos/${GITHUB_REPOSITORY}/releases/tags/${TAG}" \
--silent 2>err; then
exit 0
fi
if ! grep -q 'HTTP 404' err; then
cat err >&2
exit 1
fi
sleep 2
done
echo "GitHub Release ${TAG} did not appear in time" >&2
exit 1
- name: Upload to PyPI
uses: pypa/gh-action-pypi-publish@dc37677b2e1c63e2034f94d8a5b11f265b73ba33 # v1.14.2
with:
packages-dir: dist_group
skip-existing: true
- name: Upload assets to GitHub Release
uses: softprops/action-gh-release@3d0d9888cb7fd7b750713d6e236d1fcb99157228 # v3.0.2
with:
files: |
dist_group/*.whl
dist_group/*.tar.gz