Skip to content

Commit

Permalink
😇 Revamp CD workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
agriyakhetarpal committed Mar 23, 2024
1 parent d0f7b68 commit a85207b
Showing 1 changed file with 66 additions and 157 deletions.
223 changes: 66 additions & 157 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,61 +13,56 @@ concurrency:
env:
FORCE_COLOR: 3
CIBW_BUILD_VERBOSITY: 2
CIBW_BUILD_FRONTEND: 'pip'
CIBW_BUILD_FRONTEND: "pip"
CIBW_BUILD: "cp312-*"
CIBW_SKIP: "pp* *musllinux*"
CIBW_MANYLINUX_X86_64_IMAGE: "manylinux_2_28"
CIBW_MANYLINUX_AARCH64_IMAGE: "manylinux_2_28"

jobs:
sdist:
name: Build source distribution
name: sdist
runs-on: ubuntu-latest
steps:

- uses: actions/checkout@v4
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
fetch-depth: 0

- name: Set up Python 3.12
uses: actions/setup-python@v5
uses: actions/setup-python@0a5c61591373683505ea898e09a3ea4f39ef2b9c # v5.0.0
with:
python-version: 3.12

- name: Install dependencies
run: |
python -m pip install build
- name: Build source distribution
run: |
python -m build --sdist --outdir dist/
pipx run build --sdist --outdir dist/
- uses: actions/upload-artifact@v4
- uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1
with:
name: source_distribution
path: dist
if-no-files-found: error

windows_wheels:
name: Windows wheels (amd64)
windows_amd64_wheels:
name: amd64-windows
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Python
uses: actions/setup-python@v5
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- uses: actions/setup-python@0a5c61591373683505ea898e09a3ea4f39ef2b9c # v5.0.0
with:
python-version: 3.8
python-version: 3.12

- name: Set up Go toolchain
uses: actions/setup-go@v5
uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0
with:
go-version: '1.22.1'
cache: false

- name: Install MinGW compiler(s)
run: choco install mingw

