Build #214
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: Build | |
| on: | |
| pull_request: | |
| merge_group: | |
| types: [checks_requested] | |
| workflow_call: | |
| inputs: | |
| ref: | |
| description: Git ref to checkout | |
| required: false | |
| type: string | |
| default: '' | |
| verify_dist: | |
| description: Fail if a fresh build changes committed output | |
| required: false | |
| type: boolean | |
| default: false | |
| concurrency: | |
| group: build-${{ github.event.pull_request.number || github.ref }} | |
| cancel-in-progress: true | |
| permissions: | |
| contents: read | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | |
| with: | |
| ref: ${{ inputs.ref }} | |
| fetch-depth: 0 | |
| - name: Setup pnpm | |
| uses: pnpm/action-setup@26f6d4f2c533a43e6b5da0b4a5dd983f98f7b49a # v6.0.4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0 | |
| with: | |
| node-version-file: '.nvmrc' | |
| cache: pnpm | |
| - name: Install dependencies | |
| run: pnpm install --frozen-lockfile | |
| - name: Build actions | |
| run: pnpm build | |
| - name: Should verify dist gate | |
| id: should_verify_dist | |
| env: | |
| VERIFY_DIST_INPUT: ${{ inputs.verify_dist }} | |
| EVENT_NAME: ${{ github.event_name }} | |
| HEAD_REPO: ${{ github.event.pull_request.head.repo.full_name || '' }} | |
| HEAD_REF: ${{ github.head_ref || '' }} | |
| MERGE_GROUP_BASE_REF: ${{ github.event.merge_group.base_ref || '' }} | |
| run: | | |
| read_package_version_from_ref() { | |
| git show "$1:package.json" | jq -r '.version' | |
| } | |
| should_verify=false | |
| if [ "${VERIFY_DIST_INPUT}" = 'true' ]; then | |
| should_verify=true | |
| elif [ "${EVENT_NAME}" = 'pull_request' ] && | |
| [ "${HEAD_REPO}" = "${GITHUB_REPOSITORY}" ] && | |
| [[ "${HEAD_REF}" == release/* ]]; then | |
| should_verify=true | |
| elif [ "${EVENT_NAME}" = 'merge_group' ] && | |
| [ "${MERGE_GROUP_BASE_REF}" = 'refs/heads/master' ]; then | |
| git fetch origin master | |
| HEAD_VERSION="$(read_package_version_from_ref 'HEAD')" | |
| BASE_VERSION="$(read_package_version_from_ref 'origin/master')" | |
| if [ "${HEAD_VERSION}" != "${BASE_VERSION}" ]; then | |
| should_verify=true | |
| fi | |
| fi | |
| echo "should_verify=${should_verify}" >> "${GITHUB_OUTPUT}" | |
| - name: Verify committed dist output | |
| if: ${{ steps.should_verify_dist.outputs.should_verify == 'true' }} | |
| run: | | |
| mapfile -t CHANGED_FILES < <(git ls-files --modified --deleted --others --exclude-standard) | |
| if [ "${#CHANGED_FILES[@]}" -eq 0 ]; then | |
| exit 0 | |
| fi | |
| echo "::error::Committed dist output is stale. Run `pnpm build` and commit generated files." >&2 | |
| printf '%s\n' "${CHANGED_FILES[@]}" >&2 | |
| exit 1 |