diff --git a/.github/workflows/proxy_integration_tests.yml b/.github/workflows/proxy_integration_tests.yml index 938e47b..a7569e7 100644 --- a/.github/workflows/proxy_integration_tests.yml +++ b/.github/workflows/proxy_integration_tests.yml @@ -42,6 +42,11 @@ jobs: - name: Run typecheck run: npm run test:types + - name: Check npm and JSR package contents + run: | + npm pack --dry-run + npx --yes jsr publish --dry-run + - name: Require PROXY_URL Actions secret env: PROXY_URL: ${{ secrets.PROXY_URL }} diff --git a/scripts/check-version.sh b/scripts/check-version.sh new file mode 100755 index 0000000..b063b09 --- /dev/null +++ b/scripts/check-version.sh @@ -0,0 +1,36 @@ +#!/usr/bin/env bash +# Check that package.json, package-lock.json and jsr.json carry the same +# version, and that a release/X.Y.Z branch carries version X.Y.Z. +# scripts/lint.sh runs this; on pull requests the branch comes from +# GITHUB_HEAD_REF. + +set -euo pipefail + +err() { + echo "$*" >&2 +} + +# Print the "version" field of a JSON file. +version_of() { + node -p "require('./$1').version" +} + +main() { + cd "$(git rev-parse --show-toplevel)" + local version file other branch + version="$(version_of package.json)" + for file in package-lock.json jsr.json; do + other="$(version_of "${file}")" + if [[ "${other}" != "${version}" ]]; then + err "${file} version ${other} != package.json version ${version}" + exit 1 + fi + done + branch="${GITHUB_HEAD_REF:-$(git rev-parse --abbrev-ref HEAD)}" + if [[ "${branch}" == release/* && "${branch#release/}" != "${version}" ]]; then + err "branch ${branch} != package.json version ${version}" + exit 1 + fi +} + +main "$@" diff --git a/scripts/lint.sh b/scripts/lint.sh index 2d7bf13..6fab8a2 100755 --- a/scripts/lint.sh +++ b/scripts/lint.sh @@ -45,6 +45,7 @@ main() { fi check shellcheck shellcheck "${sh_files[@]}" check shfmt shfmt -d -i 2 -ci "${sh_files[@]}" + check version scripts/check-version.sh check eslint npm run lint --silent if ((${#failed[@]} > 0)); then