diff --git a/ci-tools/update-nixpkgs b/ci-tools/update-nixpkgs index a017c2d1ea5f961eefa7c3c365c480f7d77130f2..77d8e3bf4c6dd88950b622fed14cd2e1add95ae3 100755 --- a/ci-tools/update-nixpkgs +++ b/ci-tools/update-nixpkgs @@ -6,6 +6,7 @@ # we need git to commit and push our changes # we need openssh for ssh-agent to authenticate the push # we need curl to create the gitlab MR +# we need python to format the data as json set -eux -o pipefail @@ -29,30 +30,28 @@ setup_ssh() { setup_git() { git config --global user.email "update-bot@private.storage" git config --global user.name "Update Bot" - git remote remove origin || true - git remote add origin "gitlab@${HOST}:PrivateStorage/PrivateStorageio.git" } setup_ssh setup_git -export TARGET_BRANCH="nixpkgs-upgrade-$(date +%Y-%m-%d)" +export SOURCE_BRANCH="nixpkgs-upgrade-$(date +%Y-%m-%d)" + +# Avoid messing with the checkout we're running from. +git clone . working-copy +cd working-copy +git branch -D "${SOURCE_BRANCH}" || true +git checkout -B "${SOURCE_BRANCH}" origin/develop echo '{}' > morph/grid/local/public-keys/users.nix nix-build -A morph -o result-before -git branch -D "${TARGET_BRANCH}" || true -git checkout -b "${TARGET_BRANCH}" - # Spawn *another* nix-shell that has the *other* update-nixpkgs tool. Should # sort out this mess sooner rather than later... -nix-shell ./shell.nix --run 'update-nixpkgs' - -git fetch origin develop -git branch -a +nix-shell ../shell.nix --run 'update-nixpkgs ./nixpkgs.json' # Show us what we did -if git diff --exit-code origin/develop...; then +if git diff --exit-code; then echo "No changes." exit 0 fi @@ -61,13 +60,13 @@ nix-build -A morph -o result-after DIFF=$(nix --extra-experimental-features nix-command store diff-closures ./result-before/ ./result-after/) git commit -am "bump nixpkgs version" -git push --force origin "${TARGET_BRANCH}:${TARGET_BRANCH}" +git push --force origin "${SOURCE_BRANCH}:${SOURCE_BRANCH}" BODY=$(python3 -c ' import os, sys, json print(json.dumps({ "id": os.environ["CI_PROJECT_ID"], - "source_branch": os.environ["TARGET_BRANCH"], + "source_branch": os.environ["SOURCE_BRANCH"], "target_branch": "develop", "remove_source_branch": True, "title": "bump nixpkgs version",