Skip to content

feat(ci): switch to npm trusted publishing with nightly support - #11986

Merged
michaelbromley merged 8 commits into
masterfrom
feat/trusted-publishing
Feb 17, 2026
Merged

michaelbromley merged 8 commits into
masterfrom
feat/trusted-publishing

Conversation

@michaelbromley

@michaelbromley michaelbromley commented Feb 13, 2026 •

Copy link
Copy Markdown
Member

Summary

  • Replace long-lived NPM_TOKEN secret with OIDC-based Trusted Publishing
  • Add nightly publishing for both master and v0.3 branches via cron (02:00 UTC daily), with 24h commit check to skip when nothing changed
  • Add manual workflow_dispatch trigger with choice of release, master-nightly, or v0.3-nightly
  • Use matrix strategy so scheduled nightlies for both branches run in parallel
  • Add concurrency control to prevent racing publishes
  • Strip dev-only fields (scripts, devDependencies, devEngines) from built package.json to fix publish lifecycle errors

How it works

Trigger What happens
GitHub Release published Publishes release with latest tag
Cron (02:00 UTC) Runs master-nightly + v0.3-nightly in parallel, skips if no commits in 24h
Manual: master-nightly Checks out master, publishes as typeorm@master
Manual: v0.3-nightly Checks out v0.3, publishes as [email protected]

Nightly versioning

  • master branch (1.0.0-pre) → 1.0.0-nightly.20260213 (replaces prerelease suffix)
  • v0.3 branch (0.3.20) → 0.3.21-nightly.20260213 (bumps patch, adds nightly suffix)

Install via: npm install typeorm@master or npm install [email protected]

Required setup

Before merging:

  1. npmjs.com: Add a trusted publisher at https://www.npmjs.com/package/typeorm/access
    • Repository: typeorm/typeorm
    • Workflow: publish-package.yml
    • Environment: npm
  2. GitHub: Create an npm environment in repo settings (Settings > Environments)

After verifying a successful publish, the NPM_TOKEN secret can be removed.

Test plan

  • Configure trusted publisher on npmjs.com
  • Create npm GitHub environment
  • Test master nightly via workflow_dispatch — published 1.0.1-nightly.20260213 successfully
  • Test v0.3 nightly via workflow_dispatch — correctly skipped (no commits in 24h on v0.3)
  • Trigger a release and verify the package publishes successfully
  • Remove NPM_TOKEN secret after confirming OIDC works
  • Remove feat/trusted-publishing from npm environment allowed branches

@qodo-free-for-open-source-projects

Copy link
Copy Markdown

User description

Summary

  • Replace long-lived NPM_TOKEN secret with OIDC-based Trusted Publishing
  • Add nightly publishing via cron (02:00 UTC) with 24h commit check, plus manual dispatch
  • Split into two jobs: lightweight determine job gates the publish job so id-token: write and the npm environment are only activated when actually publishing
  • Add concurrency control to prevent racing publishes
  • Harden shell scripts against injection by using env vars instead of direct ${{ }} interpolation

Required setup

Before merging:

  1. npmjs.com: Add a trusted publisher at https://www.npmjs.com/package/typeorm/access
    • Repository: typeorm/typeorm
    • Workflow: publish-package.yml
    • Environment: npm
  2. GitHub: Create an npm environment in repo settings (Settings > Environments)

After verifying a successful publish, the NPM_TOKEN secret can be removed.

Test plan

  • Configure trusted publisher on npmjs.com
  • Trigger a release and verify the package publishes successfully
  • Trigger a manual nightly via workflow_dispatch and verify the nightly version publishes with the nightly dist-tag
  • Remove NPM_TOKEN secret after confirming OIDC works

PR Type

Enhancement


Description

  • Replace NPM_TOKEN secret with OIDC-based Trusted Publishing

  • Add nightly publishing via cron schedule with 24h commit check

  • Split workflow into determine and publish jobs for security

  • Add manual dispatch option for nightly publishes

  • Harden shell scripts using environment variables instead of direct interpolation


Diagram Walkthrough

flowchart LR
  A["GitHub Events<br/>release/schedule/dispatch"] --> B["Determine Job<br/>Check publish conditions"]
  B --> C{{"Should Publish?"}}
  C -->|"true"| D["Publish Job<br/>OIDC auth"]
  D --> E["npm publish<br/>release or nightly"]
  C -->|"false"| F["Skip publish"]
Loading

File Walkthrough

Relevant files
Enhancement
publish-package.yml
Implement OIDC Trusted Publishing with nightly support     

.github/workflows/publish-package.yml

  • Replaced NPM_TOKEN secret authentication with OIDC-based Trusted
    Publishing
  • Added nightly publishing via cron schedule (02:00 UTC) with 24-hour
    commit check
  • Split workflow into lightweight determine job and publish job for
    security isolation
  • Added workflow_dispatch input to manually trigger nightly publishes
  • Implemented concurrency control to prevent racing publishes
  • Updated Node.js version from 20 to 22
  • Removed registry-url configuration to allow OIDC automatic
    authentication
  • Added conditional steps for release vs nightly publishing with version
    bumping
  • Hardened shell scripts using environment variables instead of direct
    GitHub context interpolation
