1313env :
1414 FORCE_JAVASCRIPT_ACTIONS_TO_NODE24 : true
1515
16+ concurrency :
17+ group : ${{ github.workflow }}-${{ github.ref }}
18+ cancel-in-progress : true
19+
1620jobs :
1721 # ─────────────────────────────────────────────────────────────────────────────
1822 # TEST BUILD (develop only) — Verify code compiles and tests pass
6367 runs-on : ubuntu-latest
6468 permissions :
6569 contents : read
70+ env :
71+ ELECTRON_CACHE : ${{ github.workspace }}/.electron-cache
6672 steps :
6773 - uses : actions/checkout@v6
6874 - uses : actions/setup-python@v6
@@ -97,35 +103,46 @@ jobs:
97103 cd frontend
98104 npm ci
99105 npm run build
106+ - name : Cache Electron download
107+ uses : actions/cache@v4
108+ with :
109+ path : ${{ env.ELECTRON_CACHE }}
110+ key : electron-${{ runner.os }}-${{ hashFiles('electron/package-lock.json') }}
100111 - name : Test electron setup
101112 run : |
102113 cd electron
103114 npm ci --include=dev
104115
105116 # ─────────────────────────────────────────────────────────────────────────────
106- # RELEASE BUILD (main only) — Create and publish stable release
117+ # BETA RELEASE (develop only) — Package and publish a prerelease build
107118 # ─────────────────────────────────────────────────────────────────────────────
108- get-version :
109- if : github.ref == 'refs/heads/main'
119+ get-version-beta :
120+ if : github.ref == 'refs/heads/develop'
121+ needs : [test-python, test-frontend, test-electron]
110122 runs-on : ubuntu-latest
111123 permissions :
112124 contents : read
113125 outputs :
114- version : ${{ steps.ver.outputs.version }}
126+ base_version : ${{ steps.ver.outputs.base_version }}
127+ beta_version : ${{ steps.ver.outputs.beta_version }}
115128 steps :
116129 - uses : actions/checkout@v6
117130 - id : ver
118131 run : |
119- VERSION=$(grep -oP 'VERSION\s*=\s*"\K[^"]+' python/config.py)
120- echo "version=$VERSION" >> "$GITHUB_OUTPUT"
121- echo "Building MetaLens v$VERSION"
132+ BASE=$(grep -oP 'VERSION\s*=\s*"\K[^"]+' python/config.py)
133+ BETA="${BASE}-beta.${{ github.run_number }}"
134+ echo "base_version=$BASE" >> "$GITHUB_OUTPUT"
135+ echo "beta_version=$BETA" >> "$GITHUB_OUTPUT"
136+ echo "Building MetaLens beta v$BETA"
122137
123- build-windows :
124- if : github.ref == 'refs/heads/main '
125- needs : get-version
138+ build-windows-beta :
139+ if : github.ref == 'refs/heads/develop '
140+ needs : get-version-beta
126141 runs-on : windows-latest
127142 permissions :
128143 contents : read
144+ env :
145+ ELECTRON_CACHE : ${{ github.workspace }}/.electron-cache
129146 steps :
130147 - uses : actions/checkout@v6
131148 - uses : actions/setup-python@v6
@@ -160,28 +177,35 @@ jobs:
160177 npm run build
161178 - name : Copy frontend dist into electron
162179 run : cp -r frontend/dist electron/frontend
163- - name : Sync electron version
180+ - name : Sync electron version to beta
164181 run : |
165182 cd electron
166- npm version ${{ needs.get-version.outputs.version }} --no-git-tag-version --allow-same-version
183+ npm version ${{ needs.get-version-beta.outputs.beta_version }} --no-git-tag-version --allow-same-version
184+ - name : Cache Electron download
185+ uses : actions/cache@v4
186+ with :
187+ path : ${{ env.ELECTRON_CACHE }}
188+ key : electron-${{ runner.os }}-${{ hashFiles('electron/package-lock.json') }}
167189 - name : Package with Electron Forge
168190 run : |
169191 cd electron
170192 npm ci --include=dev
171193 npx electron-forge make
172- - name : Upload Windows artifact
194+ - name : Upload Windows beta artifact
173195 uses : actions/upload-artifact@v7
174196 with :
175- name : windows-installer
197+ name : windows-installer-beta
176198 path : electron/out/make/**/*.exe
177199 if-no-files-found : error
178200
179- build-linux :
180- if : github.ref == 'refs/heads/main '
181- needs : get-version
201+ build-linux-beta :
202+ if : github.ref == 'refs/heads/develop '
203+ needs : get-version-beta
182204 runs-on : ubuntu-latest
183205 permissions :
184206 contents : read
207+ env :
208+ ELECTRON_CACHE : ${{ github.workspace }}/.electron-cache
185209 steps :
186210 - uses : actions/checkout@v6
187211 - name : Install system dependencies
@@ -217,20 +241,25 @@ jobs:
217241 npm run build
218242 - name : Copy frontend dist into electron
219243 run : cp -r frontend/dist electron/frontend
220- - name : Sync electron version
244+ - name : Sync electron version to beta
221245 run : |
222246 cd electron
223- npm version ${{ needs.get-version.outputs.version }} --no-git-tag-version --allow-same-version
247+ npm version ${{ needs.get-version-beta .outputs.beta_version }} --no-git-tag-version --allow-same-version
224248 - name : Configure RPM macros
225249 run : echo '%_build_id_links none' >> ~/.rpmmacros
250+ - name : Cache Electron download
251+ uses : actions/cache@v4
252+ with :
253+ path : ${{ env.ELECTRON_CACHE }}
254+ key : electron-${{ runner.os }}-${{ hashFiles('electron/package-lock.json') }}
226255 - name : Package with Electron Forge
227256 run : |
228257 cd electron
229258 npm ci --include=dev
230259 npx electron-forge make
231260 - name : Create Linux tar.gz
232261 run : |
233- VERSION=${{ needs.get-version.outputs.version }}
262+ VERSION=${{ needs.get-version-beta .outputs.beta_version }}
234263 APP_DIR=$(find electron/out -maxdepth 1 -type d -name "MetaLens-linux-*" | head -1)
235264 if [ -n "$APP_DIR" ]; then
236265 tar -czf "electron/out/make/MetaLens-${VERSION}-Linux.tar.gz" \
@@ -239,19 +268,19 @@ jobs:
239268 else
240269 echo "Warning: no MetaLens-linux-* directory found, skipping tar.gz"
241270 fi
242- - name : Upload Linux artifacts
271+ - name : Upload Linux beta artifacts
243272 uses : actions/upload-artifact@v7
244273 with :
245- name : linux-packages
274+ name : linux-packages-beta
246275 path : |
247276 electron/out/make/**/*.deb
248277 electron/out/make/**/*.rpm
249278 electron/out/make/**/*.tar.gz
250279 if-no-files-found : error
251280
252- release :
253- if : github.ref == 'refs/heads/main '
254- needs : [get-version, build-windows, build-linux]
281+ release-beta :
282+ if : github.ref == 'refs/heads/develop '
283+ needs : [get-version-beta , build-windows-beta , build-linux-beta ]
255284 runs-on : ubuntu-latest
256285 permissions :
257286 contents : write
@@ -261,7 +290,86 @@ jobs:
261290 path : artifacts
262291 - name : List artifacts
263292 run : find artifacts -type f
264- - name : Create GitHub Release
293+ - name : Create beta GitHub Release
294+ uses : softprops/action-gh-release@v3
295+ with :
296+ tag_name : v${{ needs.get-version-beta.outputs.beta_version }}
297+ name : MetaLens v${{ needs.get-version-beta.outputs.beta_version }} (beta)
298+ draft : false
299+ prerelease : true
300+ generate_release_notes : true
301+ make_latest : false
302+ files : |
303+ artifacts/windows-installer-beta/**
304+ artifacts/linux-packages-beta/**
305+
306+ # ─────────────────────────────────────────────────────────────────────────────
307+ # STABLE RELEASE (main only) — Promote the matching beta build, no rebuild
308+ # ─────────────────────────────────────────────────────────────────────────────
309+ get-version :
310+ if : github.ref == 'refs/heads/main'
311+ runs-on : ubuntu-latest
312+ permissions :
313+ contents : read
314+ outputs :
315+ version : ${{ steps.ver.outputs.version }}
316+ steps :
317+ - uses : actions/checkout@v6
318+ - id : ver
319+ run : |
320+ VERSION=$(grep -oP 'VERSION\s*=\s*"\K[^"]+' python/config.py)
321+ echo "version=$VERSION" >> "$GITHUB_OUTPUT"
322+ echo "Building MetaLens v$VERSION"
323+
324+ find-latest-beta :
325+ if : github.ref == 'refs/heads/main'
326+ needs : get-version
327+ runs-on : ubuntu-latest
328+ permissions :
329+ contents : read
330+ outputs :
331+ beta_tag : ${{ steps.find.outputs.beta_tag }}
332+ steps :
333+ - id : find
334+ env :
335+ GH_TOKEN : ${{ github.token }}
336+ VERSION : ${{ needs.get-version.outputs.version }}
337+ run : |
338+ TAG=$(gh release list --repo "$GITHUB_REPOSITORY" --limit 200 --json tagName \
339+ --jq '.[].tagName' \
340+ | grep -E "^v${VERSION}-beta\.[0-9]+$" \
341+ | sort -t. -k4 -n \
342+ | tail -1)
343+ if [ -z "$TAG" ]; then
344+ echo "::error::Nessuna release beta trovata per v${VERSION}. Genera prima una beta da develop con la stessa VERSION in python/config.py."
345+ exit 1
346+ fi
347+ echo "beta_tag=$TAG" >> "$GITHUB_OUTPUT"
348+ echo "Promuovendo $TAG a stable v${VERSION}"
349+
350+ promote-stable :
351+ if : github.ref == 'refs/heads/main'
352+ needs : [get-version, find-latest-beta]
353+ runs-on : ubuntu-latest
354+ permissions :
355+ contents : write
356+ steps :
357+ - name : Download beta release assets
358+ env :
359+ GH_TOKEN : ${{ github.token }}
360+ run : |
361+ mkdir -p promoted
362+ gh release download "${{ needs.find-latest-beta.outputs.beta_tag }}" \
363+ --repo "$GITHUB_REPOSITORY" --dir promoted
364+ - name : Strip beta suffix from filenames
365+ run : |
366+ cd promoted
367+ for f in *; do
368+ new=$(echo "$f" | sed -E 's/-beta\.[0-9]+//')
369+ if [ "$f" != "$new" ]; then mv -- "$f" "$new"; fi
370+ done
371+ ls -la
372+ - name : Create stable GitHub Release
265373 uses : softprops/action-gh-release@v3
266374 with :
267375 tag_name : v${{ needs.get-version.outputs.version }}
@@ -270,6 +378,4 @@ jobs:
270378 prerelease : false
271379 generate_release_notes : true
272380 make_latest : true
273- files : |
274- artifacts/windows-installer/**
275- artifacts/linux-packages/**
381+ files : promoted/*
0 commit comments