diff --git a/tools/changelogger-release.sh b/tools/changelogger-release.sh index 25ac6f06855bc..4222f4fdf8b3d 100755 --- a/tools/changelogger-release.sh +++ b/tools/changelogger-release.sh @@ -161,7 +161,6 @@ if $ANY; then fi # Release the projects, in build order so we can force a release of something if one of its deps got updated. -declare -A RELEASED for SLUG in "${TO_RELEASE[@]}"; do cd "$BASE/projects/$SLUG" @@ -172,7 +171,6 @@ for SLUG in "${TO_RELEASE[@]}"; do fi info "Processing $SLUG..." - RELEASED[$SLUG]=1 # Avoid "There are no changes with content for this write. Proceed?" prompts and empty changelog entries. ANY=false @@ -224,6 +222,7 @@ for SLUG in "${TO_RELEASE[@]}"; do if [[ -z "$OLDVER" ]] || is_major_bump "$OLDVER" "$VER"; then debug " Version bump ${OLDVER:-none} -> $VER looks like a major bump, adding a change entry to dependents without one" for S in $( jq -r --arg slug "$SLUG" '.[$slug] // empty | .[]' <<<"$DEPTS" ); do + [[ "$S" == monorepo ]] && continue cd "$BASE/projects/$S" CHANGES_DIR=$(jq -r '.extra.changelogger["changes-dir"] // "changelog"' composer.json) if [[ ! -d "$CHANGES_DIR" || -z "$(ls -- "$CHANGES_DIR")" ]]; then @@ -251,25 +250,24 @@ done cd "$BASE" info "Updating dependencies..." -SLUGS=() -# Use a temp variable so pipefail works -TMP="$(pnpm jetpack dependencies build-order --pretty)" -mapfile -t SLUGS <<<"$TMP" - -TMPDIR="${TMPDIR:-/tmp}" -TEMP=$(mktemp "${TMPDIR%/}/changelogger-release-XXXXXXXX") - -for DEPENDENCY_SLUG in "${SLUGS[@]}"; do - if [[ -n "${RELEASED[$DEPENDENCY_SLUG]}" ]]; then - debug " tools/check-intra-monorepo-deps.sh $VERBOSE $RELEASEBRANCH -U $DEPENDENCY_SLUG" - PACKAGE_VERSIONS_CACHE="$TEMP" tools/check-intra-monorepo-deps.sh $VERBOSE $RELEASEBRANCH -U "$DEPENDENCY_SLUG" +debug " tools/check-intra-monorepo-deps.sh $VERBOSE $RELEASEBRANCH -U -P" +"$BASE"/tools/check-intra-monorepo-deps.sh $VERBOSE $RELEASEBRANCH -U -P +info "Adding changelog entries for unreleased projects..." +for DS in $( git -c core.quotepath=off diff --name-only projects | sed -e 's!^projects/\([^/]\+/[^/]\+\)/.*$!\1!' | sort -u ); do + cd "$BASE/projects/$DS" + if ! git diff --quiet ./CHANGELOG.md; then + debug " $DS is being released, no change entry needed" + elif ! git diff --quiet -- "./$( q -r '.extra.changelogger["changes-dir"] // "changelog"' composer.json )/"; then + debug " $DS already has an uncommitted change entry file, skipping" + elif ! git diff --quiet -- . ":!./composer.lock"; then + debug " $DS has non-lockfile changes" + changelogger_add 'Updated package dependencies.' else - debug " tools/check-intra-monorepo-deps.sh $VERBOSE $RELEASEBRANCH -u $DEPENDENCY_SLUG" - PACKAGE_VERSIONS_CACHE="$TEMP" tools/check-intra-monorepo-deps.sh $VERBOSE $RELEASEBRANCH -u "$DEPENDENCY_SLUG" + debug " $DS has lockfile changes only" + changelogger_add '' 'Updated composer.lock.' fi done - -rm "$TEMP" +cd "$BASE" debug " Updating pnpm.lock..." pnpm install --silent diff --git a/tools/check-intra-monorepo-deps.sh b/tools/check-intra-monorepo-deps.sh index e349b63e0d8cc..d5ec0a9434b8f 100755 --- a/tools/check-intra-monorepo-deps.sh +++ b/tools/check-intra-monorepo-deps.sh @@ -12,7 +12,7 @@ BASE=$PWD # Print help and exit. function usage { cat <<-EOH - usage: $0 [-a] [-n ] [-v] [-R] [-U|-u] [ ...] + usage: $0 [-a] [-n ] [-v] [-R] [-P] [-U|-u] [ ...] Check that all composer and pnpm dependencies between monorepo projects are up to date. @@ -28,6 +28,7 @@ function usage { -n: Set changelogger filename. -v: Output debug information. -R: When on a release branch, skip updating the corresponding plugins. + -P: Skip updating pnpm lockfile. Automatically skipped if is passed. EOH exit 1 } @@ -39,7 +40,8 @@ DOCL_EVER=true AUTO_SUFFIX=false CL_FILENAME= RELEASEBRANCH=false -while getopts ":uUvhHRan:" opt; do +DO_PNPM_LOCK=true +while getopts ":uUvhHRPan:" opt; do case ${opt} in u) UPDATE=true @@ -61,6 +63,9 @@ while getopts ":uUvhHRan:" opt; do # -H is an old name, kept for back compat. RELEASEBRANCH=true ;; + P) + DO_PNPM_LOCK=false + ;; h) usage ;; @@ -123,23 +128,15 @@ function get_packages { else PKGS=() fi - if [[ "$PACKAGES" == '{}' && -n "$PACKAGE_VERSIONS_CACHE" && -s "$PACKAGE_VERSIONS_CACHE" ]]; then - PACKAGES="$(<"$PACKAGE_VERSIONS_CACHE")" - else - for PKG in "${PKGS[@]}"; do - PACKAGES=$(jq -c --argjson packages "$PACKAGES" --arg ver "$(cd "${PKG%/composer.json}" && changelogger version current --default-first-version)" '.name as $k | $packages | .[$k] |= { rel: $ver, dep: ( "^" + $ver ) }' "$PKG") - done - if [[ -n "$PACKAGE_VERSIONS_CACHE" ]]; then - echo "$PACKAGES" > "$PACKAGE_VERSIONS_CACHE" - fi - fi + for PKG in "${PKGS[@]}"; do + PACKAGES=$(jq -c --argjson packages "$PACKAGES" --arg ver "$(cd "${PKG%/composer.json}" && changelogger version current --default-first-version)" '.name as $k | $packages | .[$k] |= { rel: $ver, dep: ( "^" + $ver ) }' "$PKG") + done JSPACKAGES=$(jq -nc 'reduce inputs as $in ({}; if $in.name then .[$in.name] |= [ "workspace:*" ] else . end )' "$BASE"/projects/js-packages/*/package.json) } get_packages -DO_PNPM_LOCK=true SLUGS=() if [[ $# -le 0 ]]; then # Use a temp variable so pipefail works