From 4f85958f2674d0ec4948557680577fb2a92adda2 Mon Sep 17 00:00:00 2001 From: Just Call Me Koko Date: Wed, 4 Feb 2026 10:08:29 -0500 Subject: [PATCH] Fix nightly build release condition --- .github/workflows/nightly_build.yml | 50 ++++++++++++++++++----------- 1 file changed, 32 insertions(+), 18 deletions(-) diff --git a/.github/workflows/nightly_build.yml b/.github/workflows/nightly_build.yml index d3d52d649..e478913ee 100644 --- a/.github/workflows/nightly_build.yml +++ b/.github/workflows/nightly_build.yml @@ -26,31 +26,43 @@ jobs: const owner = context.repo.owner; const repo = context.repo.repo; - // Find default branch and its HEAD + // Get default branch info const repoInfo = await github.rest.repos.get({ owner, repo }); const defaultBranch = repoInfo.data.default_branch; - const head = await github.rest.repos.getBranch({ owner, repo, branch: defaultBranch }); + + const head = await github.rest.repos.getBranch({ + owner, + repo, + branch: defaultBranch + }); + const headSha = head.data.commit.sha; - const shortSha = headSha.slice(0,7); + const shortSha = headSha.slice(0, 7); - // Try get the existing nightly release (single static tag) - let nightlyRelease = null; - try { - nightlyRelease = await github.rest.repos.getReleaseByTag({ - owner, repo, tag: 'nightly' - }); - } catch (e) { - if (e.status !== 404) throw e; + // List releases and find the most recent "_nightly" + const releases = await github.rest.repos.listReleases({ + owner, + repo, + per_page: 50 + }); + + let latestNightlySha = null; + + for (const rel of releases.data) { + const name = rel.name || ""; + + const match = name.match(/^([0-9a-f]{7})_nightly$/i); + if (match) { + latestNightlySha = match[1]; + break; // releases are returned newest-first + } } - // Decide if we need to rebuild: compare short SHA in the release name - // Name format we set: "_nightly" let shouldBuild = true; - if (nightlyRelease) { - const name = nightlyRelease.data.name || ''; - const m = name.match(/^([0-9a-f]{7})_nightly$/i); - if (m && m[1] === shortSha) { - shouldBuild = false; // no new commits since last nightly + + if (latestNightlySha) { + if (latestNightlySha === shortSha) { + shouldBuild = false; } } @@ -62,6 +74,8 @@ jobs: compile_sketch: name: build ${{ matrix.board.name }} runs-on: ubuntu-latest + needs: decide + if: ${{ needs.decide.outputs.should_build == 'true' }} strategy: fail-fast: false matrix: