feat(release): enforce aligned trusted publications
This commit is contained in:
@@ -17,6 +17,10 @@ the regenerated release lockfile.
|
||||
Options:
|
||||
--npm <path> npm executable to use.
|
||||
--core-root <path> govoplan-core checkout. Defaults to ../govoplan-core.
|
||||
--local-git-repo <path>
|
||||
Resolve that repository's release tag from its local Git
|
||||
object store while preserving the published Git URL in
|
||||
the lockfile. May be repeated.
|
||||
-h, --help Show this help.
|
||||
USAGE
|
||||
}
|
||||
@@ -32,6 +36,7 @@ CORE_ROOT="$(cd "$CORE_ROOT" && pwd)"
|
||||
WEBUI="$CORE_ROOT/webui"
|
||||
NPM_BIN="${NPM:-}"
|
||||
NODE_BIN="${NODE:-}"
|
||||
LOCAL_GIT_REPOS=()
|
||||
|
||||
if [[ -z "$NPM_BIN" ]]; then
|
||||
if [[ -x "/home/zemion/.nvm/versions/node/v22.22.3/bin/npm" ]]; then
|
||||
@@ -61,6 +66,11 @@ while [[ $# -gt 0 ]]; do
|
||||
WEBUI="$CORE_ROOT/webui"
|
||||
shift 2
|
||||
;;
|
||||
--local-git-repo)
|
||||
[[ $# -ge 2 ]] || fail "missing value for $1"
|
||||
LOCAL_GIT_REPOS+=("$(cd "$2" && pwd)")
|
||||
shift 2
|
||||
;;
|
||||
-h|--help)
|
||||
usage
|
||||
exit 0
|
||||
@@ -90,9 +100,27 @@ fi
|
||||
|
||||
echo "Generating release lockfile from $WEBUI/package.release.json"
|
||||
echo "Temporary workspace: $TMP_DIR"
|
||||
|
||||
GIT_ENV=(env)
|
||||
git_config_count=0
|
||||
for local_repo in "${LOCAL_GIT_REPOS[@]}"; do
|
||||
[[ -d "$local_repo/.git" ]] || fail "local Git release source is not a repository: $local_repo"
|
||||
remote_url="$(git -C "$local_repo" remote get-url origin)"
|
||||
remote_url="${remote_url#git+}"
|
||||
if [[ "$remote_url" != *://* && "$remote_url" =~ ^([^@]+@)?([^:]+):(.+)$ ]]; then
|
||||
remote_url="ssh://${BASH_REMATCH[1]}${BASH_REMATCH[2]}/${BASH_REMATCH[3]}"
|
||||
fi
|
||||
GIT_ENV+=(
|
||||
"GIT_CONFIG_KEY_${git_config_count}=url.file://$local_repo/.insteadOf"
|
||||
"GIT_CONFIG_VALUE_${git_config_count}=$remote_url"
|
||||
)
|
||||
git_config_count=$((git_config_count + 1))
|
||||
done
|
||||
GIT_ENV+=("GIT_CONFIG_COUNT=$git_config_count")
|
||||
|
||||
(
|
||||
cd "$TMP_DIR"
|
||||
PATH="$(dirname "$NPM_BIN"):$PATH" "$NPM_BIN" install --package-lock-only --ignore-scripts
|
||||
"${GIT_ENV[@]}" PATH="$(dirname "$NPM_BIN"):$PATH" "$NPM_BIN" install --package-lock-only --ignore-scripts
|
||||
mapfile -t GIT_PACKAGES < <(
|
||||
PATH="$(dirname "$NODE_BIN"):$PATH" "$NODE_BIN" <<'NODE'
|
||||
const fs = require("fs");
|
||||
@@ -108,7 +136,7 @@ NODE
|
||||
)
|
||||
if [[ "${#GIT_PACKAGES[@]}" -gt 0 ]]; then
|
||||
echo "Refreshing git package lock entries: ${GIT_PACKAGES[*]}"
|
||||
PATH="$(dirname "$NPM_BIN"):$PATH" "$NPM_BIN" update --package-lock-only --ignore-scripts "${GIT_PACKAGES[@]}"
|
||||
"${GIT_ENV[@]}" PATH="$(dirname "$NPM_BIN"):$PATH" "$NPM_BIN" update --package-lock-only --ignore-scripts "${GIT_PACKAGES[@]}"
|
||||
fi
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user