@@ -6,10 +6,13 @@ name: Build and deploy
66
77on :
88 push :
9- branches : ["dev"]
109 tags : ["*"]
11- pull_request :
10+ workflow_run :
11+ workflows : ["Python lint and tests"]
1212 branches : ["dev"]
13+ types :
14+ - completed
15+ - requested
1316
1417# Cancel a currently running workflow from the same PR, branch or tag when a new workflow is triggered:
1518# Taken from https://stackoverflow.com/a/72408109
@@ -25,24 +28,31 @@ jobs:
2528 build_docs :
2629 name : Documentation
2730 runs-on : ubuntu-latest
31+ # Only run if tests passed or if triggered by push/PR (not workflow_run)
32+ if : |
33+ github.event_name != 'workflow_run' ||
34+ github.event.workflow_run.conclusion == 'success'
2835 permissions :
2936 packages : write
37+ env :
38+ UV_LOCKED : true
39+ UV_COMPILE_BYTECODE : true
40+ UV_NO_EDITABLE : true
41+ UV_NO_PROGRESS : true
3042 steps :
3143 - name : Checkout repository
3244 uses : actions/checkout@v6
3345 # https://github.com/actions/setup-python
34- - name : Set up Python
35- uses : actions/setup-python@v6
46+ - name : Install uv and set the python version
47+ id : setup-uv
48+ uses : astral-sh/setup-uv@v7
3649 with :
37- python-version : " 3.12"
38- cache : ' pip' # caching pip dependencies
39- # Manually set 'doc-requirements.txt' as the file to use for dependencies, since `requirements.txt` contains runtime dependencies.
40- cache-dependency-path : ' doc-requirements.txt'
41- - name : Install dependencies
42- run : |
43- python -m pip install --upgrade pip
44- pip install -r doc-requirements.txt
45- # Invoke sphinx to build the documentation
50+ # https://docs.astral.sh/uv/guides/integration/github/#using-uv-in-github-actions
51+ # It is considered best practice to pin to a specific uv version
52+ version : " 0.9.26"
53+ # https://github.com/astral-sh/setup-uv?tab=readme-ov-file#enable-caching
54+ enable-cache : true
55+ cache-dependency-glob : uv.lock
4656 - name : Build documentation
4757 # Options:
4858 # -T Display the full traceback when an unhandled exception occurs
5262 # -D Override a configuration value set in the conf.py file
5363 # -W Turn warnings into errors. This means that the build stops at the first warning and sphinx-build exits with exit status 1
5464 # --keep-going With -W option, keep going processing when getting warnings to the end of build, and sphinx-build exits with exit status 1.
55- run : python -m sphinx -T -E -b html -d _build/doctrees -D language=en -W --keep-going . _build/html
65+ run : >
66+ uv run
67+ --group doc
68+ python -m sphinx
69+ -T -E
70+ -b html
71+ -d _build/doctrees
72+ -D language=en
73+ -W --keep-going
74+ . _build/html
5675 working-directory : docs
5776 # Save the generated documentation as an artifact in Github
5877 - name : Upload documentation
@@ -65,27 +84,36 @@ jobs:
6584 build_package :
6685 name : Python package
6786 runs-on : ubuntu-latest
87+ # Only run if tests passed or if triggered by push/PR (not workflow_run)
88+ if : |
89+ github.event_name != 'workflow_run' ||
90+ github.event.workflow_run.conclusion == 'success'
6891 permissions :
6992 contents : read
7093 packages : write
71-
94+ env :
95+ UV_LOCKED : true
96+ UV_COMPILE_BYTECODE : true
97+ UV_NO_EDITABLE : true
98+ UV_NO_PROGRESS : true
99+ UV_NO_SYNC : true
72100 steps :
73101 - name : Checkout repository
74102 uses : actions/checkout@v6
75- # https://github.com/actions/setup- python
76- - name : Set up Python
77- uses : actions /setup-python@v6
103+ - name : Install uv and set the python version
104+ id : setup-uv
105+ uses : astral-sh /setup-uv@v7
78106 with :
79- python-version : " 3.12 "
80- cache : ' pip ' # caching pip dependencies
81- # Manually set 'dev-requirements.txt' as the file to use for dependencies, since `requirements.txt` contains runtime dependencies.
82- cache-dependency-path : ' dev-requirements.txt '
83- - name : Install dependencies
84- run : |
85- python -m pip install --upgrade pip
86- pip install -r dev-requirements.txt
107+ # https://docs.astral.sh/uv/guides/integration/github/#using-uv-in-github-actions
108+ # It is considered best practice to pin to a specific uv version
109+ version : " 0.9.26 "
110+ # https://github.com/astral-sh/setup-uv?tab=readme-ov-file#enable-caching
111+ enable-cache : true
112+ cache-dependency-glob : uv.lock
113+ - name : Install the project
114+ run : uv sync --dev
87115 - name : Build Python package
88- run : python -m build
116+ run : uv build --wheel --refresh
89117 - name : Upload Python package
90118 uses : actions/upload-artifact@v6
91119 with :
@@ -103,6 +131,10 @@ jobs:
103131 name : Docker image
104132 runs-on : ubuntu-latest
105133 needs : ['build_package']
134+ # Only run if tests passed or if triggered by push/PR (not workflow_run)
135+ if : |
136+ github.event_name != 'workflow_run' ||
137+ github.event.workflow_run.conclusion == 'success'
106138 permissions :
107139 contents : read
108140 packages : write
@@ -154,6 +186,7 @@ jobs:
154186 uses : docker/build-push-action@v6.18.0
155187 with :
156188 context : .
189+ file : Dockerfile
157190 push : ${{github.event_name == 'push' && (startsWith(github.ref, 'refs/tags') || github.ref_name == 'dev') && github.repository == 'AppDaemon/appdaemon'}}
158191 tags : ${{ steps.meta.outputs.tags }}
159192 labels : ${{ steps.meta.outputs.labels }}
0 commit comments