+82/-5   

@qodo-free-for-open-source-projects

qodo-free-for-open-source-projects Bot commented Feb 13, 2026 •

Copy link
Copy Markdown

PR Code Suggestions ✨

Latest suggestions up to 6cbb065

CategorySuggestion                                                                                                                                    Impact
Possible issue
Fix checkout ref and action

Update the actions/checkout step to use a valid version (v4) and correctly check
out the release tag for release builds using github.event.release.tag_name.

.github/workflows/publish-package.yml [58-61]

-- uses: actions/checkout@v6
+- uses: actions/checkout@v4
   with:
-    ref: ${{ matrix.type == 'v0.3-nightly' && 'v0.3' || matrix.type == 'master-nightly' && 'master' || '' }}
+    ref: ${{ matrix.type == 'release' && github.event.release.tag_name || matrix.type == 'v0.3-nightly' && 'v0.3' || 'master' }}
     fetch-depth: ${{ matrix.type == 'release' && 1 || 0 }}
  • Apply / Chat
Suggestion importance[1-10]: 9

__

Why: The suggestion correctly identifies that actions/checkout@v6 is an invalid version and that the ref for release builds is wrong, which would cause the workflow to publish from the wrong branch. This is a critical correctness fix.

High
Ensure nightly versions are unique

Make nightly version numbers unique by appending the short commit SHA to prevent
publishing failures on reruns within the same day.

.github/workflows/publish-package.yml [117-129]

 - name: Set nightly version
   if: matrix.type != 'release' && steps.commit_check.outputs.should_publish == 'true'
   run: |
     cd build/package
     node -e "
+      const fs = require('fs');
+      const cp = require('child_process');
       const pkg = require('./package.json');
+
       const base = pkg.version.replace(/-.*/, '');
       const [major, minor, patch] = base.split('.').map(Number);
       const hasPrerelease = pkg.version.includes('-');
-      pkg.version = major + '.' + minor + '.' + (hasPrerelease ? patch : patch + 1) + '-nightly.' + new Date().toISOString().slice(0,10).replace(/-/g, '');
-      require('fs').writeFileSync('package.json', JSON.stringify(pkg, null, 2) + '\n');
+
+      const date = new Date().toISOString().slice(0,10).replace(/-/g, '');
+      const sha = cp.execSync('git rev-parse --short HEAD', { encoding: 'utf8' }).trim();
+
+      pkg.version = major + '.' + minor + '.' + (hasPrerelease ? patch : patch + 1) + '-nightly.' + date + '.' + sha;
+
+      fs.writeFileSync('package.json', JSON.stringify(pkg, null, 2) + '\n');
       console.log('Publishing nightly version: ' + pkg.version);
     "
  • Apply / Chat
Suggestion importance[1-10]: 8

__

Why: This suggestion correctly points out that nightly version numbers are not unique for the same day, which would cause publish failures on reruns. Adding the commit SHA makes the workflow more robust and reliable.

Medium
General
Avoid incorrect nightly skips

Modify the "Check for new commits" step to always publish nightly builds when
triggered manually via workflow_dispatch, bypassing the 24-hour commit check.

.github/workflows/publish-package.yml [63-76]

 - name: Check for new commits
   id: commit_check
   if: matrix.type != 'release'
   env:
     MATRIX_TYPE: ${{ matrix.type }}
+    EVENT_NAME: ${{ github.event_name }}
   run: |
+    echo "dist_tag=${MATRIX_TYPE%-nightly}" >> $GITHUB_OUTPUT
+
+    if [ "$EVENT_NAME" = "workflow_dispatch" ]; then
+      echo "should_publish=true" >> $GITHUB_OUTPUT
+      exit 0
+    fi
+
     COMMITS=$(git rev-list --count --since="24 hours" HEAD)
     echo "Commits in last 24h: $COMMITS"
-    echo "dist_tag=${MATRIX_TYPE%-nightly}" >> $GITHUB_OUTPUT
     if [ "$COMMITS" -eq 0 ]; then
       echo "should_publish=false" >> $GITHUB_OUTPUT
     else
       echo "should_publish=true" >> $GITHUB_OUTPUT
     fi
  • Apply / Chat
Suggestion importance[1-10]: 7

__

Why: The suggestion correctly identifies a potential flaw in the "new commits" check and proposes a good improvement to always publish when manually dispatched, making the workflow more robust and user-friendly.

Medium
  • More

Previous suggestions

Suggestions up to commit e47aae6
CategorySuggestion                                                                                                                                    Impact
Possible issue
Use valid action versions

