Skip to content

Commit 850d9e2

Browse files
committed
CI reorg
1 parent 5202f65 commit 850d9e2

File tree

11 files changed

+888
-679
lines changed

11 files changed

+888
-679
lines changed

.github/workflows/build-deploy.yml

Lines changed: 0 additions & 195 deletions
This file was deleted.

.github/workflows/build-docker.yml

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
# Builds and publishes multi-platform Docker images after Python Build completes successfully.
2+
# Pushes to Docker Hub on version tags (v*) or dev branch.
3+
name: Build and Deploy Docker Image
4+
5+
on:
6+
workflow_run:
7+
workflows: ["Python CI"]
8+
branches: ['**']
9+
types:
10+
- completed
11+
12+
# Cancel a currently running workflow from the same PR, branch or tag when a new workflow is triggered:
13+
concurrency:
14+
group: docker-${{ github.workflow }}-${{ github.event_name }}-${{ github.event.workflow_run.id || github.ref }}
15+
cancel-in-progress: true
16+
17+
env:
18+
# github.repository as <account>/<repo>
19+
IMAGE_NAME: acockburn/appdaemon
20+
21+
jobs:
22+
# After building the Python package, build the Docker image
23+
build_image:
24+
name: Docker image
25+
runs-on: ubuntu-latest
26+
# Only run if tests passed and it's dev branch or a version tag
27+
if: |
28+
github.event.workflow_run.conclusion == 'success' &&
29+
(
30+
github.event.workflow_run.head_branch == 'dev' ||
31+
startsWith(github.event.workflow_run.head_branch, 'v')
32+
)
33+
permissions:
34+
contents: read
35+
packages: write
36+
37+
steps:
38+
- name: Checkout repository
39+
uses: actions/checkout@v6
40+
- name: Download Python package
41+
uses: actions/download-artifact@v7
42+
with:
43+
name: python-package
44+
path: dist/
45+
run-id: ${{ github.event.workflow_run.id }}
46+
github-token: ${{ secrets.GITHUB_TOKEN }}
47+
- name: Setup Docker buildx
48+
uses: docker/setup-buildx-action@v3.12.0
49+
# Login against a Docker registry (only with a tag or push on `dev` branch)
50+
# https://github.com/docker/login-action
51+
- name: Log into Docker Hub
52+
uses: docker/login-action@v3.6.0
53+
with:
54+
username: ${{ secrets.DOCKERHUB_USERNAME }}
55+
password: ${{ secrets.DOCKERHUB_PASSWORD }}
56+
# Extract metadata (tags, labels) for Docker
57+
# https://github.com/docker/metadata-action
58+
- name: Extract Docker metadata
59+
id: meta
60+
uses: docker/metadata-action@v5.10.0
61+
with:
62+
images: ${{ env.IMAGE_NAME }}
63+
# Customize the generation of Docker `latest` tag
64+
# Tag with `latest` the git tags that do not have a "pre-release" component in the end (e.g. `3.0.0`)
65+
# Avoid tagging with `latest` the git tag that have a "pre-release" component in the end (e.g. `3.0.0b1`)
66+
# If no git tag, fallback to branch or PR name
67+
tags: |
68+
# If the git tag follows PEP440 conventions, use it as the resulting docker tag (both releases and pre-releases)
69+
type=pep440,pattern={{version}}
70+
71+
# If the git tag does NOT have a pre-release ending (e.g. `3.0.0`), it is a release version to be tagged as `latest`
72+
type=match,value=latest,pattern=pattern=^\d\.\d+\.\d+$
73+
74+
# If no git tag is used, fallback to tagging with branch or PR name
75+
type=ref,event=branch
76+
type=ref,event=pr
77+
78+
# Build and push Docker image with Buildx (push image only with a tag or push on `dev` branch)
79+
# https://github.com/docker/build-push-action
80+
- name: Build and push Docker image
81+
id: build-and-push
82+
uses: docker/build-push-action@v6.18.0
83+
with:
84+
context: .
85+
file: Dockerfile
86+
push: true
87+
tags: ${{ steps.meta.outputs.tags }}
88+
labels: ${{ steps.meta.outputs.labels }}
89+
platforms: linux/arm64/v8, linux/amd64, linux/arm/v7, linux/arm/v6
90+
cache-from: type=gha
91+
cache-to: type=gha,mode=max

.github/workflows/build-docs.yml

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
# Builds Sphinx documentation after Python Build completes successfully.
2+
# Uploads documentation artifact for review or deployment.
3+
name: Build Documentation
4+
5+
on:
6+
workflow_run:
7+
workflows: ["Python CI"]
8+
types:
9+
- completed
10+
push:
11+
branches:
12+
- 'dev'
13+
tags:
14+
- '**'
15+
paths:
16+
- '.github/workflows/build-docs.yml'
17+
- 'docs/**'
18+
- 'pyproject.toml'
19+
20+
# Cancel a currently running workflow from the same PR, branch or tag when a new workflow is triggered:
21+
concurrency:
22+
group: ${{ github.workflow }}-${{ github.event.workflow_run.head_sha || github.sha }}
23+
cancel-in-progress: true
24+
25+
jobs:
26+
build_docs:
27+
name: Documentation
28+
runs-on: ubuntu-latest
29+
# For workflow_run: only run if tests passed and it's dev or a version tag
30+
# For push: always run
31+
if: |
32+
github.event_name == 'push' || (
33+
github.event.workflow_run.conclusion == 'success' &&
34+
(
35+
github.event.workflow_run.head_branch == 'dev' ||
36+
startsWith(github.event.workflow_run.head_branch, 'v')
37+
)
38+
)
39+
permissions:
40+
packages: write
41+
env:
42+
UV_LOCKED: true
43+
UV_COMPILE_BYTECODE: true
44+
UV_NO_EDITABLE: true
45+
UV_NO_PROGRESS: true
46+
steps:
47+
- name: Checkout repository
48+
uses: actions/checkout@v6
49+
# https://github.com/actions/setup-python
50+
- name: Install uv and set the python version
51+
id: setup-uv
52+
uses: astral-sh/setup-uv@v7
53+
with:
54+
# https://docs.astral.sh/uv/guides/integration/github/#using-uv-in-github-actions
55+
# It is considered best practice to pin to a specific uv version
56+
version: "0.9.26"
57+
# https://github.com/astral-sh/setup-uv?tab=readme-ov-file#enable-caching
58+
enable-cache: true
59+
cache-dependency-glob: uv.lock
60+
- name: Build documentation
61+
# Options:
62+
# -T Display the full traceback when an unhandled exception occurs
63+
# -E Don't use a saved environment (the structure caching all cross-references), but rebuild it completely.
64+
# -b Select the builder
65+
# -d Select a different cache directory
66+
# -D Override a configuration value set in the conf.py file
67+
# -W Turn warnings into errors. This means that the build stops at the first warning and sphinx-build exits with exit status 1
68+
# --keep-going With -W option, keep going processing when getting warnings to the end of build, and sphinx-build exits with exit status 1.
69+
run: >
70+
uv run
71+
--group doc
72+
python -m sphinx
73+
-T -E
74+
-b html
75+
-d _build/doctrees
76+
-D language=en
77+
-W --keep-going
78+
. _build/html
79+
working-directory: docs
80+
# Save the generated documentation as an artifact in Github
81+
- name: Upload documentation
82+
uses: actions/upload-artifact@v6
83+
with:
84+
name: python-doc-package
85+
path: docs/_build/

0 commit comments

Comments
 (0)