From 9998b5e66de43d17b1178965863127d7f0d798c0 Mon Sep 17 00:00:00 2001 From: Jason Karns Date: Wed, 23 Jul 2025 14:13:09 -0400 Subject: [PATCH 1/4] Update preversion checkscript from node-build --- script/preversion | 74 ++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 63 insertions(+), 11 deletions(-) diff --git a/script/preversion b/script/preversion index 98c03c05..71088685 100755 --- a/script/preversion +++ b/script/preversion @@ -1,29 +1,81 @@ #!/usr/bin/env bash -# Usage: script/release-precheck +# +# Ensures repo is ready to release. +# +# Usage: script/preversion [-v] [--] [FILES...] +# +# Options: +# -o Detect unreleased changes in (and only in) FILES +# -v Print log since last tag +# FILES Files to check for changes. +# [default: package.json#files read via $npm_package_files_*] # # - fetch from origin # - ensure it isn't already tagged -# - ensure currently on master branch +# - ensure currently on main branch # - ensure there are bin or definition changes to release set -euo pipefail -git fetch --quiet --tags origin master +[ -n "${DEBUG-}" ] && set -x + +unset verbose strict +while getopts "ov" opt; do + case "$opt" in + o) strict=1 ;; + v) verbose=1 ;; + *) break ;; + esac +done +shift $((OPTIND-1)) + +if [ "${1-}" = -- ]; then + shift +fi + +abort() { + echo "Aborting: $1" >&2 + exit "${2:-1}" +} + +declare -a files +if [ "$#" -gt 0 ]; then + files=("$@") +else + for file in $(env | grep -E '^npm_package_files_\d' | cut -d= -f1); do + files+=("${!file}") + done +fi + +git fetch --quiet --tags origin main existing="$(git tag --points-at HEAD)" if [ -n "$existing" ]; then - echo "Aborting: HEAD is already tagged as '${existing}'" >&2 - exit 1 + abort "HEAD is already tagged as '${existing}'" fi current_branch="$(git symbolic-ref --short HEAD)" -if [ "$current_branch" != master ]; then - echo "Aborting: Not currently on master branch" >&2 - exit 1 +if [ "$current_branch" != main ]; then + abort "Not currently on main branch" 2 fi previous_tag="$(git describe --tags --abbrev=0)" -if git diff --quiet "${previous_tag}..HEAD" -- bin share; then - echo "Aborting: No features to release since '${previous_tag}'" >&2 - exit 1 +if git diff --quiet "${previous_tag}..HEAD" -- "${files[@]}"; then + abort "No features to release since '${previous_tag}'" +fi + +allowed_changes=( "${files[@]}" .github script *.md ) +allowed_changes=( "${allowed_changes[@]/#/\':!\'}" ) # prefix pathspecs with git's "ignore" + +if [ -n "${strict-}" ] && + ! git diff --quiet "${previous_tag}..HEAD" -- "${allowed_changes[@]}"; then + { + echo "git diff --stat ${previous_tag}..HEAD -- ${allowed_changes[*]}" + git diff --stat "${previous_tag}..HEAD" -- "${allowed_changes[@]}" + } >&2 + abort "Changes detected outside '${allowed_changes[*]#:!}'" 2 +fi + +if [ -n "${verbose-}" ]; then + git log "$previous_tag"... --oneline -- "${files[@]}" fi From a71498659efaf01eaa4e6ddf7f913aa5412369b1 Mon Sep 17 00:00:00 2001 From: Jason Karns Date: Wed, 23 Jul 2025 14:25:43 -0400 Subject: [PATCH 2/4] npm broke npm_package_files variable --- script/preversion | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/script/preversion b/script/preversion index 71088685..1bdb9b42 100755 --- a/script/preversion +++ b/script/preversion @@ -42,9 +42,7 @@ declare -a files if [ "$#" -gt 0 ]; then files=("$@") else - for file in $(env | grep -E '^npm_package_files_\d' | cut -d= -f1); do - files+=("${!file}") - done + IFS=" " read -r -a files <<<"$(node -p 'require("./package").files.join(" ")')" fi git fetch --quiet --tags origin main From ec12185035bfe149ec61f8bb5598464b2ee97f8f Mon Sep 17 00:00:00 2001 From: Jason Karns Date: Wed, 23 Jul 2025 14:26:44 -0400 Subject: [PATCH 3/4] shfmt --- script/preversion | 46 +++++++++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/script/preversion b/script/preversion index 1bdb9b42..f33dfc45 100755 --- a/script/preversion +++ b/script/preversion @@ -21,59 +21,59 @@ set -euo pipefail unset verbose strict while getopts "ov" opt; do - case "$opt" in - o) strict=1 ;; - v) verbose=1 ;; - *) break ;; - esac + case "$opt" in + o) strict=1 ;; + v) verbose=1 ;; + *) break ;; + esac done -shift $((OPTIND-1)) +shift $((OPTIND - 1)) if [ "${1-}" = -- ]; then - shift + shift fi abort() { - echo "Aborting: $1" >&2 - exit "${2:-1}" + echo "Aborting: $1" >&2 + exit "${2:-1}" } declare -a files if [ "$#" -gt 0 ]; then - files=("$@") + files=("$@") else - IFS=" " read -r -a files <<<"$(node -p 'require("./package").files.join(" ")')" + IFS=" " read -r -a files <<<"$(node -p 'require("./package").files.join(" ")')" fi git fetch --quiet --tags origin main existing="$(git tag --points-at HEAD)" if [ -n "$existing" ]; then - abort "HEAD is already tagged as '${existing}'" + abort "HEAD is already tagged as '${existing}'" fi current_branch="$(git symbolic-ref --short HEAD)" if [ "$current_branch" != main ]; then - abort "Not currently on main branch" 2 + abort "Not currently on main branch" 2 fi previous_tag="$(git describe --tags --abbrev=0)" if git diff --quiet "${previous_tag}..HEAD" -- "${files[@]}"; then - abort "No features to release since '${previous_tag}'" + abort "No features to release since '${previous_tag}'" fi -allowed_changes=( "${files[@]}" .github script *.md ) -allowed_changes=( "${allowed_changes[@]/#/\':!\'}" ) # prefix pathspecs with git's "ignore" +allowed_changes=("${files[@]}" .github script *.md) +allowed_changes=("${allowed_changes[@]/#/\':!\'}") # prefix pathspecs with git's "ignore" if [ -n "${strict-}" ] && - ! git diff --quiet "${previous_tag}..HEAD" -- "${allowed_changes[@]}"; then - { - echo "git diff --stat ${previous_tag}..HEAD -- ${allowed_changes[*]}" - git diff --stat "${previous_tag}..HEAD" -- "${allowed_changes[@]}" - } >&2 - abort "Changes detected outside '${allowed_changes[*]#:!}'" 2 + ! git diff --quiet "${previous_tag}..HEAD" -- "${allowed_changes[@]}"; then + { + echo "git diff --stat ${previous_tag}..HEAD -- ${allowed_changes[*]}" + git diff --stat "${previous_tag}..HEAD" -- "${allowed_changes[@]}" + } >&2 + abort "Changes detected outside '${allowed_changes[*]#:!}'" 2 fi if [ -n "${verbose-}" ]; then - git log "$previous_tag"... --oneline -- "${files[@]}" + git log "$previous_tag"... --oneline -- "${files[@]}" fi From 6972cfb4de7a2a0c9e5b76753ff856952552819c Mon Sep 17 00:00:00 2001 From: Jason Karns Date: Wed, 23 Jul 2025 14:29:27 -0400 Subject: [PATCH 4/4] readme badges --- README.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index af7b6589..0bfb9b88 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,12 @@ # node-build-prerelease -[![Build Status](https://travis-ci.org/nodenv/node-build-prerelease.svg?branch=master)](https://travis-ci.org/nodenv/node-build-prerelease) - node-build-prerelease is an [nodenv][] plugin (or more precisely, a [node-build][] plugin) that provides build definitions for Node.js prereleases (primarily release candidates). +[![Tests](https://img.shields.io/github/actions/workflow/status/nodenv/node-build-prerelease/test.yml?label=tests&logo=github)](https://github.com/nodenv/node-build-prerelease/actions/workflows/test.yml) +[![Latest Homebrew Release]()](https://github.com/nodenv/homebrew-nodenv/blob/main/Formula/node-build-prerelease.rb) +[![Latest GitHub Release](https://img.shields.io/github/v/release/nodenv/node-build-prerelease?label=github&logo=github&sort=semver)](https://github.com/nodenv/node-build-prerelease/releases/latest) +[![Latest npm Release](https://img.shields.io/npm/v/@nodenv/node-build-prerelease?logo=npm&logoColor=white)](https://www.npmjs.com/package/@nodenv/node-build-prerelease/v/latest) + - [Installation](#installation)