Pin actions/checkout and actions/setup-node to a valid major version like @v4
instead of the non-existent @v6 to prevent workflow failures.

.github/workflows/publish-package.yml [58-88]

-- uses: actions/checkout@v6
+- uses: actions/checkout@v4
   with:
     ref: ${{ matrix.type == 'v0.3-nightly' && 'v0.3' || matrix.type == 'master-nightly' && 'master' || '' }}
     fetch-depth: ${{ matrix.type == 'release' && 1 || 0 }}
 ...
-- uses: actions/setup-node@v6
+- uses: actions/setup-node@v4
   if: matrix.type == 'release' || steps.commit_check.outputs.should_publish == 'true'
   with:
     node-version: 22
     cache: "pnpm"
Suggestion importance[1-10]: 10

__

Why: The suggestion correctly identifies that the workflow uses non-existent major versions for actions/checkout and actions/setup-node, which would cause the entire workflow to fail at runtime.

High
Ensure nightly versions are unique

To prevent publish failures on re-runs, make the nightly version string unique
by appending a component like github.run_number or a commit SHA.

.github/workflows/publish-package.yml [117-129]

 - name: Set nightly version
   if: matrix.type != 'release' && steps.commit_check.outputs.should_publish == 'true'
+  env:
+    GITHUB_RUN_NUMBER: ${{ github.run_number }}
+    GITHUB_SHA: ${{ github.sha }}
   run: |
     cd build/package
     node -e "
       const pkg = require('./package.json');
       const base = pkg.version.replace(/-.*/, '');
       const [major, minor, patch] = base.split('.').map(Number);
       const hasPrerelease = pkg.version.includes('-');
-      pkg.version = major + '.' + minor + '.' + (hasPrerelease ? patch : patch + 1) + '-nightly.' + new Date().toISOString().slice(0,10).replace(/-/g, '');
+      const date = new Date().toISOString().slice(0,10).replace(/-/g, '');
+      const run = process.env.GITHUB_RUN_NUMBER || '0';
+      const sha = (process.env.GITHUB_SHA || '').slice(0,7) || 'unknown';
+      pkg.version = major + '.' + minor + '.' + (hasPrerelease ? patch : patch + 1) + '-nightly.' + date + '.' + run + '.' + sha;
       require('fs').writeFileSync('package.json', JSON.stringify(pkg, null, 2) + '\n');
       console.log('Publishing nightly version: ' + pkg.version);
     "
Suggestion importance[1-10]: 9

__

Why: The suggestion correctly identifies a critical flaw where nightly builds could fail on re-runs due to non-unique version numbers, and the proposed fix effectively ensures version uniqueness.

High
Suggestions up to commit b1765d1
CategorySuggestion                                                                                                                                    Impact
Possible issue
Fix invalid GitHub Action version

Correct the invalid version for actions/checkout from @v6 to @v4 to prevent the
workflow from failing.

.github/workflows/publish-package.yml [58-61]

-- uses: actions/checkout@v6
+- uses: actions/checkout@v4
   with:
     ref: ${{ matrix.type == 'v0.3-nightly' && 'v0.3' || matrix.type == 'master-nightly' && 'master' || '' }}
     fetch-depth: ${{ matrix.type == 'release' && 1 || 0 }}
Suggestion importance[1-10]: 9

__

Why: The suggestion correctly identifies that actions/checkout@v6 is an invalid version, which would cause the workflow to fail. Using the correct version (@v4) is a critical fix.

High
Fix invalid Node setup action

Correct the invalid version for actions/setup-node from @v6 to @v4 to prevent
the workflow from failing.

.github/workflows/publish-package.yml [84-88]

-- uses: actions/setup-node@v6
+- uses: actions/setup-node@v4
   if: matrix.type == 'release' || steps.commit_check.outputs.should_publish == 'true'
   with:
     node-version: 22
     cache: "pnpm"
Suggestion importance[1-10]: 9

__

Why: The suggestion correctly identifies that actions/setup-node@v6 is an invalid version, which would cause the workflow to fail. Using the correct version (@v4) is a critical fix.

High
Ensure nightly versions are unique

Modify the nightly version generation to include the github.run_number, ensuring
version uniqueness and preventing publish failures on workflow reruns.

.github/workflows/publish-package.yml [117-129]

 - name: Set nightly version
   if: matrix.type != 'release' && steps.commit_check.outputs.should_publish == 'true'
+  env:
+    RUN_NUMBER: ${{ github.run_number }}
   run: |
     cd build/package
     node -e "
       const pkg = require('./package.json');
       const base = pkg.version.replace(/-.*/, '');
       const [major, minor, patch] = base.split('.').map(Number);
       const hasPrerelease = pkg.version.includes('-');
