Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor GitHub Actions workflows, get wheels ready, cross-compile macOS wheels #14

Merged
merged 27 commits into from
Jan 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
1f2b597
🔢 Update `nox -s venv` to run commands sequentially
agriyakhetarpal Jan 4, 2024
fcdaf9a
🎁 Add `delocate-fuse` Python wrapper script
agriyakhetarpal Jan 4, 2024
d0a2ea4
🚚 Write various jobs for continuous deployment
agriyakhetarpal Jan 4, 2024
3f7b22f
🏘️ Rename `build` frontend path to `wheelhouse/`
agriyakhetarpal Jan 4, 2024
f803a5f
🚧 Update `CIBW_TEST_COMMAND` to include entry point
agriyakhetarpal Jan 4, 2024
e25736e
🖨️ Display Hugo version and caller path at runtime
agriyakhetarpal Jan 5, 2024
1731f50
⏩ Skip PyPy and MUSL wheel builds
agriyakhetarpal Jan 5, 2024
1152a72
🎾 Fetch latest Go for manylinux2014 containers
agriyakhetarpal Jan 5, 2024
67f4197
🕴️ Don't run `sudo` inside the container
agriyakhetarpal Jan 5, 2024
8060169
😋 Use `yum` and Google FTP servers
agriyakhetarpal Jan 5, 2024
1bb7a58
🏛️ Specify just `amd64` architecture for Linux for now
agriyakhetarpal Jan 5, 2024
64e74a2
🏰 Don't build 32-bit Windows wheels
agriyakhetarpal Jan 5, 2024
bb67137
🎙️ Non-interactive `yum` command invocation and user directory
agriyakhetarpal Jan 5, 2024
6c8e00a
✏️ Install Golang to separate `go_installed/` folder
agriyakhetarpal Jan 5, 2024
c68392c
🛤️ Pass PATH environment variables to build container
agriyakhetarpal Jan 5, 2024
24108e6
🔀 Move helper scripts, platform-wise
agriyakhetarpal Jan 5, 2024
b3d72d0
📝 Bash script to install Golang per architecture
agriyakhetarpal Jan 5, 2024
05543b0
🎩 Set up QEMU for Linux aarch64/arm64 wheels
agriyakhetarpal Jan 5, 2024
6c85d5e
🛣️ Rename artifact paths to check for
agriyakhetarpal Jan 5, 2024
bcad937
🚧 Rename jobs to reflect built architecture
agriyakhetarpal Jan 5, 2024
4b386d3
🐛 Fix EOF-bug for Golang installation script
agriyakhetarpal Jan 5, 2024
6856f62
📂 Add notes about future platform and architecture support
agriyakhetarpal Jan 5, 2024
aa4562c
🚧 Don't run CD on PRs or `main` branch pushes
agriyakhetarpal Jan 5, 2024
2ea5288
👀 Don't run on two Golang versions (security updates)
agriyakhetarpal Jan 5, 2024
a35946d
🚧 Skip CD if it's not a release
agriyakhetarpal Jan 5, 2024
634d7eb
🐛 Resolve bug with incorrect platform specification
agriyakhetarpal Jan 5, 2024
e980b94
🐛 Resolve bug due to which `python -m build` did not work
agriyakhetarpal Jan 5, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
286 changes: 272 additions & 14 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@ name: CD

on:
workflow_dispatch:
# pull_request:
# push:
# branches:
# - main
release:
types:
- published
Expand All @@ -16,33 +12,295 @@ concurrency:

env:
FORCE_COLOR: 3
CIBW_BUILD_VERBOSITY: 2
CIBW_BUILD_FRONTEND: 'pip'
CIBW_SKIP: "pp* *musllinux*"

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

- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Python 3.12
uses: actions/setup-python@v5
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/

- uses: actions/upload-artifact@v4
with:
name: source_distribution
path: dist

windows_wheels:
strategy:
fail-fast: false
name: Windows wheels
runs-on: windows-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
with:
go-version: '1.21.x'
cache: false
check-latest: true

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

- uses: pypa/cibuildwheel@v2.16.2
with:
package-dir: .
output-dir: wheelhouse
env:
CIBW_ARCHS_WINDOWS: AMD64
CIBW_TEST_COMMAND: >
hugo version
hugo env --logLevel debug

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

linux_amd64_wheels:
strategy:
fail-fast: false
name: Linux wheels (amd64)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

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

