# Publishes @twoux/ui and twoux to npm when a GitHub release is published. # It can also be run by hand (Actions → Publish to npm → Run workflow) on a release tag such as v0.1.1, # for a release whose automatic run didn't start. # Uses npm trusted publishing (OpenID Connect): no npm token is stored anywhere, and each version # carries a provenance statement linking it to this repository and workflow run. # Actions are pinned to exact commits so a moved tag can't change what runs here. name: Publish to npm on: release: types: [published] workflow_dispatch: permissions: contents: read id-token: write jobs: publish: runs-on: ubuntu-latest # The "npm" environment can require a person to approve each run (Settings → Environments). environment: npm steps: - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0 - uses: pnpm/action-setup@fc06bc1257f339d1d5d8b3a19a8cae5388b55320 # v4.4.0 - uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0 with: node-version: 24 registry-url: https://registry.npmjs.org # Trusted publishing needs npm 11.5.1 or later. - run: npm install -g npm@11 - run: pnpm install --frozen-lockfile - name: Check the release tag matches both package versions run: | [ "$GITHUB_REF_TYPE" = "tag" ] || { echo "Run this on a release tag such as v0.1.1, not the branch $GITHUB_REF_NAME."; exit 1; } tag="${GITHUB_REF_NAME#v}" for p in packages/ui packages/twoux; do v=$(node -p "require('./$p/package.json').version") [ "$v" = "$tag" ] || { echo "$p is $v, release is $tag"; exit 1; } done - run: pnpm typecheck - name: Pack run: | mkdir -p "$RUNNER_TEMP/npm" (cd packages/ui && pnpm pack --pack-destination "$RUNNER_TEMP/npm") (cd packages/twoux && pnpm pack --pack-destination "$RUNNER_TEMP/npm") ls -l "$RUNNER_TEMP/npm" # The library first: the twoux command depends on it. - run: npm publish "$RUNNER_TEMP"/npm/twoux-ui-*.tgz --provenance --access public - run: npm publish "$RUNNER_TEMP"/npm/twoux-[0-9]*.tgz --provenance --access public