-      pkg.version = major + '.' + minor + '.' + (hasPrerelease ? patch : patch + 1) + '-nightly.' + new Date().toISOString().slice(0,10).replace(/-/g, '');
+      const date = new Date().toISOString().slice(0,10).replace(/-/g, '');
+      const run = process.env.RUN_NUMBER || '0';
+      pkg.version = major + '.' + minor + '.' + (hasPrerelease ? patch : patch + 1) + '-nightly.' + date + '.' + run;
       require('fs').writeFileSync('package.json', JSON.stringify(pkg, null, 2) + '\n');
       console.log('Publishing nightly version: ' + pkg.version);
     "
Suggestion importance[1-10]: 8

__

Why: The suggestion correctly identifies a flaw in the nightly versioning scheme that would cause publish failures on reruns within the same day. The proposed fix of including github.run_number makes the version unique and prevents this issue.

Medium
Suggestions up to commit 056adae
CategorySuggestion                                                                                                                                    Impact
Possible issue
Fix invalid action versions

Downgrade actions/checkout and actions/setup-node from the non-existent @v6 to a
valid major version like @v4 to prevent workflow failure.

.github/workflows/publish-package.yml [32-78]

-- uses: actions/checkout@v6
+- uses: actions/checkout@v4
   with:
     fetch-depth: 0
 ...
-- uses: actions/checkout@v6
+- uses: actions/checkout@v4
 ...
-- uses: actions/setup-node@v6
+- uses: actions/setup-node@v4
   with:
     node-version: 22
     cache: "pnpm"
Suggestion importance[1-10]: 10

__

Why: The suggestion correctly identifies that actions/checkout@v6 and actions/setup-node@v6 are non-existent versions, which would cause the entire workflow to fail, making this a critical fix.

High
Ensure nightly versions are unique

Add a uniqueness component like the time or run ID to the nightly version string
to prevent publish failures if the workflow runs more than once per day.

.github/workflows/publish-package.yml [98-109]

 - name: Set nightly version
   if: needs.determine.outputs.type == 'nightly'
   run: |
     cd build/package
     node -e "
       const pkg = require('./package.json');
       const base = pkg.version.replace(/-.*/, '');
       const [major, minor, patch] = base.split('.').map(Number);
-      pkg.version = major + '.' + minor + '.' + (patch + 1) + '-nightly.' + new Date().toISOString().slice(0,10).replace(/-/g, '');
+      const d = new Date();
+      const ymd = d.toISOString().slice(0,10).replace(/-/g, '');
+      const hms = d.toISOString().slice(11,19).replace(/:/g, '');
+      const run = process.env.GITHUB_RUN_NUMBER || process.env.GITHUB_RUN_ID || '0';
+      pkg.version = major + '.' + minor + '.' + (patch + 1) + '-nightly.' + ymd + hms + '.' + run;
       require('fs').writeFileSync('package.json', JSON.stringify(pkg, null, 2) + '\n');
       console.log('Publishing nightly version: ' + pkg.version);
     "
Suggestion importance[1-10]: 9

__

Why: This suggestion correctly identifies a potential bug where multiple nightly builds on the same day would fail due to version conflicts, and provides a robust solution to ensure version uniqueness.

High
General
Avoid blocking releases with nightlies

Update the concurrency group to be dynamic based on the event type to prevent
nightly builds from blocking release builds.

.github/workflows/publish-package.yml [21-23]

 concurrency:
-  group: publish-package
+  group: publish-package-${{ github.event_name }}-${{ github.ref }}
   cancel-in-progress: false
Suggestion importance[1-10]: 7

__

Why: The suggestion correctly points out that a static concurrency group can cause unnecessary blocking between different publish types and proposes a good improvement to allow releases and nightlies to run in parallel.

Medium
✅ Suggestions up to commit 00eafbc
CategorySuggestion                                                                                                                                    Impact
Possible issue
Fix invalid action versions

Downgrade actions/checkout and actions/setup-node to their supported major
versions (v4) to prevent workflow failures.

.github/workflows/publish-package.yml [32-78]

-- uses: actions/checkout@v6
+- uses: actions/checkout@v4
   with:
     fetch-depth: 0
 ...
-- uses: actions/checkout@v6
+- uses: actions/checkout@v4
 ...
-- uses: actions/setup-node@v6
+- uses: actions/setup-node@v4
   with:
     node-version: 22
     cache: "pnpm"
Suggestion importance[1-10]: 10

__

Why: The suggestion correctly identifies that actions/checkout@v6 and actions/setup-node@v6 are non-existent versions, which would cause the workflow to fail. This is a critical fix to make the workflow runnable.

High
Use npm CLI for publishing

Replace pnpm publish with npm publish to ensure reliable support for the
--provenance flag required for npm Trusted Publishing.

.github/workflows/publish-package.yml [97-107]

 - name: Publish (release)
   if: needs.determine.outputs.type == 'release'
   run: |
     cd build/package