- uses: pypa/cibuildwheel@v2.16.2
with:
package-dir: .
output-dir: wheelhouse
env:
CIBW_ARCHS_LINUX: x86_64
CIBW_BEFORE_ALL_LINUX: >
yum install -y wget &&
wget https://golang.org/dl/go1.21.5.linux-amd64.tar.gz &&
mkdir $HOME/go_installed &&
tar -C $HOME/go_installed/ -xzf go1.21.5.linux-amd64.tar.gz &&
export PATH="$HOME/go_installed/go/bin:$PATH" &&
go version
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
with:
name: linux_amd64_wheels
path: ./wheelhouse/*.whl
if-no-files-found: error

linux_aarch64_wheels:
strategy:
fail-fast: false
name: Linux wheels (aarch64)
runs-on: ubuntu-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 QEMU for emulation
uses: docker/setup-qemu-action@v3
with:
platforms: all

- uses: pypa/cibuildwheel@v2.16.2
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
with:
name: linux_aarch64_wheels
path: ./wheelhouse/*.whl
if-no-files-found: error

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

- uses: hynek/build-and-inspect-python-package@v2
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.8

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

- uses: pypa/cibuildwheel@v2.16.2
with:
package-dir: .
output-dir: wheelhouse
env:
CIBW_ARCHS_MACOS: x86_64
CIBW_REPAIR_WHEEL_COMMAND_MACOS: ''
CIBW_TEST_COMMAND: >
hugo version
hugo env --logLevel debug

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

macos_arm64_wheels:
strategy:
fail-fast: false
name: macOS wheels (arm64)
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
with:
go-version: '1.21.x'
cache: false
check-latest: true

- uses: pypa/cibuildwheel@v2.16.2
with:
package-dir: .
output-dir: wheelhouse
env:
CIBW_ARCHS_MACOS: arm64
# These are needed to build arm64 binaries on x86_64 macOS
CIBW_ENVIRONMENT_MACOS: >
GOARCH="arm64"
CIBW_REPAIR_WHEEL_COMMAND_MACOS: ''
CIBW_TEST_COMMAND: >
hugo version
hugo env --logLevel debug

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

combined_macos_wheels:
name: Combine macOS wheels
runs-on: macos-latest
needs: [macos_x86_64_wheels, macos_arm64_wheels]
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

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

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

- name: Combine macOS wheels
run: |
mkdir wheelhouse_arm64
mkdir wheelhouse_x86_64
mkdir wheelhouse_universal2
cp macos_x86_64_wheels/*.whl wheelhouse_x86_64/
cp macos_arm64_wheels/*.whl wheelhouse_arm64/
python -m pip install delocate
python scripts/ci/tools/macos/fuse_wheels.py ./wheelhouse_x86_64 ./wheelhouse_arm64 ./wheelhouse_universal2

- name: Upload combined macOS wheels
uses: actions/upload-artifact@v4
with:
name: combined_macos_wheels
path: ./wheelhouse_universal2/*.whl
if-no-files-found: error

publish:
needs: [dist]
name: Publish to PyPI
environment: pypi
needs: [sdist, windows_wheels, linux_amd64_wheels, linux_aarch64_wheels, combined_macos_wheels]
name: Publish to PyPI or TestPyPI
environment: release
permissions:
id-token: write
runs-on: ubuntu-latest
if: github.event_name == 'release' && github.event.action == 'published'

steps:
- uses: actions/download-artifact@v4
with:
name: Packages
path: dist
- name: Download all artifacts
uses: actions/download-artifact@v4

- name: Move all artifacts to upload directory
run: |
mkdir upload
mv source_distribution/* windows_wheels/* linux_amd64_wheels/* linux_aarch64_wheels/* combined_macos_wheels/* upload/

- uses: pypa/gh-action-pypi-publish@release/v1
if: github.event_name == 'release' && github.event.action == 'published'
Expand Down
11 changes: 5 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,12 @@ env:

jobs:
build:
name: Wheels (${{ matrix.runs-on }} / Python ${{ matrix.python-version }} / Go ${{ matrix.go-version }})
name: Wheels (${{ matrix.runs-on }} / Python ${{ matrix.python-version }})
runs-on: ${{ matrix.runs-on }}
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.12"]
go-version: ["1.20.x", "1.21.x"]
runs-on: [ubuntu-latest, macos-latest, windows-latest]

steps:
Expand All @@ -38,7 +37,7 @@ jobs:
- name: Set up Go toolchain
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go-version }}
go-version: "1.21.x"
cache: false
check-latest: true

Expand All @@ -54,20 +53,20 @@ jobs:
uses: actions/cache/restore@v3
with:
path: ./hugo_cache/
key: ${{ runner.os }}-${{ matrix.go-version }}-hugo-build-cache-${{ hashFiles('**/setup.py', '**/pyproject.toml') }}
key: ${{ runner.os }}-hugo-build-cache-${{ hashFiles('**/setup.py', '**/pyproject.toml') }}

- name: Install Python dependencies
run: python -m pip install build virtualenv nox

- name: Build binary distribution (wheel)
run: |
python -m build --wheel . --outdir dist/
python -m build --wheel . --outdir wheelhouse/

- name: Save Hugo builder cache
uses: actions/cache/save@v3
with:
path: ./hugo_cache/
key: ${{ runner.os }}-${{ matrix.go-version }}-hugo-build-cache-${{ hashFiles('**/setup.py', '**/pyproject.toml') }}
key: ${{ runner.os }}-hugo-build-cache-${{ hashFiles('**/setup.py', '**/pyproject.toml') }}

- name: Test entry points for package
run: nox -s venv
3 changes: 2 additions & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
include licenses/LICENSE-hugo.txt
exclude python_hugo/binaries/*
include python_hugo/binaries/*
exclude python_hugo/binaries/hugo-*
Loading
Loading