spotify: Auto-commit on update

Also, replace tabs with spaces
This commit is contained in:
Tim Steinbach 2019-04-06 13:11:58 -04:00
parent 6bccbe6372
commit 55fa3c1180
No known key found for this signature in database
GPG Key ID: 6C654787275A64F1

View File

@ -29,10 +29,10 @@ spotify_nix="$nixpkgs/pkgs/applications/audio/spotify/default.nix"
# create bash array from snap info # create bash array from snap info
snap_info=($( snap_info=($(
curl -H 'X-Ubuntu-Series: 16' \ curl -H 'X-Ubuntu-Series: 16' \
"https://api.snapcraft.io/api/v1/snaps/details/spotify?channel=$channel" \ "https://api.snapcraft.io/api/v1/snaps/details/spotify?channel=$channel" \
| jq --raw-output \ | jq --raw-output \
'.revision,.download_sha512,.version,.last_updated' '.revision,.download_sha512,.version,.last_updated'
)) ))
# "revision" is the actual version identifier on snapcraft, the "version" is # "revision" is the actual version identifier on snapcraft, the "version" is
@ -50,8 +50,8 @@ echo "Latest $channel release is $upstream_version from $last_updated."
# #
current_nix_version=$( current_nix_version=$(
grep 'version\s*=' "$spotify_nix" \ grep 'version\s*=' "$spotify_nix" \
| sed -Ene 's/.*"(.*)".*/\1/p' | sed -Ene 's/.*"(.*)".*/\1/p'
) )
echo "Current nix version: $current_nix_version" echo "Current nix version: $current_nix_version"
@ -61,36 +61,28 @@ echo "Current nix version: $current_nix_version"
# #
if [[ "$current_nix_version" = "$upstream_version" ]]; then if [[ "$current_nix_version" = "$upstream_version" ]]; then
echo "Spotify is already up ot date" echo "Spotify is already up ot date"
exit 0 exit 0
fi fi
echo "Updating from ${current_nix_version} to ${upstream_version}, released on ${last_updated}" echo "Updating from ${current_nix_version} to ${upstream_version}, released on ${last_updated}"
# search-and-replace revision, hash and version # search-and-replace revision, hash and version
sed --regexp-extended \ sed --regexp-extended \
-e 's/rev\s*=\s*"[0-9]+"\s*;/rev = "'"${revision}"'";/' \ -e 's/rev\s*=\s*"[0-9]+"\s*;/rev = "'"${revision}"'";/' \
-e 's/sha512\s*=\s*"[^"]*"\s*;/sha512 = "'"${sha512}"'";/' \ -e 's/sha512\s*=\s*"[^"]*"\s*;/sha512 = "'"${sha512}"'";/' \
-e 's/version\s*=\s*".*"\s*;/version = "'"${upstream_version}"'";/' \ -e 's/version\s*=\s*".*"\s*;/version = "'"${upstream_version}"'";/' \
-i "$spotify_nix" -i "$spotify_nix"
# #
# try to build the updated version # try to build the updated version
# #
if ! nix-build -A spotify "$nixpkgs"; then if ! nix-build -A spotify "$nixpkgs"; then
echo "The updated spotify failed to build." echo "The updated spotify failed to build."
exit 1 exit 1
fi fi
# # Commit changes
# give instructions for upstreaming
#
git add "$spotify_nix" git add "$spotify_nix"
# show changes for review git commit -m "spotify: ${current_nix_version} -> ${upstream_version}"
git status
echo 'Please review and test the changes (./result/bin/spotify).'
echo 'Then stage the changes with `git add` and commit with:'
# prepare commit message
echo "git commit -m 'spotify: $current_nix_version -> $upstream_version'"