-    pnpm publish --provenance --access public
+    npm publish --provenance --access public
 
 - name: Publish (nightly)
   if: needs.determine.outputs.type == 'nightly'
   run: |
     cd build/package
-    pnpm publish --provenance --access public --tag nightly
+    npm publish --provenance --access public --tag nightly
Suggestion importance[1-10]: 7

__

Why: The suggestion correctly points out that --provenance is an npm feature and using npm publish directly is more robust than relying on pnpm to proxy the flag, which could have version-specific compatibility issues. This improves the reliability of the publishing workflow.

Medium
General
✅ Avoid publish failures from git checks
Suggestion Impact:The workflow publish commands were updated to include --no-git-checks, including the nightly publish step (and additionally the release publish step), preventing publish failures due to git checks.

code diff:

@@ -98,11 +98,11 @@
         if: needs.determine.outputs.type == 'release'
         run: |
           cd build/package
-          pnpm publish --provenance --access public
+          pnpm publish --provenance --access public --no-git-checks
 
       - name: Publish (nightly)
         if: needs.determine.outputs.type == 'nightly'
         run: |
           cd build/package
-          pnpm publish --provenance --access public --tag nightly
+          pnpm publish --provenance --access public --no-git-checks --tag nightly

Add the --no-git-checks flag to the nightly pnpm publish command to prevent
failures caused by uncommitted changes to package.json.

.github/workflows/publish-package.yml [103-107]

 - name: Publish (nightly)
   if: needs.determine.outputs.type == 'nightly'
   run: |
     cd build/package
-    pnpm publish --provenance --access public --tag nightly
+    pnpm publish --provenance --access public --tag nightly --no-git-checks
Suggestion importance[1-10]: 8

__

Why: The suggestion correctly identifies that modifying package.json before publishing can cause failures due to git checks for a clean working directory. Adding --no-git-checks prevents potential intermittent publish failures, making the nightly workflow more robust.

Medium
✅ Suggestions up to commit 3cbdb96
CategorySuggestion                                                                                                                                    Impact
General
✅ Use built-in npm prerelease bump
Suggestion Impact:The PR removed the brittle shell-based version parsing/incrementing logic in the nightly publish step, replacing it with a single Node.js snippet that computes and writes the nightly version. It did not adopt the suggested `npm version prerelease --preid nightly` command.

code diff:

@@ -85,12 +85,14 @@
         if: needs.determine.outputs.type == 'nightly'
         run: |
           cd build/package
-          CURRENT_VERSION=$(node -p "require('./package.json').version")
-          BASE_VERSION=$(echo "$CURRENT_VERSION" | sed 's/-.*//')
-          IFS='.' read -r -a V <<< "$BASE_VERSION"
-          NIGHTLY_VERSION="${V[0]}.${V[1]}.$((V[2] + 1))-nightly.$(date +'%Y%m%d')"
-          npm version "$NIGHTLY_VERSION" --no-git-tag-version
-          echo "Publishing nightly version: $NIGHTLY_VERSION"
+          node -e "
+            const pkg = require('./package.json');
+            const base = pkg.version.replace(/-.*/, '');
+            const [major, minor, patch] = base.split('.').map(Number);
+            pkg.version = major + '.' + minor + '.' + (patch + 1) + '-nightly.' + new Date().toISOString().slice(0,10).replace(/-/g, '');
+            require('fs').writeFileSync('package.json', JSON.stringify(pkg, null, 2) + '\n');
+            console.log('Publishing nightly version: ' + pkg.version);
+          "

Replace the custom shell script for versioning with the npm version prerelease
--preid nightly command to simplify and harden the nightly version bumping
logic.

.github/workflows/publish-package.yml [84-93]

 - name: Set nightly version
   if: needs.determine.outputs.type == 'nightly'
   run: |
     cd build/package
-    CURRENT_VERSION=$(node -p "require('./package.json').version")
-    BASE_VERSION=$(echo "$CURRENT_VERSION" | sed 's/-.*//')
-    IFS='.' read -r -a V <<< "$BASE_VERSION"
-    NIGHTLY_VERSION="${V[0]}.${V[1]}.$((V[2] + 1))-nightly.$(date +'%Y%m%d')"
-    npm version "$NIGHTLY_VERSION" --no-git-tag-version
-    echo "Publishing nightly version: $NIGHTLY_VERSION"
+    npm version prerelease --preid nightly --no-git-tag-version
+    echo "Publishing nightly version: $(node -p "require('./package.json').version")"
Suggestion importance[1-10]: 8

__

Why: This is an excellent suggestion that replaces a complex and potentially brittle shell script with a single, standard npm command, significantly improving code simplicity and maintainability.

Medium
Improve workflow concurrency

Improve workflow concurrency by setting cancel-in-progress to true and scoping
the concurrency group by github.ref to prevent interference between different
publish types.

.github/workflows/publish-package.yml [21-23]

 concurrency:
