forked from NixOS/nixpkgs
-
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.
Co-authored-by: Sandro <[email protected]> Signed-off-by: phanirithvij <[email protected]>
- Loading branch information
1 parent
e89738c
commit cb8dd4a
Showing
2 changed files
with
85 additions
and
18 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
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,61 @@ | ||
#!/usr/bin/env nix-shell | ||
#!nix-shell -i bash -p bash curl coreutils jq git prefetch-npm-deps moreutils common-updater-scripts common-updater-scripts | ||
|
||
# shellcheck shell=bash | ||
|
||
set -eou pipefail | ||
|
||
NIXPKGS_DIR="$PWD" | ||
SCRIPT_DIR="$(dirname "${BASH_SOURCE[0]}")" | ||
|
||
# Get latest release | ||
OPENGIST_RELEASE=$( | ||
curl --silent ${GITHUB_TOKEN:+-u ":$GITHUB_TOKEN"} \ | ||
https://api.github.com/repos/thomiceli/opengist/releases/latest | ||
) | ||
|
||
# Get release information | ||
latestVersion=$(echo "$OPENGIST_RELEASE" | jq -r ".tag_name") | ||
latestVersion="${latestVersion:1}" # remove first char 'v' | ||
|
||
oldVersion=$(nix eval --raw -f "$NIXPKGS_DIR" opengist.version) | ||
|
||
if [[ "$oldVersion" == "$latestVersion" ]]; then | ||
echo "opengist is up-to-date: ${oldVersion}" | ||
exit 0 | ||
fi | ||
|
||
echo "Updating opengist $oldVersion -> $latestVersion" | ||
|
||
update-source-version opengist "${latestVersion}" | ||
|
||
pushd "$SCRIPT_DIR" >/dev/null || exit 1 | ||
|
||
## npm hash | ||
rm -f package{,-lock}.json | ||
curl -sLO "https://raw.githubusercontent.com/thomiceli/opengist/refs/tags/v$latestVersion/package-lock.json" | ||
|
||
npmDepsHash="$(prefetch-npm-deps package-lock.json)" | ||
sed -E 's#\bnpmDepsHash = ".*?"#npmDepsHash = "'"$npmDepsHash"'"#' --in-place package.nix | ||
|
||
popd >/dev/null | ||
|
||
# nix-prefetch broken due to ninja finalAttrs.src.rev | ||
# nix-update with goModules broken for this package | ||
|
||
setKV () { | ||
sed -i "s|$1 = \".*\"|$1 = \"${2:-}\"|" "${SCRIPT_DIR}/package.nix" | ||
} | ||
|
||
setKV vendorHash "sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=" # The same as lib.fakeHash | ||
|
||
set +e | ||
VENDOR_HASH=$(nix-build --no-out-link -A opengist "$NIXPKGS_DIR" 2>&1 >/dev/null | grep "got:" | cut -d':' -f2 | sed 's| ||g') | ||
set -e | ||
|
||
if [ -n "${VENDOR_HASH:-}" ]; then | ||
setKV vendorHash "${VENDOR_HASH}" | ||
else | ||
echo "Update failed. VENDOR_HASH is empty." | ||
exit 1 | ||
fi |