diff --git a/.forgejo/workflows/publish.yml b/.forgejo/workflows/publish.yml index f883389..ddf60cb 100644 --- a/.forgejo/workflows/publish.yml +++ b/.forgejo/workflows/publish.yml @@ -23,27 +23,26 @@ jobs: with: node-version: ${{ env.NODE_VERSION }} - - name: Setup pnpm + - name: Setup pnpm and bun run: | - npm install -g pnpm@${{ env.PNPM_VERSION }} + npm install -g pnpm@${{ env.PNPM_VERSION }} bun echo "Node: $(node --version)" echo "pnpm: $(pnpm --version)" + echo "bun: $(bun --version)" - name: Configure npm for Forgejo registry run: | echo "@lilith:registry=https://forge.nasty.sh/api/packages/lilith/npm/" > .npmrc echo "//forge.nasty.sh/api/packages/lilith/npm/:_authToken=\${NPM_TOKEN}" >> .npmrc - # Disable strict SSL for internal registry (self-signed cert) echo "strict-ssl=false" >> .npmrc + echo "Configured Forgejo registry" - name: Transform external workspace dependencies run: | - # Convert workspace:* deps to * for packages not in this workspace node -e " const fs = require('fs'); const path = require('path'); - // Collect all package names in this workspace const localPackages = new Set(); const dirs = fs.readdirSync('.').filter(d => fs.statSync(d).isDirectory() && @@ -55,7 +54,6 @@ jobs: const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8')); if (pkg.name) localPackages.add(pkg.name); } - // Add root package if (fs.existsSync('package.json')) { const rootPkg = JSON.parse(fs.readFileSync('package.json', 'utf8')); if (rootPkg.name) localPackages.add(rootPkg.name); @@ -75,7 +73,6 @@ jobs: return deps; }; - // Transform root package.json if (fs.existsSync('package.json')) { console.log('Processing: package.json'); const pkg = JSON.parse(fs.readFileSync('package.json', 'utf8')); @@ -85,7 +82,6 @@ jobs: fs.writeFileSync('package.json', JSON.stringify(pkg, null, 2)); } - // Transform all workspace package.json files for (const dir of dirs) { const pkgPath = path.join(dir, 'package.json'); console.log('Processing:', pkgPath); @@ -99,78 +95,74 @@ jobs: - name: Install dependencies run: | - echo "Installing dependencies..." + echo "=== Installing dependencies ===" pnpm install --no-frozen-lockfile + echo "Dependencies installed" + + - name: Build + run: | + echo "=== Building monorepo packages ===" + pnpm run build + echo "Build complete" - name: Validate run: | - echo "Running validation..." - # Run typecheck if available + echo "=== Running validation ===" if grep -q '"typecheck"' package.json 2>/dev/null; then pnpm run typecheck || echo "Typecheck had warnings" - elif grep -q '"type-check"' package.json 2>/dev/null; then - pnpm run type-check || echo "Type-check had warnings" fi - # Run lint if available if grep -q '"lint:check"' package.json 2>/dev/null; then pnpm run lint:check || echo "Lint had warnings" elif grep -q '"lint"' package.json 2>/dev/null; then pnpm run lint || echo "Lint had warnings" fi + echo "Validation complete" - - name: Build and Publish based on _ config + - name: Publish run: | pkg_name=$(node -p "require('./package.json').name") pkg_version=$(node -p "require('./package.json').version") - - # Read _ config fields - should_build=$(node -p "require('./package.json')._?.build === true") should_publish=$(node -p "require('./package.json')._?.publish === true") registry=$(node -p "require('./package.json')._?.registry || 'none'") echo "=== $pkg_name@$pkg_version ===" - echo " build: $should_build, publish: $should_publish, registry: $registry" + echo " publish: $should_publish, registry: $registry" - # Only process if configured for forgejo registry if [ "$registry" != "forgejo" ]; then echo "Skipping: registry is not forgejo" exit 0 fi - # Build if configured - if [ "$should_build" = "true" ]; then - echo "Building..." - pnpm run build + if [ "$should_publish" != "true" ]; then + echo "Skipping: publish not enabled" + exit 0 fi - # Publish if configured - if [ "$should_publish" = "true" ]; then - if npm view "$pkg_name@$pkg_version" version 2>/dev/null; then - echo "Already published, skipping" - else - echo "Publishing..." + if npm view "$pkg_name@$pkg_version" version 2>/dev/null; then + echo "Already published: $pkg_name@$pkg_version" + else + echo "Publishing $pkg_name@$pkg_version..." - # Transform workspace:* and file: dependencies - node -e " - const fs = require('fs'); - const pkg = JSON.parse(fs.readFileSync('package.json', 'utf8')); - const transform = (deps) => { - if (!deps) return deps; - for (const [name, version] of Object.entries(deps)) { - if (version.startsWith('workspace:') || version.startsWith('file:')) { - deps[name] = '*'; - } + node -e " + const fs = require('fs'); + const pkg = JSON.parse(fs.readFileSync('package.json', 'utf8')); + const transform = (deps) => { + if (!deps) return deps; + for (const [name, version] of Object.entries(deps)) { + if (version.startsWith('workspace:') || version.startsWith('file:')) { + deps[name] = '*'; } - return deps; - }; - pkg.dependencies = transform(pkg.dependencies); - pkg.devDependencies = transform(pkg.devDependencies); - pkg.peerDependencies = transform(pkg.peerDependencies); - fs.writeFileSync('package.json', JSON.stringify(pkg, null, 2)); - " + } + return deps; + }; + pkg.dependencies = transform(pkg.dependencies); + pkg.devDependencies = transform(pkg.devDependencies); + pkg.peerDependencies = transform(pkg.peerDependencies); + fs.writeFileSync('package.json', JSON.stringify(pkg, null, 2)); + " - npm publish --access public --no-git-checks - fi + npm publish --access public --no-git-checks + echo "Published $pkg_name@$pkg_version" fi echo "=== Complete ==="