-  group: publish-package
-  cancel-in-progress: false
+  group: publish-package-${{ github.ref }}
+  cancel-in-progress: true
Suggestion importance[1-10]: 8

__

Why: The suggestion correctly identifies that the current concurrency settings can cause contention between release and nightly jobs, and proposes a valid solution to isolate them and prevent queued runs.

Medium
✅ Add explicit schedule branch
Suggestion Impact:The workflow logic was updated to include an explicit `elif [ "$EVENT_NAME" == "schedule" ]` branch in the event-based conditional, rather than relying on `else` to implicitly represent scheduled runs (though the surrounding logic was also refactored to output a publish matrix).

code diff:

+      - name: Determine publish matrix
+        id: set-matrix
         env:
           EVENT_NAME: ${{ github.event_name }}
           PUBLISH_TYPE: ${{ inputs.publish_type }}
         run: |
           if [ "$EVENT_NAME" == "release" ]; then
-            echo "type=release" >> $GITHUB_OUTPUT
-            echo "should_publish=true" >> $GITHUB_OUTPUT
-          elif [ "$EVENT_NAME" == "workflow_dispatch" ]; then
-            echo "type=$PUBLISH_TYPE" >> $GITHUB_OUTPUT
-            echo "should_publish=true" >> $GITHUB_OUTPUT
+            echo 'matrix=["release"]' >> $GITHUB_OUTPUT
+          elif [ "$EVENT_NAME" == "schedule" ]; then
+            echo 'matrix=["master-nightly", "v0.3-nightly"]' >> $GITHUB_OUTPUT
           else
-            COMMITS=$(git rev-list --count --since="24 hours" HEAD)
-            echo "Commits in last 24h: $COMMITS"
-            echo "type=nightly" >> $GITHUB_OUTPUT
-            if [ "$COMMITS" -eq 0 ]; then
-              echo "should_publish=false" >> $GITHUB_OUTPUT
-            else
-              echo "should_publish=true" >> $GITHUB_OUTPUT
-            fi
+            echo "matrix=[\"$PUBLISH_TYPE\"]" >> $GITHUB_OUTPUT
           fi

In the determine job, replace the else block with an explicit elif [
"$EVENT_NAME" == "schedule" ] to handle scheduled runs, making the workflow
logic more robust.

.github/workflows/publish-package.yml [42-57]

 if [ "$EVENT_NAME" == "release" ]; then
   echo "type=release" >> $GITHUB_OUTPUT
   echo "should_publish=true" >> $GITHUB_OUTPUT
 elif [ "$EVENT_NAME" == "workflow_dispatch" ]; then
   echo "type=$PUBLISH_TYPE" >> $GITHUB_OUTPUT
   echo "should_publish=true" >> $GITHUB_OUTPUT
-else
+elif [ "$EVENT_NAME" == "schedule" ]; then
   COMMITS=$(git rev-list --count --since="24 hours" HEAD)
   echo "type=nightly" >> $GITHUB_OUTPUT
   if [ "$COMMITS" -eq 0 ]; then
     echo "should_publish=false" >> $GITHUB_OUTPUT
   else
     echo "should_publish=true" >> $GITHUB_OUTPUT
   fi
+else
+  echo "should_publish=false" >> $GITHUB_OUTPUT
 fi
Suggestion importance[1-10]: 7

__

Why: This suggestion correctly points out that relying on a catch-all else for the schedule event is brittle and improves the workflow's robustness by explicitly checking for the event name.

Medium

@qodo-free-for-open-source-projects

qodo-free-for-open-source-projects Bot commented Feb 13, 2026 •

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (2) 📘 Rule violations (0) 📎 Requirement gaps (0)

Grey Divider


Action required

1. Nightly version collisions 🐞 Bug ⛯ Reliability
Description
Nightly version is derived from base semver + YYYYMMDD only, so reruns or multiple nightly runs on
the same day will compute the same version and cause publish failures due to duplicate versions.
Code

.github/workflows/publish-package.yml[R87-92]

+          cd build/package
+          CURRENT_VERSION=$(node -p "require('./package.json').version")
+          BASE_VERSION=$(echo "$CURRENT_VERSION" | sed 's/-.*//')
+          IFS='.' read -r -a V <<< "$BASE_VERSION"
+          NIGHTLY_VERSION="${V[0]}.${V[1]}.$((V[2] + 1))-nightly.$(date +'%Y%m%d')"
+          npm version "$NIGHTLY_VERSION" --no-git-tag-version
Evidence
The workflow computes NIGHTLY_VERSION using only the base version and the current date (day
precision), with no additional uniqueness source (e.g., run number/SHA). Therefore, multiple runs on
the same date generate identical versions.

