@@ -201,62 +201,39 @@ jobs:
201201 publish-docker :
202202 name : Publish Docker Image
203203 runs-on : ubuntu-latest
204- needs : [release] # Depend on 'release' job to ensure artifacts are uploaded and version is stable
204+ needs : [release]
205+
205206 steps :
206207 - name : Checkout repository
207208 uses : actions/checkout@v4
208209 with :
209- fetch-depth : 0 # Required for setuptools-scm to determine the version
210-
211- - name : Setup Python
212- uses : actions/setup-python@v5
213- with :
214- python-version : ' 3.x' # Use a recent Python version
215-
216- - name : Install setuptools-scm
217- run : pip install setuptools-scm
210+ fetch-depth : 0
218211
219- - name : Generate _version.py
220- run : |
221- python -c "import setuptools_scm; \
222- import os; \
223- # Get the version from setuptools_scm, using the current directory as root \
224- # fallback_version is used if setuptools_scm cannot determine the version (e.g., no .git) \
225- version = setuptools_scm.get_version(root='.', fallback_version='0.0.0+unknown'); \
226- # Ensure the version string is clean for Python (remove leading 'v' if present) \
227- if version.startswith('v'): version = version[1:]; \
228- # Write the version to _version.py \
229- with open('_version.py', 'w') as f: f.write(f\"__version__ = '{version}'\\n\"); \
230- print(f\"Generated _version.py with __version__ = '{version}'\")"
231-
232- - name : Get version from _version.py
233- id : get_version
212+ - name : Extract version from tag
213+ id : version
234214 run : |
235- # Read the __version__ variable from the generated _version.py
236- # Add current directory to PYTHONPATH to allow importing _version.py
237- VERSION=$(PYTHONPATH=. python -c "import _version; print(_version.__version__)")
238- # Remove leading 'v' if present (e.g., v1.0.0 -> 1.0.0)
239- VERSION="${VERSION#v}"
240- # Extract major version (e.g., 1.0.0 -> 1)
241- MAJOR_VERSION=$(echo "$VERSION" | cut -d. -f1)
215+ RAW="${GITHUB_REF_NAME}"
216+ VERSION="${RAW#v}"
217+ MAJOR="${VERSION%%.*}"
242218 echo "VERSION=$VERSION" >> $GITHUB_ENV
243- echo "MAJOR_VERSION=$MAJOR_VERSION " >> $GITHUB_ENV
244- echo "Extracted VERSION: $VERSION"
245- echo "Extracted MAJOR_VERSION: $MAJOR_VERSION "
219+ echo "MAJOR_VERSION=$MAJOR " >> $GITHUB_ENV
220+ echo "Version = $VERSION"
221+ echo "Major = $MAJOR "
246222
247223 - name : Log in to Docker Hub
248224 uses : docker/login-action@v3
249225 with :
250226 username : ${{ secrets.DOCKER_USERNAME }}
251227 password : ${{ secrets.DOCKER_PASSWORD }}
252228
253- # --- Build and push FULL image (with WhisperX) ---
254229 - name : Build and push FULL Docker image
255230 uses : docker/build-push-action@v5
256231 with :
257232 context : .
258233 push : true
259- target : with_whisperx # Assuming this is the target for the full version
234+ target : with_whisperx
235+ build-args : |
236+ VERSION=${{ env.VERSION }}
260237 tags : |
261238 gandulf78/podcast_generator:${{ env.VERSION }}
262239 gandulf78/podcast_generator:${{ env.MAJOR_VERSION }}
@@ -265,13 +242,14 @@ jobs:
265242 org.opencontainers.image.source=${{ github.event.repository.html_url }}
266243 org.opencontainers.image.version=${{ env.VERSION }}
267244
268- # --- Build and push LIGHT image (without WhisperX) ---
269245 - name : Build and push LIGHT Docker image
270246 uses : docker/build-push-action@v5
271247 with :
272248 context : .
273249 push : true
274- target : without_whisperx # Assuming this is the target for the light version
250+ target : without_whisperx
251+ build-args : |
252+ VERSION=${{ env.VERSION }}
275253 tags : |
276254 gandulf78/podcast_generator:${{ env.VERSION }}-light
277255 gandulf78/podcast_generator:${{ env.MAJOR_VERSION }}-light
0 commit comments