Merge pull request #191 from nix-community/feature/create-json

update-nur-search.sh: add script to deploy package.json
This commit is contained in:
Jörg Thalheim 2020-03-12 16:20:55 +00:00 committed by GitHub
commit bfe65e9b65
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 131 additions and 89 deletions

View file

@ -1,3 +1,24 @@
language: nix
script:
- bash ci/deploy.sh
notifications:
irc:
on_success: change
on_failure: always
channels:
- "irc.freenode.net#nixos-nur"
template:
- "%{result} - %{branch} \"%{commit_subject}\" %{build_url}"
jobs:
include:
- name: test pull request
script: bash ci/test.sh
if: type = pull_request
- name: update nur / nur-combined
script: bash ci/update-nur.sh
if: branch = master AND type != pull_request
- name: update nur-search/data/packages.json
script: ci/update-nur-search.sh
if: branch = master AND type != pull_request

View file

@ -134,9 +134,11 @@ in
## Finding packages
At the moment we do not have a dedicated package search available. However our
[nur-combined](https://github.com/nix-community/nur-combined) repository contains all
nix expressions from all users and can be search via
You can find all packages using
[Packages search for NUR](https://nix-community.github.io/nur-search/)
or search our
[nur-combined](https://github.com/nix-community/nur-combined)
repository, which contains all nix expressions from all users, via
[github](https://github.com/nix-community/nur-combined/search).
## How to add your own repository.

View file

@ -1,66 +0,0 @@
#!/usr/bin/env bash
set -eu -o pipefail # Exit with nonzero exit code if anything fails
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
is-automatic-update() {
[[ "$TRAVIS_EVENT_TYPE" == "cron" ]] || [[ "$TRAVIS_EVENT_TYPE" == "api" ]]
}
if is-automatic-update; then
keys_dir=$(mktemp -d)
openssl aes-256-cbc \
-K $encrypted_080f214a372c_key \
-iv $encrypted_080f214a372c_iv \
-in ci/keys.tar.gz.enc -out ci/keys.tar.gz -d
tar -C "$keys_dir" -xzvf ci/keys.tar.gz
eval "$(ssh-agent -s)"
chmod 600 "${keys_dir}/ssh-key"
ssh-add "${keys_dir}/ssh-key"
gpg --import "${keys_dir}/gpg-private-key"
rm -rf "$keys_dir"
fi
export encrypted_080f214a372c_key= encrypted_080f214a372c_iv=
nix-build --quiet release.nix
if ! is-automatic-update; then
bash $DIR/lint.sh
fi
set -x
result/bin/nur update
nix-build
if ! is-automatic-update; then
# Pull requests and commits to other branches shouldn't try to deploy, just build to verify
echo "Skipping deploy; just doing a build."
exit 0
fi
git config --global user.name "Nur a bot"
git config --global user.email "joerg.nur-bot@thalheim.io"
git config --global user.signingkey "B4E40EEC9053254E"
git config --global commit.gpgsign true
git clone git@github.com:nix-community/nur-combined
result/bin/nur combine \
--irc-notify nur-bot@chat.freenode.net:6697/nixos-nur \
nur-combined
if [[ -z "$(git diff --exit-code)" ]]; then
echo "No changes to the output on this push; exiting."
else
git add --all repos.json*
git commit -m "automatic update"
git push git@github.com:nix-community/NUR HEAD:master
fi
(cd nur-combined && git push origin master)

24
ci/lib/setup-git.sh Normal file
View file

@ -0,0 +1,24 @@
# only source this file
# to setup git to push and pull repositories via ssh
# ==================================================
# set up git and ssh
# ------------------
keys_dir=$(mktemp -d)
openssl aes-256-cbc \
-K $encrypted_080f214a372c_key \
-iv $encrypted_080f214a372c_iv \
-in ci/keys.tar.gz.enc -out ci/keys.tar.gz -d
tar -C "$keys_dir" -xzvf ci/keys.tar.gz
eval "$(ssh-agent -s)"
chmod 600 "${keys_dir}/ssh-key"
ssh-add "${keys_dir}/ssh-key"
gpg --import "${keys_dir}/gpg-private-key"
rm -rf "$keys_dir"
export encrypted_080f214a372c_key= encrypted_080f214a372c_iv=
git config --global user.name "Nur a bot"
git config --global user.email "joerg.nur-bot@thalheim.io"
git config --global user.signingkey "B4E40EEC9053254E"
git config --global commit.gpgsign true

View file

@ -1,18 +0,0 @@
#!/usr/bin/env bash
set -eu -o pipefail # Exit with nonzero exit code if anything fails
$(nix-build --no-out-link release.nix)/bin/nur format-manifest
if [ -n "$(git diff --exit-code repos.json)" ]; then
echo "repos.json was not formatted before committing repos.json:" >&2
git diff --exit-code repos.json
echo "Please run ./bin/nur/format-manifest.py and updates repos.json accordingly!" >&2
exit 1
fi
# Type checker
nix run nixpkgs.python3Packages.mypy -c mypy nur
# Format checker
nix run nixpkgs.python3Packages.black -c black --check .
# Linter
nix run nixpkgs.python3Packages.flake8 -c flake8 .

21
ci/test.sh Executable file
View file

@ -0,0 +1,21 @@
#!/usr/bin/env bash
set -eux -o pipefail # Exit with nonzero exit code if anything fails
nix run '(import ./release.nix {})' -c nur format-manifest
if [ -n "$(git diff --exit-code repos.json)" ]; then
echo "repos.json was not formatted before committing repos.json:" >&2
git diff --exit-code repos.json
echo "Please run ./bin/nur/format-manifest.py and updates repos.json accordingly!" >&2
exit 1
fi
# Type checker
nix run nixpkgs.python3Packages.mypy -c mypy nur
# Format checker
nix run nixpkgs.python3Packages.black -c black --check .
# Linter
nix run nixpkgs.python3Packages.flake8 -c flake8 .
nix run '(import ./release.nix {})' -c nur update
nix-build

31
ci/update-nur-search.sh Executable file
View file

@ -0,0 +1,31 @@
#!/usr/bin/env bash
set -eu -o pipefail # Exit with nonzero exit code if anything fails
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
source ${DIR}/lib/setup-git.sh
set -x
# build package.json for nur-search
# ---------------------------------
nix-build --quiet release.nix
git clone git@github.com:nix-community/nur-search
nix run '(import ./release.nix {})' -c nur index . > nur-search/data/packages.json
# rebuild and publish nur-search repository
# -----------------------------------------
cd nur-search
if [[ ! -z "$(git diff --exit-code)" ]]; then
git add ./data/packages.json
git commit -m "automatic update package.json"
git push origin master
nix-shell --run "make && make publish"
else
echo "nothings changed will not commit anything"
fi

27
ci/update-nur.sh Executable file
View file

@ -0,0 +1,27 @@
#!/usr/bin/env bash
set -eu -o pipefail # Exit with nonzero exit code if anything fails
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
source ${DIR}/lib/setup-git.sh
set -x
nix run '(import ./release.nix {})' -c nur update
nix-build
git clone git@github.com:nix-community/nur-combined
nix run '(import ./release.nix {})' -c nur combine \
--irc-notify nur-bot@chat.freenode.net:6697/nixos-nur \
nur-combined
if [[ -z "$(git diff --exit-code)" ]]; then
echo "No changes to the output on this push; exiting."
else
git add --all repos.json*
git commit -m "automatic update"
git push git@github.com:nix-community/NUR HEAD:master
fi
(cd nur-combined && git push origin master)