.github/workflows/publish-package.yml[84-93]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
Nightly publishing computes a version string that only varies by date (YYYYMMDD). If the workflow is re-run, manually dispatched multiple times, or triggered more than once on the same day, it will attempt to publish the same version again and fail.
### Issue Context
Nightly version is computed in the publish job before `pnpm publish --tag nightly`.
### Fix Focus Areas
- .github/workflows/publish-package.yml[84-93]
### Suggested change
- Keep the existing base-version parsing, but append at least one of:
- `${GITHUB_RUN_NUMBER}`
- short commit SHA (e.g., `${GITHUB_SHA::7}`)
- higher-resolution UTC timestamp (e.g., `date -u +&amp;amp;amp;amp;amp;amp;amp;#x27;%Y%m%d%H%M%S&amp;amp;amp;amp;amp;amp;amp;#x27;`)
This ensures versions are unique across multiple runs on the same day.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools



Remediation recommended

2. Dispatch release publish path 🐞 Bug ⛯ Reliability
Description
workflow_dispatch allows publish_type=release, which triggers the release publish step without the
documented GitHub Release flow; this is likely to result in a failed run (e.g., attempting to
republish an existing version) and can create confusion about the intended release process.
Code

.github/workflows/publish-package.yml[R45-47]

+          elif [ "$EVENT_NAME" == "workflow_dispatch" ]; then
+            echo "type=$PUBLISH_TYPE" >> $GITHUB_OUTPUT
+            echo "should_publish=true" >> $GITHUB_OUTPUT
Evidence
The workflow explicitly exposes a manual dispatch option for release and treats any
workflow_dispatch as publishable, setting type=$PUBLISH_TYPE. Repo docs describe release
publishing as being triggered by creating a GitHub Release, not by manually dispatching a release
publish.

.github/workflows/publish-package.yml[11-19]
.github/workflows/publish-package.yml[42-47]
DEVELOPER.md[172-181]
.github/workflows/publish-package.yml[95-99]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`workflow_dispatch` currently allows `publish_type=release`, and the workflow will proceed to run the release publish step even though the documented release process is tied to the GitHub Release event. This makes it easy to trigger a confusing/failed publish run.
### Issue Context
Docs describe publishing as triggered by a GitHub Release; the workflow also supports manual dispatch.
### Fix Focus Areas
- .github/workflows/publish-package.yml[11-19]
- .github/workflows/publish-package.yml[42-47]
### Suggested fixes (pick one)
1) **Simplest (recommended):**
- Remove `release` from `workflow_dispatch.inputs.publish_type.options`
- Optionally remove the workflow_dispatch branch in the determine step or force it to `nightly`.
2) **If you must keep manual release:**
- Add validation/guardrails, e.g.:
- Only allow manual release when `github.ref` is a tag (`refs/tags/...`)
- Validate the local package version differs from the currently published one (e.g., `npm view typeorm version`) before attempting publish
- Fail early with a clear error message if checks fail.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

ⓘ The new review experience is currently in Beta. Learn more

Grey Divider

Qodo Logo

Comment thread .github/workflows/publish-package.yml Outdated
Comment on lines +87 to +92
cd build/package
CURRENT_VERSION=$(node -p "require('./package.json').version")
BASE_VERSION=$(echo "$CURRENT_VERSION" | sed 's/-.*//')
IFS='.' read -r -a V <<< "$BASE_VERSION"
NIGHTLY_VERSION="${V[0]}.${V[1]}.$((V[2] + 1))-nightly.$(date +'%Y%m%d')"
npm version "$NIGHTLY_VERSION" --no-git-tag-version

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Action required

1. Nightly version collisions 🐞 Bug ⛯ Reliability

Nightly version is derived from base semver + YYYYMMDD only, so reruns or multiple nightly runs on
the same day will compute the same version and cause publish failures due to duplicate versions.
Agent Prompt
### Issue description
Nightly publishing computes a version string that only varies by date (YYYYMMDD). If the workflow is re-run, manually dispatched multiple times, or triggered more than once on the same day, it will attempt to publish the same version again and fail.

### Issue Context
Nightly version is computed in the publish job before `pnpm publish --tag nightly`.

### Fix Focus Areas
- .github/workflows/publish-package.yml[84-93]

### Suggested change
- Keep the existing base-version parsing, but append at least one of:
  - `${GITHUB_RUN_NUMBER}`
  - short commit SHA (e.g., `${GITHUB_SHA::7}`)
  - higher-resolution UTC timestamp (e.g., `date -u +'%Y%m%d%H%M%S'`)

This ensures versions are unique across multiple runs on the same day.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Persistent review updated to latest commit 00eafbc

@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Persistent review updated to latest commit cbbcc9a

@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Persistent review updated to latest commit 056adae

@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Persistent review updated to latest commit b1765d1

Comment on lines 46 to +56
publish:
needs: setup
runs-on: ubuntu-latest
environment: npm
permissions:
contents: read
id-token: write
strategy:
fail-fast: false
matrix:
type: ${{ fromJson(needs.setup.outputs.matrix) }}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Action required