- uses: pypa/cibuildwheel@v2.17.0
- uses: pypa/cibuildwheel@8d945475ac4b1aac4ae08b2fd27db9917158b6ce # v2.17.0
with:
package-dir: .
output-dir: wheelhouse
Expand All @@ -78,177 +73,90 @@ jobs:
hugo env --logLevel debug
- name: Upload wheels
uses: actions/upload-artifact@v4
uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1
with:
name: windows_wheels
name: wheels_windows_amd64
path: ./wheelhouse/*.whl
if-no-files-found: error

linux_amd64_wheels:
name: Linux wheels (amd64)
name: amd64-linux
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- uses: actions/setup-python@0a5c61591373683505ea898e09a3ea4f39ef2b9c # v5.0.0
with:
fetch-depth: 0

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.8
python-version: 3.12

- uses: pypa/cibuildwheel@v2.17.0
- uses: pypa/cibuildwheel@8d945475ac4b1aac4ae08b2fd27db9917158b6ce # v2.17.0
with:
package-dir: .
output-dir: wheelhouse
env:
CIBW_ARCHS_LINUX: x86_64
CIBW_BEFORE_ALL_LINUX: bash scripts/ci/tools/linux/install_go.sh
CIBW_ENVIRONMENT_LINUX: PATH=$PATH:$HOME/go_installed/go/bin
CIBW_REPAIR_WHEEL_COMMAND_LINUX: ''
CIBW_TEST_COMMAND: >
hugo version
hugo env --logLevel debug
- name: Upload wheels
uses: actions/upload-artifact@v4
uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1
with:
name: linux_amd64_wheels
name: wheels_linux_amd64
path: ./wheelhouse/*.whl
if-no-files-found: error

linux_aarch64_wheels:
name: Linux wheels (aarch64)
linux_arm64_wheels:
name: arm64-linux
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- uses: actions/setup-python@0a5c61591373683505ea898e09a3ea4f39ef2b9c # v5.0.0
with:
fetch-depth: 0

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.8
python-version: 3.12

- name: Set up QEMU for emulation
uses: docker/setup-qemu-action@v3
uses: docker/setup-qemu-action@68827325e0b33c7199eb31dd4e31fbe9023e06e3 # v3.0.0
with:
platforms: all

- uses: pypa/cibuildwheel@v2.17.0
- uses: pypa/cibuildwheel@8d945475ac4b1aac4ae08b2fd27db9917158b6ce # v2.17.0
with:
package-dir: .
output-dir: wheelhouse
env:
CIBW_ARCHS_LINUX: aarch64
CIBW_BEFORE_ALL_LINUX: bash scripts/ci/tools/linux/install_go.sh
CIBW_ENVIRONMENT_LINUX: PATH=$PATH:$HOME/go_installed/go/bin
CIBW_REPAIR_WHEEL_COMMAND_LINUX: ''
CIBW_TEST_COMMAND: >
hugo version
hugo env --logLevel debug
- name: Upload wheels
uses: actions/upload-artifact@v4
uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1
with:
name: linux_aarch64_wheels
name: wheels_linux_aarch64
path: ./wheelhouse/*.whl
if-no-files-found: error

repair_linux_wheels:
name: Repair Linux wheels
runs-on: ubuntu-latest
needs: [linux_amd64_wheels, linux_aarch64_wheels]
macos_amd64_wheels:
name: amd64-macos
runs-on: macos-13
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Download Linux wheels for both architectures
uses: actions/download-artifact@v4

- name: Set up Python
uses: actions/setup-python@v5
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- uses: actions/setup-python@0a5c61591373683505ea898e09a3ea4f39ef2b9c # v5.0.0
with:
python-version: 3.12

- name: Repair Linux wheels to add conformant platform tags
run: |
mkdir wheelhouse_amd64
mkdir wheelhouse_aarch64
mkdir repaired_linux_wheels
cp linux_amd64_wheels/*.whl wheelhouse_amd64/
cp linux_aarch64_wheels/*.whl wheelhouse_aarch64/
python scripts/ci/tools/linux/repair_wheels.py ./wheelhouse_amd64 ./repaired_linux_wheels
python scripts/ci/tools/linux/repair_wheels.py ./wheelhouse_aarch64 ./repaired_linux_wheels
- name: Upload repaired Linux wheels
uses: actions/upload-artifact@v4
with:
name: repaired_linux_wheels
path: ./repaired_linux_wheels/*.whl
if-no-files-found: error

macos_arm64_cp38_hotfix:
name: macOS wheels (arm64) with Python 3.8
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.9

- name: Set up Go toolchain
uses: actions/setup-go@v5
with:
go-version: '1.22.1'
cache: false
check-latest: true

- uses: pypa/cibuildwheel@v2.17.0
with:
package-dir: .
output-dir: wheelhouse
env:
# Cross-compile for arm64 on macOS x86_64 with Python 3.8 for now
# See https://github.com/pypa/cibuildwheel/issues/1278
GOARCH: arm64
CIBW_ARCHS_MACOS: arm64
CIBW_PROJECT_REQUIRES_PYTHON: ">=3.8,<3.9"
CIBW_REPAIR_WHEEL_COMMAND_MACOS: ''

- name: Upload wheels
uses: actions/upload-artifact@v4
with:
name: macos_arm64_cp38_hotfix
path: ./wheelhouse/*.whl
if-no-files-found: error

macos_x86_64_wheels:
name: macOS wheels (x86_64)
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.8

- name: Set up Go toolchain
uses: actions/setup-go@v5
uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0
with:
go-version: '1.22.1'
cache: false
check-latest: true

- uses: pypa/cibuildwheel@v2.17.0
- uses: pypa/cibuildwheel@8d945475ac4b1aac4ae08b2fd27db9917158b6ce # v2.17.0
with:
package-dir: .
output-dir: wheelhouse
Expand All @@ -260,53 +168,56 @@ jobs:
hugo env --logLevel debug
- name: Upload wheels
uses: actions/upload-artifact@v4
uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1
with:
name: macos_x86_64_wheels
name: wheels_macos_x86_64
path: ./wheelhouse/*.whl
if-no-files-found: error

macos_arm64_wheels:
name: macOS wheels (arm64)
name: arm64-macos
runs-on: macos-14
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Python
uses: actions/setup-python@v5
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- uses: actions/setup-python@0a5c61591373683505ea898e09a3ea4f39ef2b9c # v5.0.0
with:
python-version: 3.12

- name: Set up Go toolchain
uses: actions/setup-go@v5
uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0
with:
go-version: '1.22.1'
cache: false
check-latest: true

- uses: pypa/cibuildwheel@v2.17.0
- uses: pypa/cibuildwheel@8d945475ac4b1aac4ae08b2fd27db9917158b6ce # v2.17.0
with:
package-dir: .
output-dir: wheelhouse
env:
CIBW_PROJECT_REQUIRES_PYTHON: ">=3.9"
CIBW_ARCHS_MACOS: arm64
CIBW_REPAIR_WHEEL_COMMAND_MACOS: ''
CIBW_TEST_COMMAND: >
hugo version
hugo env --logLevel debug
- name: Upload wheels
uses: actions/upload-artifact@v4
uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1
with:
name: macos_arm64_wheels
name: wheels_macos_arm64
path: ./wheelhouse/*.whl
if-no-files-found: error

publish:
needs: [sdist, windows_wheels, repair_linux_wheels, macos_arm64_cp38_hotfix, macos_x86_64_wheels, macos_arm64_wheels]
needs: [
sdist,
windows_amd64_wheels,
macos_amd64_wheels,
macos_arm64_wheels,
linux_amd64_wheels,
linux_arm64_wheels
]

name: Publish to PyPI or TestPyPI
environment: release
permissions:
Expand All @@ -317,23 +228,21 @@ jobs:

steps:
- name: Download all artifacts
uses: actions/download-artifact@v4

- name: Move all artifacts to upload directory
run: |
mkdir upload
mv source_distribution/* windows_wheels/* repaired_linux_wheels/* macos_arm64_cp38_hotfix/* macos_x86_64_wheels/* macos_arm64_wheels/* upload/
uses: actions/download-artifact@c850b930e6ba138125429b7e5c93fc707a7f8427 #v4.1.4
with:
path: upload/
merge-multiple: true

- uses: pypa/gh-action-pypi-publish@release/v1
- uses: pypa/gh-action-pypi-publish@81e9d935c883d0b210363ab89cf05f3894778450 # v1.8.14
if: github.event_name == 'release' && github.event.action == 'published'
with:
# Remember to tell (test-)pypi about this repo before publishing
# Remove this line to publish to PyPI
# Comment this line out to publish to PyPI
# repository-url: https://test.pypi.org/legacy/
packages-dir: upload

- name: Publish to GitHub Releases
uses: softprops/action-gh-release@v2.0.4
uses: softprops/action-gh-release@9d7c94cfd0a1f3ed45544c887983e9fa900f0564 # v2.0.4
if: github.event_name == 'release' && github.event.action == 'published'
with:
files: upload/*

0 comments on commit a85207b

Please sign in to comment.