publish-to-npmjs #32
Workflow file for this run
This file contains 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
on: | |
release: | |
types: [published] | |
name: publish-to-npmjs | |
env: | |
PNPM_VERSION: "9.0.4" | |
NODE_VERSION: "18.17.0" | |
jobs: | |
publish: | |
permissions: | |
id-token: write | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out repository | |
uses: actions/checkout@v4 | |
- name: Setup PNPM | |
uses: pnpm/action-setup@v3 | |
with: | |
version: "${{ env.PNPM_VERSION }}" | |
- uses: actions/setup-node@v4 | |
with: | |
cache: pnpm | |
node-version: "${{ env.NODE_VERSION }}" | |
# Forces the creation of an .npmrc that reads `NODE_AUTH_TOKEN` | |
registry-url: "https://registry.npmjs.org" | |
- name: Register package name | |
run: | | |
PACKAGE_NAME=`echo "${{ github.event.release.name }}" | cut -d ' ' -f 1` | |
echo "PACKAGE_NAME=$PACKAGE_NAME" >> $GITHUB_ENV | |
- name: Publish single module | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
NODE_AUTH_TOKEN: ${{ secrets.NODE_AUTH_TOKEN }} | |
NPM_CONFIG_PROVENANCE: true | |
# the `echo` below deliberately uses single quotes so that the | |
# token isn’t written to the file; instead, npm should replace | |
# it at runtime. | |
run: | | |
cd packages/$PACKAGE_NAME | |
pnpm install --frozen-lockfile --filter "$PACKAGE_NAME..." | |
pnpm run --filter "$PACKAGE_NAME" -r build | |
pnpm publish --filter "$PACKAGE_NAME" --no-git-checks | |
- name: Check out just docs | |
uses: actions/checkout@v4 | |
with: | |
ref: "gh-pages" | |
sparse-checkout: "docs-json" | |
- name: Update documentation | |
run: | | |
pnpm install -r --frozen-lockfile | |
pushd packages/$PACKAGE_NAME | |
npx typedoc --json ../../docs-json --options typedoc.json --validation.invalidLink | |
popd | |
npx typedoc --entrypointStrategy merge "docs-json/*.json" | |
- name: Deploy docs to GitHub Pages | |
if: success() | |
uses: crazy-max/ghaction-github-pages@v2 | |
with: | |
target_branch: gh-pages | |
build_dir: docs | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |