Skip to content

Commit

Permalink
Add experimental package update scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
Deraen committed Mar 2, 2019
1 parent f50b1bd commit b2780c5
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 0 deletions.
30 changes: 30 additions & 0 deletions update-package.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/bash

name=$1
old_version=$2
new_version=$3

(
cd "$name" || exit

sed -i "s/$old_version/$new_version/" build.boot

package_json=$(curl -sS "https://unpkg.com/$name@$new_version/package.json")
scm=$(echo "$package_json" | jq -r '.repository.url')
regex='https://github.com/([^/]*)/([^/]*)'
[[ $scm =~ $regex ]] && organisation=${BASH_REMATCH[1]}

changelog=$(curl -sS "https://raw.githubusercontent.com/$organisation/$name/master/CHANGELOG.md" | sed "/^## $new_version/,/^## .*/!d;//d")

message="Update $name to $new_version\n\n## $old_version => $new_version\n$changelog"

# FIXME: Need way to automatically accept changed checksums
boot package

git add build.boot boot-cljsjs-checksums.edn

git checkout -b "$name-$new_version"
git commit -m "$(echo -e "$message")"
git push origin HEAD
# TODO: Open pull request
)
38 changes: 38 additions & 0 deletions update-packages.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/bin/bash

for x in *; do
if [[ -d $x ]]; then
if [[ ! -f $x/build.boot ]]; then
continue
fi
if [[ -f $x/disabled ]]; then
continue
fi

# Skip packages not using unpkg
if ! grep -q "unpkg.com" "$x/build.boot"; then
continue
fi

artifact=${x//_[0-9]*/}
# Skip old versions of packages, like jquery_1 or react_15
if [[ "$x" != "$artifact" ]]; then
continue
fi

lib_version=$(grep "def +lib-version+" "$x/build.boot" | grep -o "\".*\"" | head -n1 | cut -d \" -f 2)

location=$(curl -s --head "https://unpkg.com/$artifact/" | grep location:)
latest_version=$(echo "$location" | grep -o "@[0-9.]*" | cut -c2-)

if [[ $latest_version = "" ]]; then
# if no response, e.g. folder name doesn't match unpkg, skip for now
continue
fi

if [[ "$lib_version" != "$latest_version" ]]; then
echo "$x, packaged lib version $lib_version, latest is $latest_version"
./update-package.sh "$x" "$lib_version" "$latest_version"
fi
fi
done

0 comments on commit b2780c5

Please sign in to comment.