fix: improve generated type indentation and transition www to workspa… #35
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: Publish | |
| # Push a commit to main whose message STARTS WITH `final:publish` (e.g. | |
| # `git commit -m "final:publish: ..."`) to build, bump, and publish all | |
| # four packages to npm. Any other commit is a no-op here, deliberately | |
| # `startsWith`, not a bare substring match: a commit message that merely | |
| # *mentions* the trigger phrase (like this comment block, or a docs commit | |
| # explaining this workflow) must never fire it by accident. Confirmed this | |
| # was a real, not just theoretical, risk: an earlier commit whose message | |
| # explained this exact trigger phrase in its body fired the workflow. | |
| # | |
| # Uses npm Trusted Publishing (OIDC), no stored token/secret at all. Before | |
| # the first real run, each package needs a Trusted Publisher configured on | |
| # its own npmjs.com settings page: | |
| # | |
| # npmjs.com -> package -> Settings -> Trusted Publisher -> GitHub Actions | |
| # Organization or user: phe-rus | |
| # Repository: base-config | |
| # Workflow filename: publish.yml | |
| # Environment name: npm-publish | |
| # | |
| # Do this for @baseconfig/ui, @baseconfig/core, @baseconfig/plugin-form-builder, | |
| # and @baseconfig/cli. | |
| # Trusted Publishing is implemented in the npm CLI itself (not `bun publish`), | |
| # and requires a recent-enough npm, this workflow force-installs npm@latest | |
| # before publishing rather than relying on whatever ships with the runner. | |
| on: | |
| push: | |
| branches: [main] | |
| permissions: | |
| contents: write | |
| id-token: write | |
| jobs: | |
| publish: | |
| if: startsWith(github.event.head_commit.message, 'final:publish') | |
| runs-on: ubuntu-latest | |
| environment: npm-publish | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v5 | |
| with: | |
| fetch-depth: 0 | |
| - name: Setup Bun | |
| uses: oven-sh/setup-bun@v2 | |
| with: | |
| bun-version: 1.3.14 | |
| - name: Setup Node (for a recent, OIDC-capable npm CLI) | |
| uses: actions/setup-node@v5 | |
| with: | |
| node-version: 22 | |
| - name: Update npm | |
| run: npm install -g npm@latest | |
| - name: Install dependencies | |
| run: bun install | |
| - name: Typecheck | |
| run: bunx turbo run typecheck | |
| - name: Build | |
| run: bunx turbo run build | |
| # `packages/config`/`packages/ui`/`plugins/plugin-form-builder` are | |
| # tightly coupled (config depends on ui, plugin-form-builder depends on | |
| # both). `packages/cli` (`@baseconfig/cli`) has no such dependency, it | |
| # only ever resolves core/ui's latest published versions over the | |
| # network, and clones a template directly from this repo's own GitHub | |
| # branch, both at scaffold time, never at its own build/publish time. | |
| # Still kept in the same lockstep release as the other three, so its | |
| # own npm version stays a meaningful signal of "this CLI as of roughly | |
| # when core/ui were at version X." | |
| # | |
| # A plain patch bump, not `npm version patch`: confirmed (the hard | |
| # way, via a real failed run) that npm CLI's `version` command chokes | |
| # on a `workspace:*` dependency exactly like `npm publish` does | |
| # (`EUNSUPPORTEDPROTOCOL`), even though it isn't touching that field | |
| # at all. Writing the version field directly with plain Node sidesteps | |
| # npm CLI entirely for this step. | |
| - name: Bump versions (patch, all four packages together) | |
| run: | | |
| for pkg in packages/ui packages/config packages/cli plugins/plugin-form-builder; do | |
| node -e " | |
| const fs = require('fs'); | |
| const path = './$pkg/package.json'; | |
| const manifest = JSON.parse(fs.readFileSync(path, 'utf8')); | |
| const [major, minor, patch] = manifest.version.split('.').map(Number); | |
| manifest.version = [major, minor, patch + 1].join('.'); | |
| fs.writeFileSync(path, JSON.stringify(manifest, null, '\t') + '\n'); | |
| console.log(manifest.name, '->', manifest.version); | |
| " | |
| done | |
| - name: Commit version bump | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git add packages/ui/package.json packages/config/package.json packages/cli/package.json plugins/plugin-form-builder/package.json | |
| git commit -m "chore: bump package versions [skip ci]" | |
| git push | |
| # `workspace:*` is what a real bun/pnpm workspace consumer needs to see | |
| # committed, but `npm publish` (unlike `bun publish`) doesn't rewrite | |
| # it to a real version, and plain npm CLI is what Trusted Publishing | |
| # needs. Resolved here, in the ephemeral runner only, right before each | |
| # publish call, never committed back, so the repo keeps workspace:*. | |
| - name: Publish @baseconfig/ui | |
| working-directory: packages/ui | |
| run: npm publish --access public | |
| - name: Resolve @baseconfig/ui's real version into config's package.json | |
| run: | | |
| UI_VERSION=$(node -p "require('./packages/ui/package.json').version") | |
| node -e " | |
| const fs = require('fs'); | |
| const path = './packages/config/package.json'; | |
| const pkg = JSON.parse(fs.readFileSync(path, 'utf8')); | |
| pkg.dependencies['@baseconfig/ui'] = '$UI_VERSION'; | |
| fs.writeFileSync(path, JSON.stringify(pkg, null, '\t') + '\n'); | |
| " | |
| - name: Publish @baseconfig/core | |
| working-directory: packages/config | |
| run: npm publish --access public | |
| - name: Resolve @baseconfig/core and @baseconfig/ui's real versions into plugin-form-builder's package.json | |
| run: | | |
| CORE_VERSION=$(node -p "require('./packages/config/package.json').version") | |
| UI_VERSION=$(node -p "require('./packages/ui/package.json').version") | |
| node -e " | |
| const fs = require('fs'); | |
| const path = './plugins/plugin-form-builder/package.json'; | |
| const pkg = JSON.parse(fs.readFileSync(path, 'utf8')); | |
| pkg.dependencies['@baseconfig/core'] = '$CORE_VERSION'; | |
| pkg.dependencies['@baseconfig/ui'] = '$UI_VERSION'; | |
| fs.writeFileSync(path, JSON.stringify(pkg, null, '\t') + '\n'); | |
| " | |
| - name: Publish @baseconfig/plugin-form-builder | |
| working-directory: plugins/plugin-form-builder | |
| run: npm publish --access public | |
| # No dependency-resolution step needed here: @baseconfig/cli has no | |
| # `workspace:*` dependency on core/ui, it resolves their latest | |
| # published versions over the network at scaffold time instead (see | |
| # `packages/cli/src/npm-registry.ts`). | |
| - name: Publish @baseconfig/cli | |
| working-directory: packages/cli | |
| run: npm publish --access public |