Skip to content

Commit

Permalink
Merge pull request #120 from BurningEnlightenment/dev/ci
Browse files Browse the repository at this point in the history
ci: Split deployment jobs into separate workflows
  • Loading branch information
Holzhaus authored Oct 6, 2024
2 parents a5c2347 + 9fcb06e commit 09cf630
Show file tree
Hide file tree
Showing 6 changed files with 240 additions and 78 deletions.
17 changes: 17 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Editor configuration, see http://editorconfig.org
root = true

[*]
charset = utf-8
indent_style = space
indent_size = 4
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
max_line_length = 79

[*.{md,rst}]
trim_trailing_whitespace = false

[*.y{,a}ml]
indent_size = 2
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* text=auto eol=lf
96 changes: 18 additions & 78 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,33 +1,35 @@
name: build

on:
push:
pull_request:
workflow_call:

jobs:
build:
name: Build and Test Package
strategy:
matrix:
version:
- '3.8'
- '3.9'
- '3.10'
- '3.11'
- '3.12'
os: [ubuntu-latest, windows-latest]
matrix:
version:
- '3.8'
- '3.9'
- '3.10'
- '3.11'
- '3.12'
os: [ubuntu-latest, windows-latest]
include:
- version: '3.12'
os: ubuntu-latest
upload: true
runs-on: ${{ matrix.os }}

steps:
- name: Check out repository
uses: actions/checkout@v4

- name: Set up Python
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.version }}

- name: Install package
- name: Install packages
run: pip install .

- name: Run tests
Expand All @@ -42,9 +44,8 @@ jobs:
- name: Upload the Docs
uses: actions/upload-pages-artifact@v3
if: matrix.os == 'ubuntu-latest' && matrix.version == '3.12'
if: matrix.upload
with:
name: docs
path: html/

- name: Install pypa/build
Expand All @@ -54,69 +55,8 @@ jobs:
run: python3 -m build

- name: Store the distribution packages
if: matrix.os == 'ubuntu-latest' && matrix.version == '3.12'
if: matrix.upload
uses: actions/upload-artifact@v4
with:
name: python-package-distributions
path: dist/

deploy-docs:
name: Deploy Docs to GitHub Pages
if: ${{ startsWith(github.ref, 'refs/tags/') || github.ref == 'refs/heads/main' }}
runs-on: ubuntu-latest
needs: [build]
permissions:
pages: write # to deploy to Pages
id-token: write # to verify the deployment originates from an appropriate source
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}

steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4 # or specific "vX.X.X" version tag for this action
with:
artifact_name: docs

deploy-testpypi:
name: Deploy Distribution to Test PyPI
if: false # Currently disabled
needs: [build]
runs-on: ubuntu-latest
environment:
name: testpypi
url: https://test.pypi.org/p/sphinx-multiversion
permissions:
id-token: write

steps:
- name: Download the Distributions
uses: actions/download-artifact@v4
with:
name: python-package-distributions
path: dist/

- name: Publish Distributions to Test PyPI
uses: pypa/gh-action-pypi-publish@release/v1

deploy-pypi:
name: Deploy Distribution to PyPI
if: startsWith(github.ref, 'refs/tags/')
needs: [build]
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/sphinx-multiversion
permissions:
id-token: write

steps:
- name: Download the Distributions
uses: actions/download-artifact@v4
with:
name: python-package-distributions
path: dist/

- name: Publish Distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
35 changes: 35 additions & 0 deletions .github/workflows/deploy-github-pages.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Deploy docs to Github Pages

on:
push:
branches: [main]
tags:
- 'v*'

# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
concurrency:
group: "pages"
cancel-in-progress: false

jobs:
build:
if: github.ref_protected == true
uses: ./.github/workflows/build.yml

deploy-docs:
name: Deploy Docs to GitHub Pages
if: github.ref_protected == true
runs-on: ubuntu-latest
needs: [build]
permissions:
pages: write # to deploy to Pages
id-token: write # to verify the deployment originates from an appropriate source
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}

steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
34 changes: 34 additions & 0 deletions .github/workflows/deploy-pypi.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: deploy-pypi

on:
release:
types: [published]

jobs:
build:
if: github.ref_protected == true
uses: ./.github/workflows/build.yml

deploy-pypi:
if: github.ref_protected == true
needs: [build]
strategy:
matrix:
environment: [test.pypi, pypi]
name: Deploy Distribution to ${{ matrix.environment }}.org
runs-on: ubuntu-latest
environment:
name: ${{ matrix.environment }}
url: https://${{ matrix.environment }}.org/p/sphinx-multiversion
permissions:
id-token: write

steps:
- name: Download the Distributions
uses: actions/download-artifact@v4 # eventually rely on artifacts uploaded to the draft release
with:
name: python-package-distributions
path: dist/

- name: Publish Distributions to ${{ matrix.environment }}.org
uses: pypa/gh-action-pypi-publish@f7600683efdcb7656dec5b29656edb7bc586e597
135 changes: 135 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/

# Sphinx documentation
docs/_build/

# PyBuilder
.pybuilder/
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# poetry
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
#poetry.lock

# pdm
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
#pdm.lock
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
# in version control.
# https://pdm.fming.dev/latest/usage/project/#working-with-version-control
.pdm.toml
.pdm-python
.pdm-build/

# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

# pytype static type analyzer
.pytype/

# Cython debug symbols
cython_debug/

0 comments on commit 09cf630

Please sign in to comment.