v1.1.1 #67
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Release to npm | |
| on: | |
| release: | |
| types: [published] | |
| workflow_dispatch: | |
| inputs: | |
| version: | |
| description: 'Version to release (e.g., 0.1.0)' | |
| required: true | |
| type: string | |
| jobs: | |
| build-and-publish: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| registry-url: 'https://registry.npmjs.org' | |
| scope: '@predicatesystems' | |
| always-auth: true | |
| - name: Extract version from tag or input | |
| id: version | |
| run: | | |
| if [ "${{ github.event_name }}" == "release" ]; then | |
| # For release events, use the tag_name from the release event | |
| TAG_NAME="${{ github.event.release.tag_name }}" | |
| # Remove 'v' prefix if present | |
| VERSION=${TAG_NAME#v} | |
| else | |
| VERSION="${{ github.event.inputs.version }}" | |
| fi | |
| echo "version=$VERSION" >> $GITHUB_OUTPUT | |
| echo "Version: $VERSION" | |
| - name: Update version in package.json | |
| run: | | |
| VERSION="${{ steps.version.outputs.version }}" | |
| CURRENT_VERSION=$(node -p "require('./package.json').version") | |
| if [ "$CURRENT_VERSION" != "$VERSION" ]; then | |
| echo "Updating version from $CURRENT_VERSION to $VERSION" | |
| npm pkg set version=$VERSION | |
| else | |
| echo "Version is already $VERSION, skipping update" | |
| fi | |
| - name: Install dependencies | |
| run: | | |
| npm ci | |
| - name: Install Playwright Browsers | |
| run: | | |
| npx playwright install chromium | |
| npx playwright install-deps chromium || true | |
| - name: Run tests | |
| run: | | |
| npm test | |
| env: | |
| CI: true | |
| - name: Verify extension files are present | |
| run: | | |
| echo "🔍 Verifying extension files are included..." | |
| # Check required extension files exist | |
| REQUIRED_FILES=( | |
| "src/extension/manifest.json" | |
| "src/extension/content.js" | |
| "src/extension/background.js" | |
| "src/extension/injected_api.js" | |
| "src/extension/pkg/sentience_core.js" | |
| "src/extension/pkg/sentience_core_bg.wasm" | |
| ) | |
| MISSING_FILES=() | |
| for file in "${REQUIRED_FILES[@]}"; do | |
| if [ ! -f "$file" ]; then | |
| MISSING_FILES+=("$file") | |
| fi | |
| done | |
| if [ ${#MISSING_FILES[@]} -ne 0 ]; then | |
| echo "❌ Error: Missing required extension files:" | |
| printf ' - %s\n' "${MISSING_FILES[@]}" | |
| echo "" | |
| echo "Please ensure the extension is synced before releasing." | |
| echo "Run the sync-extension workflow or manually sync extension files." | |
| exit 1 | |
| fi | |
| # Verify findTextRect function exists in injected_api.js | |
| if ! grep -q "findTextRect:" src/extension/injected_api.js; then | |
| echo "❌ Error: findTextRect function not found in injected_api.js" | |
| echo "The extension may be out of date. Please sync the extension before releasing." | |
| exit 1 | |
| fi | |
| echo "✅ All extension files verified" | |
| echo "📦 Extension files that will be included:" | |
| find src/extension -type f | sort | |
| - name: Build package | |
| run: | | |
| npm run build | |
| - name: Verify extension files in built package | |
| run: | | |
| echo "🔍 Verifying extension files are included in the built package..." | |
| # Check that src/extension directory exists after build | |
| # (TypeScript build doesn't modify extension files, they should still be in src/) | |
| if [ ! -d "src/extension" ]; then | |
| echo "❌ Error: src/extension directory missing after build" | |
| exit 1 | |
| fi | |
| # Verify findTextRect is still in the extension after build | |
| if ! grep -q "findTextRect:" src/extension/injected_api.js; then | |
| echo "❌ Error: findTextRect not found in extension after build" | |
| exit 1 | |
| fi | |
| # Check package.json files array includes src/extension | |
| if ! grep -q '"src/extension"' package.json; then | |
| echo "⚠️ Warning: package.json files array may not include src/extension" | |
| echo "Current files array:" | |
| grep -A 5 '"files"' package.json || echo "files array not found" | |
| fi | |
| echo "✅ Extension files verified in package" | |
| echo "📦 Extension files that will be published:" | |
| find src/extension -type f | head -20 | |
| - name: npm publish preflight (auth + registry) | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
| run: | | |
| set -euo pipefail | |
| echo "=== Token presence (non-secret) ===" | |
| node -e "console.log('NODE_AUTH_TOKEN set:', !!process.env.NODE_AUTH_TOKEN, 'len:', (process.env.NODE_AUTH_TOKEN||'').length)" | |
| echo "" | |
| echo "=== Toolchain ===" | |
| node --version | |
| npm --version | |
| echo "" | |
| echo "=== Registry ===" | |
| npm config get registry | |
| npm ping --registry https://registry.npmjs.org | |
| echo "" | |
| echo "=== Auth ===" | |
| npm whoami --registry https://registry.npmjs.org | |
| echo "" | |
| echo "=== Scope access (@predicatesystems) ===" | |
| # npm v10 syntax: | |
| # - `npm access list packages <scope>` checks whether the user can see/publish packages in that scope | |
| # - if you are not a member/owner of the npm org, this typically fails (403/404) which is what we want surfaced | |
| # NOTE: Some orgs restrict org-wide package listing to admins/owners. | |
| # Treat this as best-effort diagnostics; do not block publishing. | |
| npm access list packages @predicatesystems --registry https://registry.npmjs.org --json || echo "WARN: cannot list org packages for @predicatesystems (may be restricted; continuing)" | |
| echo "" | |
| echo "=== Sanity: npm profile (should succeed) ===" | |
| npm profile get --registry https://registry.npmjs.org --json || echo "WARN: cannot read npm profile (continuing)" | |
| echo "" | |
| echo "=== Sanity: does package already exist? (ok if 404) ===" | |
| npm view @predicatesystems/runtime version --registry https://registry.npmjs.org --json || echo "INFO: @predicatesystems/runtime not found yet (expected for first publish)" | |
| - name: Publish to npm | |
| run: | | |
| npm publish --access public | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
| - name: Create GitHub Release | |
| if: github.event_name == 'workflow_dispatch' | |
| uses: softprops/action-gh-release@v1 | |
| with: | |
| tag_name: v${{ steps.version.outputs.version }} | |
| name: Release v${{ steps.version.outputs.version }} | |
| body: | | |
| Release v${{ steps.version.outputs.version }} of @predicatesystems/runtime | |
| ## Installation | |
| ```bash | |
| npm install @predicatesystems/runtime@${{ steps.version.outputs.version }} | |
| ``` | |
| draft: false | |
| prerelease: false | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| publish-compat-shim: | |
| runs-on: ubuntu-latest | |
| needs: build-and-publish | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| registry-url: 'https://registry.npmjs.org' | |
| scope: '@predicatesystems' | |
| always-auth: true | |
| - name: Extract version from tag or input | |
| id: version | |
| run: | | |
| if [ "${{ github.event_name }}" == "release" ]; then | |
| TAG_NAME="${{ github.event.release.tag_name }}" | |
| VERSION=${TAG_NAME#v} | |
| else | |
| VERSION="${{ github.event.inputs.version }}" | |
| fi | |
| echo "version=$VERSION" >> $GITHUB_OUTPUT | |
| echo "Version: $VERSION" | |
| - name: Sync shim version and runtime dependency | |
| run: | | |
| VERSION="${{ steps.version.outputs.version }}" | |
| npm pkg set version=$VERSION --prefix compat/sdk-shim | |
| npm pkg set dependencies."@predicatesystems/runtime"=$VERSION --prefix compat/sdk-shim | |
| - name: Publish compatibility shim to npm | |
| run: | | |
| cd compat/sdk-shim | |
| npm publish --access public | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |