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

Modernize CI/CD workflow #1163

Merged
merged 2 commits into from
Aug 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
122 changes: 64 additions & 58 deletions .github/workflows/ci-cd.yml
Original file line number Diff line number Diff line change
@@ -1,31 +1,65 @@
---
name: CI/CD

on:
push:
jakob-keller marked this conversation as resolved.
Show resolved Hide resolved
branches:
- 'master'
tags: [ '[0-9]+.[0-9]+.[0-9]+' ]
- master
tags:
- >-
[0-9]+.[0-9]+.[0-9]+
pull_request:
branches:
- 'master'
- '[0-9].[0-9]+.[0-9]+'
- master
- >-
[0-9].[0-9]+.[0-9]+

env:
FORCE_COLOR: 1

jobs:
build:
name: Build distribution 📦
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.x
- name: Install build dependencies
run: python -m pip install build twine
- name: Build distribution 📦
run: python -m build
- name: Check distribution 📦
run: python -m twine check --strict dist/*
- name: Upload distribution 📦
uses: actions/upload-artifact@v4
with:
name: python-package-distributions
path: dist/

test:
name: Test Python ${{ matrix.python-version }}
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12', '3.13']
python-version:
- 3.8
- 3.9
- >-
3.10
- 3.11
- 3.12
- 3.13
include:
- aiohttp-version: '==3.9.2'
- aiohttp-version: '<4.0.0'
python-version: '3.11'
- aiohttp-version: ==3.9.2
- aiohttp-version: <4.0.0
python-version: 3.11
fail-fast: false
timeout-minutes: 15
jakob-keller marked this conversation as resolved.
Show resolved Hide resolved
jakob-keller marked this conversation as resolved.
Show resolved Hide resolved

steps:
- name: Checkout
uses: actions/checkout@v4
Expand All @@ -40,8 +74,8 @@ jobs:
env:
AIOHTTP_VERSION: ${{ matrix.aiohttp-version }}
run: |
python -c "import sys; print(f'Python version: {sys.version}')"
python -m pip install -U setuptools pip codecov wheel pip-tools
python -V -V
python -m pip install -U pip codecov pip-tools
time pip-compile requirements-dev.in
time pip-sync requirements-dev.txt
- name: Run pre-commit hooks
Expand All @@ -57,60 +91,32 @@ jobs:
if: matrix.python-version == '3.11'
uses: codecov/[email protected]
with:
token: ${{ secrets.CODECOV_TOKEN }} # not required for public repos
token: ${{ secrets.CODECOV_TOKEN }} # not required for public repos
files: ./coverage.xml
flags: unittests # optional
name: codecov-umbrella # optional
fail_ci_if_error: true # optional (default = false)
verbose: true # optional (default = false)


pre-deploy:
name: Pre-Deploy
runs-on: ubuntu-latest
needs: test
# Run only on pushing a tag
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
steps:
- name: Dummy
run: |
echo "Predeploy step"
flags: unittests # optional
name: codecov-umbrella # optional
fail_ci_if_error: true # optional (default = false)
verbose: true # optional (default = false)

build-tarball:
name: Tarball
runs-on: ubuntu-latest
needs: pre-deploy
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: true
- name: Setup Python 3.8
uses: actions/setup-python@v5
with:
python-version: 3.8
- name: Make distributions (sdist and wheel)
run: |
python -c "import sys; print(f'Python version: {sys.version}')"
python -m pip install -U setuptools pip wheel
python setup.py sdist bdist_wheel
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: dist
path: dist

deploy:
name: Deploy
needs: [build-tarball]
pypi-publish:
name: Publish Python 🐍 distribution 📦 to PyPI
if: github.ref_type == 'tag' # only publish on tag pushes
needs:
- build
- test
jakob-keller marked this conversation as resolved.
Show resolved Hide resolved
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/project/aiobotocore/${{ github.ref_name }}
permissions:
# IMPORTANT: this permission is mandatory for trusted publishing
id-token: write

steps:
- name: Download dists
jakob-keller marked this conversation as resolved.
Show resolved Hide resolved
- name: Download distribution 📦
uses: actions/download-artifact@v4
with:
name: dist
path: dist
- name: PyPI upload
name: python-package-distributions
path: dist/
- name: Publish distribution 📦 to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[build-system]
requires = ["setuptools"]
requires = ["setuptools>=72.2.0"]
jakob-keller marked this conversation as resolved.
Show resolved Hide resolved
build-backend = "setuptools.build_meta"

[project]
Expand Down