tvl-depot/tools/releases/default.nix
Florian Klink e8fd2aabb3 fix(tools/releases): add :unsign to filteredGitPush
We need to followup on cl/8186, and use the same workaround for josh-
filter that we use for josh-proxy, so we can push again.

This could potentially become an optional function argument, if new
subtrees are to be carved out, and we want to keep signatures on commits
in there.

Change-Id: I7a9b821a7365767e8a4188e8200fa3c37463142c
Reviewed-on: https://cl.tvl.fyi/c/depot/+/8368
Tested-by: BuildkiteCI
Reviewed-by: sterni <sternenseemann@systemli.org>
Autosubmit: flokli <flokli@flokli.de>
2023-03-30 14:28:39 +00:00

37 lines
1.2 KiB
Nix

# Definitions for simple release mechanisms from depot.
{ depot, lib, pkgs, ... }:
let
inherit (lib.strings) makeBinPath sanitizeDerivationName;
in
{
# Use a josh filter to push a certain subset of canon to another git
# repository.
#
# This expects, of course, that the remote repository has granted
# push access to the CI SSH key.
filteredGitPush = { filter, remote, ref ? "refs/heads/canon" }: {
label = ":git: push '${filter}' to external git repository";
branches = [ "refs/heads/canon" ];
phase = "release";
command = pkgs.writeShellScript "${sanitizeDerivationName filter}-push" ''
set -e
export PATH="${makeBinPath [ pkgs.git depot.third_party.josh ]}:$PATH"
echo 'Filtering depot through :unsign ${filter}'
josh-filter ':unsign ${filter}'
echo 'Fetching remote to check if a push is needed'
git fetch '${remote}' '${ref}'
if git merge-base --is-ancestor FILTERED_HEAD FETCH_HEAD; then
echo 'Commit already present, nothing to push.'
exit 0
fi
echo 'Pushing filtered repository to ${remote}:${ref}'
git push '${remote}' 'FILTERED_HEAD:${ref}'
'';
};
}