Skip to content

Self-improving AI Employees for everyone

Add npm trusted publishing and inline publish jobs in release.yml

trohitgf2eef15c4537
diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml
deleted file mode 100644
index 109c6f20..00000000
--- a/.github/workflows/deploy.yml
+++ /dev/null
@@ -1,70 +0,0 @@
-# Reusable publish workflow called by release.yml
-# Publishes to both npm (OIDC) and GitHub Packages
-
-name: Deploy
-
-on:
- workflow_call:
-
-jobs:
- publish-npm:
- runs-on: ubuntu-latest
- permissions:
- contents: read
- id-token: write
- steps:
- - name: Checkout
- uses: actions/checkout@v4
-
- - name: Setup environment
- uses: ./.github/actions/setup
-
- - name: Setup Node.js (npm registry)
- uses: actions/setup-node@v4
- with:
- node-version: '20'
- registry-url: 'https://registry.npmjs.org'
-
- - name: Upgrade npm for OIDC support
- run: npm install -g npm@latest
-
- - name: Build all services
- run: npm run build
-
- - name: Publish to npm
- run: npm publish --access public --provenance
-
- publish-github-packages:
- runs-on: ubuntu-latest
- permissions:
- contents: read
- packages: write
- steps:
- - name: Checkout
- uses: actions/checkout@v4
-
- - name: Setup environment
- uses: ./.github/actions/setup
-
- - name: Setup Node.js (GitHub Packages)
- uses: actions/setup-node@v4
- with:
- node-version: '20'
- registry-url: 'https://npm.pkg.github.com'
-
- - name: Build all services
- run: npm run build
-
- - name: Configure scoped package
- run: |
- node -e "
- const pkg = require('./package.json');
- pkg.name = '@trohitg/machinaos';
- pkg.publishConfig = { registry: 'https://npm.pkg.github.com' };
- require('fs').writeFileSync('package.json', JSON.stringify(pkg, null, 2));
- "
-
- - name: Publish to GitHub Packages
- run: npm publish
- env:
- NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index b410fdc0..3aac9d24 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -1,5 +1,4 @@
-# Release workflow - chained: predeploy validation gate -> deploy publish
-# Triggers on version tags and GitHub releases
+# Release workflow - predeploy gate then publish
name: Release
@@ -14,10 +13,61 @@ jobs:
predeploy:
uses: ./.github/workflows/predeploy.yml
- deploy:
+ publish-npm:
+ name: Publish to npm
needs: predeploy
- uses: ./.github/workflows/deploy.yml
+ runs-on: ubuntu-latest
+ steps:
+ - name: Checkout
+ uses: actions/checkout@v4
+
+ - name: Setup Node.js
+ uses: actions/setup-node@v4
+ with:
+ node-version: '20'
+ registry-url: 'https://registry.npmjs.org'
+
+ - name: Install dependencies
+ run: npm install --ignore-scripts
+
+ - name: Verify package contents
+ run: npm pack --dry-run
+
+ - name: Publish to npm
+ run: npm publish --access public
+ env:
+ NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
+
+ publish-github-packages:
+ name: Publish to GitHub Packages
+ needs: predeploy
+ runs-on: ubuntu-latest
permissions:
contents: read
- id-token: write
packages: write
+ steps:
+ - name: Checkout
+ uses: actions/checkout@v4
+
+ - name: Setup Node.js
+ uses: actions/setup-node@v4
+ with:
+ node-version: '20'
+ registry-url: 'https://npm.pkg.github.com'
+
+ - name: Install dependencies
+ run: npm install --ignore-scripts
+
+ - name: Configure scoped package
+ run: |
+ node -e "
+ const pkg = require('./package.json');
+ pkg.name = '@trohitg/machinaos';
+ pkg.publishConfig = { registry: 'https://npm.pkg.github.com' };
+ require('fs').writeFileSync('package.json', JSON.stringify(pkg, null, 2));
+ "
+
+ - name: Publish to GitHub Packages
+ run: npm publish
+ env:
+ NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}