Skip to content

Instantly share code, notes, and snippets.

@RobjS
Created May 31, 2024 15:21
Show Gist options
  • Save RobjS/353d463a8c2d2aa32051b33c6c1f4e53 to your computer and use it in GitHub Desktop.
Save RobjS/353d463a8c2d2aa32051b33c6c1f4e53 to your computer and use it in GitHub Desktop.
A script to pin all plugins in existing Whippet apps to their latest major version
#!/usr/bin/env bash
# Get all app repos
repos=($(govpress repo list | jq '.Repos[]' -r))
# Generate the report file
touch report.txt
# For each, clone the repo and run whippet deps update
for repo in "${repos[@]}"; do
repo_name="[email protected]:$repo"
echo $repo_name
git clone "$repo_name" this_repo
echo "$repo_name" >> report.txt
cd this_repo
git checkout -b chore/pin-plugins-to-major-version-tags
whippet deps update
whippet_plugins=($( cat whippet.json | jq .'plugins[].name' -r))
# Then work out the major version tag for each plugin not already pinned to a ref
cd wp-content/plugins
for plugin in "${whippet_plugins[@]}"; do
cd $plugin
tags=($(git tag --points-at HEAD))
major_tag=""
for tag in "${tags[@]}"; do
if [[ $tag =~ ^[v][0-9]+$ ]]; then
echo "Major version tag for $plugin is $tag"
echo "$plugin: $tag" >> ../../../../report.txt
major_tag="$tag"
break
fi
done
if [[ $major_tag == "" ]]; then
echo "No major version found for $plugin"
echo "$plugin: No major tag found" >> ../../../../report.txt
fi
cd ../
done
cd ../../../
echo "" >> report.txt
rm -rf this_repo
# Then add those tags to the whippet.json file
# Then run whippet deps update again, to update the has ref in the lock file
# The commit the changes to whippet.lock and whippet.json
# Then push the branch and open a PR
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment