From e3af7eb8c9b787bb5f435a01309779e37fc5cb84 Mon Sep 17 00:00:00 2001 From: Charles Lowell Date: Tue, 26 Nov 2024 12:49:24 -0600 Subject: [PATCH] =?UTF-8?q?=F0=9F=91=B7Exclude=20jobs=20from=20non=20exist?= =?UTF-8?q?ent=20matrix?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/publish.yaml | 3 +++ www/tasks/publish-matrix.ts | 8 ++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml index eb17405..b2ae34a 100644 --- a/.github/workflows/publish.yaml +++ b/.github/workflows/publish.yaml @@ -22,6 +22,7 @@ jobs: id: set-matrix jsr: + if: matrix.exists name: Publish ${{ matrix.name }}@${{matrix.version}} to JSR runs-on: ubuntu-latest @@ -43,6 +44,7 @@ jobs: - run: deno publish working-directory: ${{ matrix.workspace }} npm: + if: matrix.exists name: Publish ${{ matrix.name }}@${{matrix.version}} to NPM runs-on: ubuntu-latest @@ -73,6 +75,7 @@ jobs: NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} tag: + if: matrix.exists name: "Tag Release" runs-on: ubuntu-latest needs: [generate-matrix, jsr, npm] diff --git a/www/tasks/publish-matrix.ts b/www/tasks/publish-matrix.ts index 64fcdf7..b0af6c3 100644 --- a/www/tasks/publish-matrix.ts +++ b/www/tasks/publish-matrix.ts @@ -29,6 +29,7 @@ await main(function* () { // ergo we publish if (output.join("").trim() === "") { include.push({ + exists: true, workspace: pkgmeta.workspace, tagname, name: pkg.name, @@ -37,9 +38,12 @@ await main(function* () { } } - let matrix = JSON.stringify(include.length > 0 ? { include } : {}); + // we must have a valid matrix, but don't always do anything + if (include.length === 0) { + include.push({ exists: true }); + } - let outputValue = `matrix=${matrix}`; + let outputValue = `matrix=${JSON.stringify({ include })}`; if (Deno.env.has("GITHUB_OUTPUT")) { const githubOutput = Deno.env.get("GITHUB_OUTPUT") as string;