Publish React Viewer Lib #50
Workflow file for this run
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 React Viewer Lib | |
| on: | |
| push: | |
| tags: | |
| - "[0-9]+.[0-9]+.[0-9]+" | |
| workflow_dispatch: | |
| inputs: | |
| dry-run: | |
| description: "Run in dry-run mode (don't actually publish)" | |
| required: false | |
| type: boolean | |
| default: true | |
| prerelease: | |
| description: "Publish as pre-release (beta)" | |
| required: false | |
| type: boolean | |
| default: false | |
| jobs: | |
| publish: | |
| name: Publish to NPM | |
| runs-on: ubuntu-latest | |
| environment: npm | |
| defaults: | |
| run: | |
| working-directory: src/inspect_ai/_view/ts-mono/apps/inspect | |
| permissions: | |
| contents: read | |
| id-token: write | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v7 | |
| with: | |
| fetch-depth: 0 | |
| submodules: recursive | |
| - uses: pnpm/action-setup@v6 | |
| with: | |
| package_json_file: src/inspect_ai/_view/ts-mono/package.json | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v6 | |
| with: | |
| node-version: "22.x" | |
| registry-url: "https://registry.npmjs.org" | |
| cache: pnpm | |
| cache-dependency-path: src/inspect_ai/_view/ts-mono/pnpm-lock.yaml | |
| - name: Upgrade npm (for Trusted Publishing) | |
| run: | | |
| # Install via prefix to avoid npm self-upgrade rebuild bug on Node 22. | |
| npm install --prefix "$RUNNER_TEMP/npm-upgrade" --no-audit --no-fund npm@^11.5.1 | |
| echo "$RUNNER_TEMP/npm-upgrade/node_modules/.bin" >> "$GITHUB_PATH" | |
| "$RUNNER_TEMP/npm-upgrade/node_modules/.bin/npm" --version | |
| - name: Install dependencies | |
| working-directory: src/inspect_ai/_view/ts-mono | |
| run: pnpm install --frozen-lockfile | |
| # Must run before publish: the submodule has no tags, so we resolve | |
| # the version from the parent repo and write it into package.json. | |
| # prepublishOnly in package.json expects this has already been done. | |
| - name: Sync version from git tag | |
| run: | | |
| VERSION=$(git -C ${{ github.workspace }} describe --tags --abbrev=0 --match='[0-9]*.[0-9]*.[0-9]*') | |
| npm version "$VERSION" --no-git-tag-version | |
| - name: Bump to prerelease version | |
| if: ${{ inputs.prerelease }} | |
| run: | | |
| CURRENT_VERSION=$(node -p "require('./package.json').version") | |
| TIMESTAMP=$(date +%s) | |
| npm version patch --no-git-tag-version | |
| NEW_VERSION=$(node -p "require('./package.json').version") | |
| npm version "${NEW_VERSION}-beta.${TIMESTAMP}" --no-git-tag-version | |
| - name: Run quality checks | |
| working-directory: src/inspect_ai/_view/ts-mono | |
| run: pnpm --filter inspect check-all | |
| - name: Build library for prerelease | |
| if: ${{ inputs.prerelease }} | |
| working-directory: src/inspect_ai/_view/ts-mono | |
| run: pnpm --filter inspect build:lib | |
| - name: Publish to NPM (dry-run) | |
| if: ${{ inputs.dry-run }} | |
| run: npm publish --dry-run --access public ${{ inputs.prerelease && '--tag beta --ignore-scripts' || '' }} | |
| - name: Publish to NPM | |
| if: ${{ !inputs.dry-run }} | |
| run: npm publish --access public ${{ inputs.prerelease && '--tag beta --ignore-scripts' || '' }} |