-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(pcs): move to nix-update-script
- Loading branch information
Showing
5 changed files
with
70 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -68,6 +68,7 @@ rec { | |
nix-prefetch-git | ||
nix-prefetch-github | ||
nix-prefetch-scripts | ||
nix-update | ||
]; | ||
}; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#!/usr/bin/env -S nix develop .#update -c bash | ||
|
||
ARGS=("$@") | ||
|
||
getLatest() { | ||
type="$1" | ||
owner="$2" | ||
repo="$3" | ||
|
||
case "$type" in | ||
release) | ||
curl -s "https://api.github.com/repos/$owner/$repo/releases/latest" | jq -r .tag_name | ||
;; | ||
|
||
prerelease) | ||
curl -s "https://api.github.com/repos/$owner/$repo/releases" | | ||
jq -r 'map(.tag_name)[]' | | ||
sort -r | | ||
head -n 1 | ||
;; | ||
esac | ||
} | ||
|
||
updatePackage() { | ||
versionType="$1" | ||
owner="$2" | ||
repo="$3" | ||
|
||
current_version=$(nix eval --raw ".#$repo.version") | ||
new_version=$(getLatest "$versionType" "$owner" "$repo") | ||
|
||
if [[ "$new_version" != "$current_version" ]]; then | ||
updateGems | ||
|
||
nix-update --version "$new_version" --flake pcs "${ARGS[@]}" | ||
fi | ||
} | ||
|
||
updatePackage "prerelease" "ClusterLabs" "pcs" # TODO: move to release once 0.12 comes out |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,81 +1,25 @@ | ||
#!/usr/bin/env -S nix develop .#update -c bash | ||
|
||
COMMIT="$1" | ||
ROOT_DIR="$(pwd)" | ||
|
||
git_push() { | ||
if [[ "$COMMIT" == "--commit" ]]; then | ||
( | ||
cd "$ROOT_DIR" || return | ||
git config --global user.name 'Updater' | ||
git config --global user.email 'robot@nowhere.invalid' | ||
git remote update | ||
|
||
alejandra . | ||
git add . | ||
|
||
git commit -m "$1" | ||
git push | ||
) | ||
else | ||
echo "$1" | ||
fi | ||
} | ||
|
||
updateRubyDeps() { | ||
updateGems | ||
git_push "chore: update ruby deps" | ||
updatePackage() { | ||
script="$(nix eval --raw .#"$1".updateScript)" | ||
$script "${@:2}" | ||
} | ||
getLatest() { | ||
type="$1" | ||
owner="$2" | ||
repo="$3" | ||
|
||
case "$type" in | ||
release) | ||
curl -s "https://api.github.com/repos/$owner/$repo/releases/latest" | jq -r .tag_name | ||
;; | ||
|
||
prerelease) | ||
curl -s "https://api.github.com/repos/$owner/$repo/releases" | | ||
jq -r 'map(.tag_name)[]' | | ||
sort -r | | ||
head -n 1 | ||
;; | ||
esac | ||
} | ||
if [[ "$1" == "--commit" ]]; then | ||
git config --global user.name 'github-actions[bot]' | ||
git config --global user.email '41898282+github-actions[bot]@users.noreply.github.com' | ||
updatePackage() { | ||
nix flake update | ||
versionType="$1" | ||
owner="$2" | ||
repo="$3" | ||
file="$ROOT_DIR/pkgs/$repo/src.nix" | ||
|
||
current_version=$(nix eval --json --file "$file" | jq -r .rev) | ||
new_version=$(getLatest "$versionType" "$owner" "$repo") | ||
|
||
if [[ "$new_version" != "$current_version" ]]; then | ||
hash=$(nix-prefetch-github "$owner" "$repo" --rev "$new_version" | | ||
jq -r .hash) | ||
|
||
{ | ||
echo '# This file was autogenerated. DO NOT EDIT!' | ||
echo '{' | ||
echo " owner = \"$owner\";" | ||
echo " repo = \"$repo\";" | ||
echo " rev = \"$new_version\";" | ||
echo " hash = \"$hash\";" | ||
echo '}' | ||
} >"$file" | ||
|
||
git_push "ci: $repo $current_version -> $new_version" | ||
else | ||
echo "$repo is already up to date" | ||
fi | ||
} | ||
|
||
updateRubyDeps | ||
updatePackage "prerelease" "ClusterLabs" "pcs" # TODO: move to release once 0.12 comes out | ||
updatePackage "pacemaker" --commit | ||
updatePackage "pcs" --commit | ||
updatePackage "pcs-web-ui" --commit | ||
updatePackage "resource-agents" --commit | ||
git restore . | ||
else | ||
updatePackage "pacemaker" | ||
updatePackage "pcs" | ||
updatePackage "pcs-web-ui" | ||
updatePackage "resource-agents" | ||
fi |