Skip to content

An open-source, faster Devin alternative

TypeScript

ci: publish npm packages only from main via the npm environment

Mohamed Habib via Computer6c63942028c8
diff --git a/.github/workflows/publish-flue-sdk.yml b/.github/workflows/publish-flue-sdk.yml
index 4f5bc98f..63fe1166 100644
--- a/.github/workflows/publish-flue-sdk.yml
+++ b/.github/workflows/publish-flue-sdk.yml
@@ -23,6 +23,7 @@ jobs:
permissions:
contents: read
id-token: write
+ environment: npm
steps:
- uses: actions/checkout@v4
diff --git a/.github/workflows/publish-opencomputer-packages.yml b/.github/workflows/publish-opencomputer-packages.yml
index b7911326..a46f4372 100644
--- a/.github/workflows/publish-opencomputer-packages.yml
+++ b/.github/workflows/publish-opencomputer-packages.yml
@@ -25,9 +25,61 @@ concurrency:
cancel-in-progress: false
jobs:
+ test:
+ name: Test and build packages
+ runs-on: ubuntu-latest
+ permissions:
+ contents: read
+ steps:
+ - uses: actions/checkout@v4
+
+ - uses: actions/setup-node@v4
+ with:
+ node-version: "22"
+ registry-url: "https://registry.npmjs.org"
+ cache: npm
+ cache-dependency-path: |
+ agent/package-lock.json
+ react/package-lock.json
+ cli/package-lock.json
+
+ - name: Verify package version contract
+ run: node scripts/check-opencomputer-package-contract.mjs
+
+ - name: Install and test agent package
+ working-directory: agent
+ run: |
+ npm ci
+ npm test
+
+ - name: Install and test CLI package
+ working-directory: cli
+ run: |
+ npm ci
+ npm test
+
+ - name: Install and test React package
+ working-directory: react
+ run: |
+ npm ci
+ npm test
+
+ - name: Install and test starter package
+ working-directory: create-start
+ env:
+ OPENCOMPUTER_CREATE_START_MODULE_PATH: ${{ github.workspace }}/cli/dist/create-start.js
+ run: |
+ npm test
+
+
+ # Publishing holds NPM_TOKEN and an OIDC token, so it runs only from main and
+ # only in the `npm` environment, whose secrets are restricted to main.
publish:
- name: Test, build, and publish packages
+ name: Publish packages
+ needs: test
+ if: github.event_name != 'pull_request' && github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
+ environment: npm
permissions:
contents: read
id-token: write
@@ -73,7 +125,6 @@ jobs:
npm test
- name: Publish packages in dependency order
- if: github.event_name != 'pull_request'
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
shell: bash
diff --git a/.github/workflows/publish-ts-sdk.yml b/.github/workflows/publish-ts-sdk.yml
index 78963da8..ffad5476 100644
--- a/.github/workflows/publish-ts-sdk.yml
+++ b/.github/workflows/publish-ts-sdk.yml
@@ -18,6 +18,7 @@ jobs:
permissions:
contents: read
id-token: write
+ environment: npm
steps:
- uses: actions/checkout@v4