Publish to NPM and Website #124
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 to NPM and Website | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| dry_run: | |
| description: Perform a dry run | |
| type: boolean | |
| action: | |
| type: choice | |
| description: What to publish | |
| options: | |
| - npm | |
| - website | |
| pre_release: | |
| type: boolean | |
| description: Create a pre-release | |
| permissions: | |
| id-token: write # For NPM trusted publishing | |
| contents: write # For git commits of Changelog | |
| jobs: | |
| npm: | |
| name: NPM | |
| runs-on: ubuntu-latest | |
| if: github.event.inputs.action == 'npm' | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 # Needed for changelogs and tag comparison | |
| # Remove once setup-node supports corepack https://github.com/actions/setup-node/pull/901 lands | |
| - name: Set up PNPM | |
| uses: pnpm/action-setup@v4 | |
| with: | |
| run_install: false | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: lts/* | |
| cache: pnpm | |
| - name: Install dependencies | |
| run: pnpm install | |
| - name: Set commit author | |
| run: | | |
| git config --local user.name 'github-actions[bot]' | |
| git config --local user.email 'github-actions[bot]@users.noreply.github.com' | |
| # Ensure npm 11.5.1 or later is installed | |
| - name: Update npm | |
| run: | | |
| echo 'BEFORE' | |
| npm -v | |
| npm install -g npm@latest | |
| echo 'AFTER' | |
| npm -v | |
| - name: Publish to NPM | |
| if: github.event.inputs.pre_release != 'true' | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| if [ "${{ github.event.inputs.dry_run }}" == "true" ]; then | |
| pnpm run release --dry-run | |
| else | |
| pnpm run release --yes | |
| fi | |
| - name: Publish pre-release to NPM | |
| if: github.event.inputs.pre_release == 'true' | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| if [ "${{ github.event.inputs.dry_run }}" == "true" ]; then | |
| pnpm run prerelease --dry-run | |
| else | |
| pnpm run prerelease | |
| fi | |
| website: | |
| name: Directory website | |
| runs-on: ubuntu-latest | |
| if: github.event.inputs.action == 'website' | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| # Remove once setup-node supports corepack https://github.com/actions/setup-node/pull/901 lands | |
| - name: Set up PNPM | |
| uses: pnpm/action-setup@v4 | |
| with: | |
| run_install: false | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: lts/* | |
| cache: pnpm | |
| - name: Install dependencies | |
| run: pnpm install | |
| working-directory: packages/directory | |
| - name: Build directory | |
| working-directory: packages/directory | |
| run: | | |
| pnpm prepare | |
| pnpm run build | |
| - name: Publish static assets to GitHub Pages | |
| uses: JamesIves/github-pages-deploy-action@v4 | |
| with: | |
| branch: gh-pages | |
| folder: packages/directory/build |