~lattis/muon

5ff49d9966c8b61e3850359835b4f6a14a15ffc5 — Stone Tickle 25 days ago 3c35ff4
github mirror: sync all release branches
3 files changed, 30 insertions(+), 5 deletions(-)

M tools/ci/push_to_gh_mirror.sh
A tools/ci/ref_is_release_branch.sh
M tools/ci/release.sh
M tools/ci/push_to_gh_mirror.sh => tools/ci/push_to_gh_mirror.sh +15 -1
@@ 17,5 17,19 @@ EOF

chmod 600 ~/.ssh/config

ref=""
git for-each-ref -s --format='ref=%(refname)' refs/remotes/origin | while read -r line; do
	eval "$line"
	branch="${ref##refs/remotes/origin/}"

	if tools/ci/ref_is_release_branch.sh "refs/heads/$branch"; then
		printf "+%s:refs/heads/%s " "$ref" "$branch" >> branches_to_push.txt
	fi
done

git remote add github git@github.com:muon-build/muon.git
git push --force --mirror github

# We don't want to use --mirror here because that implies --prune which will
# remove any branches that might have been created on the gh repo only.
# shellcheck disable=SC2046 # Intended splitting of branches
git push --force --tags github $(cat branches_to_push.txt)

A tools/ci/ref_is_release_branch.sh => tools/ci/ref_is_release_branch.sh +12 -0
@@ 0,0 1,12 @@
#!/bin/sh
# SPDX-FileCopyrightText: Stone Tickle <lattis@mochiro.moe>
# SPDX-License-Identifier: GPL-3.0-only

set -eu

ref="$1"

if [ "$ref" = "refs/heads/master" ]; then exit 0
elif echo "$ref" | grep -q '^refs/heads/[0-9]\+\.[0-9]\+$'; then exit 0
else exit 1
fi

M tools/ci/release.sh => tools/ci/release.sh +3 -4
@@ 11,7 11,7 @@ version=""
# shellcheck disable=SC1091
. "$build/version.sh"

branch_name="$(git branch --contains HEAD | sed 's/^[* ]*//g' | grep '^[^ ]*$')"
branch_name="$GIT_REF"

echo "version: $version, branch_name: '$branch_name'"



@@ 21,8 21,7 @@ tools/ci/prepare_release_docs.sh "$build"
tools/ci/prepare_tarball.sh "muon-$version"

# only allow master and release branches through
if [ "$branch_name" = "master" ]; then :
elif echo "$branch_name" | grep -q '[0-9]\+\.[0-9]\+'; then :
if tools/ci/ref_is_release_branch.sh "$branch_name"; then :
else exit 0
fi



@@ 35,7 34,7 @@ tools/ci/deploy.sh "/releases/$version" \
	"muon-$version.tar.gz"

# only allow master through
if [ "$branch_name" = "master" ]; then :
if [ "$branch_name" = "refs/heads/master" ]; then :
else exit 0
fi