1. Env/oidc enabled on skip 🐞 Bug ⛨ Security

The publish job always runs in the protected npm environment with id-token: write, even when
nightly publishing is skipped due to no new commits. This defeats least privilege and can also cause
scheduled runs to block on environment approvals while doing no publish.
Agent Prompt
## Issue description
The workflow always activates the protected npm environment and OIDC permissions even when the run will skip publishing.

## Issue Context
This can introduce unnecessary approval prompts/blocks and violates least-privilege (OIDC token permission granted when not needed).

## Fix Focus Areas
- .github/workflows/publish-package.yml[26-56]
- .github/workflows/publish-package.yml[63-77]
- .github/workflows/publish-package.yml[145-147]

## Suggested direction
- Move the commit/need-to-publish determination into `setup` and output a matrix that excludes entries with no new commits; then `publish` always publishes and never needs a skip path.
- Alternatively, split jobs: `build` (no environment, no id-token) -> `publish` (environment npm, id-token write) with `if:` based on `build` outputs.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Feb 17, 2026 •

Copy link
Copy Markdown

Deploying typeorm with  Cloudflare Pages  Cloudflare Pages

Latest commit: e47aae6
Status: ✅  Deploy successful!
Preview URL: https://5ee33434.typeorm.pages.dev
Branch Preview URL: https://feat-trusted-publishing.typeorm.pages.dev

View logs

@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Persistent review updated to latest commit e47aae6

Comment on lines +117 to +143
- name: Set nightly version
if: matrix.type != 'release' && steps.commit_check.outputs.should_publish == 'true'
run: |
cd build/package
pnpm publish --provenance --access public
node -e "
const pkg = require('./package.json');
const base = pkg.version.replace(/-.*/, '');
const [major, minor, patch] = base.split('.').map(Number);
const hasPrerelease = pkg.version.includes('-');
pkg.version = major + '.' + minor + '.' + (hasPrerelease ? patch : patch + 1) + '-nightly.' + new Date().toISOString().slice(0,10).replace(/-/g, '');
require('fs').writeFileSync('package.json', JSON.stringify(pkg, null, 2) + '\n');
console.log('Publishing nightly version: ' + pkg.version);
"

- name: Publish (release)
if: matrix.type == 'release'
run: |
cd build/package
pnpm publish --provenance --access public --no-git-checks

- name: Publish (nightly)
if: matrix.type != 'release' && steps.commit_check.outputs.should_publish == 'true'
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
DIST_TAG: ${{ steps.commit_check.outputs.dist_tag }}
run: |
cd build/package
pnpm publish --provenance --access public --no-git-checks --tag "$DIST_TAG"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Action required

1. Nightly tags undocumented 📘 Rule violation ✓ Correctness

This PR adds new npm nightly dist-tags (master, v0.3) and a nightly publishing workflow, which
changes how users can install pre-release builds. No documentation updates are included to describe
these new install options.
Agent Prompt
## Issue description
Nightly publishing introduces new user-facing install options (`typeorm@master`, `[email protected]`), but documentation was not updated to reflect how/when to use these dist-tags.

## Issue Context
The workflow now publishes nightlies with `--tag "$DIST_TAG"` and the PR description advertises installation via these tags.

## Fix Focus Areas
- .github/workflows/publish-package.yml[63-143]
- docs/docs/getting-started.md[149-167]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Persistent review updated to latest commit 6cbb065

Comment on lines +131 to +136
- name: Publish (release)
if: matrix.type == 'release'
run: |
cd build/package
pnpm publish --provenance --access public --no-git-checks

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Action required

1. Prerelease tagged as latest 🐞 Bug ✓ Correctness

The release publish step does not set an npm dist-tag, so a master prerelease (e.g. 1.0.0-pre)
can be published under the default tag (typically latest) and become the version installed by `npm
install typeorm. This conflicts with the repo’s existing prerelease publishing convention (next`)
and can unintentionally shift stable users onto v1 prerelease builds.
Agent Prompt
## Issue description
Release publishing currently runs `pnpm publish` without `--tag`, which can push prerelease versions from `master` (e.g. `1.0.0-pre`) under the default npm dist-tag (typically `latest`). This can cause `npm install typeorm` to install v1 prereleases unintentionally.

## Issue Context
The repo already has a gulp task intended to publish with `--tag next`, and docs mention `next` for prereleases, but the workflow does not implement any dist-tag selection for releases.

## Fix Focus Areas
- .github/workflows/publish-package.yml[131-136]
- package.json[1-4]
- gulpfile.ts[84-92]
- DEVELOPER.md[192-200]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

@michaelbromley
michaelbromley merged commit c5680ce into master Feb 17, 2026
19 checks passed
@michaelbromley
michaelbromley deleted the feat/trusted-publishing branch February 17, 2026 19:59
@pkuczynski pkuczynski added this to the 1.0 milestone Mar 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

4 participants