Skip to content

Commit

Permalink
👷Exclude jobs from non existent matrix
Browse files Browse the repository at this point in the history
  • Loading branch information
cowboyd committed Nov 26, 2024
1 parent 39d0b5c commit e3af7eb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ jobs:
id: set-matrix

jsr:
if: matrix.exists
name: Publish ${{ matrix.name }}@${{matrix.version}} to JSR
runs-on: ubuntu-latest

Expand All @@ -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

Expand Down Expand Up @@ -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]
Expand Down
8 changes: 6 additions & 2 deletions www/tasks/publish-matrix.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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;
Expand Down

0 comments on commit e3af7eb

Please sign in to comment.