lidavidm commented on code in PR #4158: URL: https://github.com/apache/arrow-adbc/pull/4158#discussion_r3012678285
########## ci/scripts/node_npm_upload.sh: ########## @@ -18,21 +18,45 @@ # Publish Node.js packages to an npm registry. # +# For non-npmjs registries (e.g. Gemfury nightlies), the script appends a +# nightly date suffix to the version (e.g. 0.23.0-nightly.20260330) to avoid +# "version already exists" errors. +# # Usage: ./ci/scripts/node_npm_upload.sh <packages_dir> # # Environment variables: -# NPM_TOKEN npm authentication token (required) -# NPM_REGISTRY registry URL (default: https://registry.npmjs.org) -# NPM_TAG dist-tag to publish under (default: latest) -# DRY_RUN set to 1 to pass --dry-run to npm publish +# NPM_TOKEN npm authentication token (required) +# NPM_REGISTRY registry URL (default: https://registry.npmjs.org) +# NPM_TAG dist-tag to publish under (default: latest) +# DRY_RUN set to 1 to pass --dry-run to npm publish set -euo pipefail +# Prevent macOS tar from including ._* resource fork files +export COPYFILE_DISABLE=1 + +# Rewrite the "version" field in a tarball's package.json and repack it +repack_with_version() { + local pkg="$1" new_version="$2" + local tmpdir + tmpdir=$(mktemp -d) + tar -xzf "${pkg}" -C "${tmpdir}" + sed -i.bak "s/\"version\": *\"[^\"]*\"/\"version\": \"${new_version}\"/" "${tmpdir}/package/package.json" + rm -f "${tmpdir}/package/package.json.bak" + tar -czf "${pkg}" -C "${tmpdir}" package + rm -rf "${tmpdir}" +} + +# Read the "version" field from a tarball's package.json +read_tarball_version() { + tar -xzf "$1" -O package/package.json | grep -o '"version": *"[^"]*"' | head -1 | cut -d'"' -f4 Review Comment: You can probably assume the presence of `jq` in CI, but this works too -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
