2023-03-09 14:15:44 +03:00
|
|
|
#!/usr/bin/env nix-shell
|
|
|
|
#!nix-shell -i bash -p wget prefetch-yarn-deps nix-prefetch-git jq
|
|
|
|
|
|
|
|
# shellcheck shell=bash
|
|
|
|
|
2023-03-16 01:14:34 +03:00
|
|
|
function help () {
|
|
|
|
echo "Regenerates packaging data for the woodpecker packages."
|
|
|
|
echo "Usage: $0 <rev>"
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
2023-03-09 14:15:44 +03:00
|
|
|
if [ -n "$GITHUB_TOKEN" ]; then
|
|
|
|
TOKEN_ARGS=(--header "Authorization: token $GITHUB_TOKEN")
|
|
|
|
fi
|
|
|
|
|
2023-03-16 01:14:34 +03:00
|
|
|
|
2023-03-09 14:15:44 +03:00
|
|
|
if [[ $# -gt 1 || $1 == -* ]]; then
|
2023-03-16 01:14:34 +03:00
|
|
|
help
|
2023-03-09 14:15:44 +03:00
|
|
|
fi
|
|
|
|
|
|
|
|
set -x
|
|
|
|
|
|
|
|
cd "$(dirname "$0")"
|
|
|
|
version="$1"
|
|
|
|
|
|
|
|
set -euo pipefail
|
|
|
|
|
|
|
|
if [ -z "$version" ]; then
|
2023-03-16 01:14:34 +03:00
|
|
|
help
|
2023-03-09 14:15:44 +03:00
|
|
|
fi
|
|
|
|
|
|
|
|
# Woodpecker repository
|
|
|
|
src_hash=$(nix-prefetch-git --url https://git.pleshevski.ru/infra/woodpecker --rev "${version}" | jq -r .sha256)
|
|
|
|
|
|
|
|
# Front-end dependencies
|
|
|
|
woodpecker_src="https://git.pleshevski.ru/infra/woodpecker/raw/$version"
|
|
|
|
wget "${TOKEN_ARGS[@]}" "$woodpecker_src/web/package.json" -O woodpecker-package.json
|
|
|
|
|
|
|
|
web_tmpdir=$(mktemp -d)
|
|
|
|
trap 'rm -rf "$web_tmpdir"' EXIT
|
|
|
|
pushd "$web_tmpdir"
|
|
|
|
wget "${TOKEN_ARGS[@]}" "$woodpecker_src/web/yarn.lock"
|
|
|
|
yarn_hash=$(prefetch-yarn-deps yarn.lock)
|
|
|
|
popd
|
|
|
|
|
|
|
|
# Use friendlier hashes
|
|
|
|
src_hash=$(nix hash to-sri --type sha256 "$src_hash")
|
|
|
|
yarn_hash=$(nix hash to-sri --type sha256 "$yarn_hash")
|
|
|
|
|
|
|
|
sed -i -E -e "s#version = \".*\"#version = \"$version\"#" common.nix
|
|
|
|
sed -i -E -e "s#srcSha256 = \".*\"#srcSha256 = \"$src_hash\"#" common.nix
|
|
|
|
sed -i -E -e "s#yarnSha256 = \".*\"#yarnSha256 = \"$yarn_hash\"#" common.nix
|