<commit_before>#!/bin/sh -e

# this is an helper
# to use into your travis file
# it is limited to amd64/386 arch
#
# to use it
# curl -L https://raw.githubusercontent.com/mh-cbon/go-bin-rpm/master/setup-deb-repository.sh \
# | GH=mh-cbon/gh-api-cli EMAIL=<EMAIL> sh -xe

# GH=$1
# EMAIL=$2

REPO=`echo ${GH} | cut -d '/' -f 2`
USER=`echo ${GH} | cut -d '/' -f 1`

sudo apt-get install build-essential -y

if type "gh-api-cli" > /dev/null; then
  echo "gh-api-cli already installed"
else
  curl -L https://raw.githubusercontent.com/mh-cbon/latest/master/install.sh | GH=mh-cbon/gh-api-cli sh -xe
fi

git checkout --track -b origin/gh-pages || echo "branch already exists"
git config user.name "${USER}"
git config user.email "${EMAIL}"

rm -fr rpm
mkdir -p rpm/{i386,x86_64}
gh-api-cli dl-assets -o ${USER} -r ${REPO} --out rpm/i386/%r-%v_%a.%e -g "*386*rpm"
gh-api-cli dl-assets -o ${USER} -r ${REPO} --out rpm/x86_64/%r-%v_%a.%e -g "*amd64*rpm"

cat <<EOT > createrepo.sh
yum install createrepo -y
cd /docker/rpm/i386
createrepo .
cd /docker/rpm/x86_64
createrepo .
EOT
docker run -v $PWD:/docker fedora /bin/sh -c "cd /docker && sh ./createrepo.sh"


cat <<EOT > gen-repo-file.sh
DESC=`rpm -qip *.rpm | grep Summary | cut -d ':' -f2 | cut -d ' ' -f2- | tail -n 1`
cat <<EOTin > rpm/${REPO}.repo
[${REPO}]
name=${DESC}
baseurl=https://${USER}.github.io/${REPO}/rpm/\$basearch/
enabled=1
skip_if_unavailable=1
gpgcheck=0
EOTin
EOT
docker run -v $PWD:/docker fedora /bin/sh -c "cd /docker && sh ./gen-repo-file.sh"

rm -f gen-repo-file.sh
rm -f createrepo.sh


git add -A
git commit -m "Created rpm repository"

set +x # disable debug output because that would display the token in clear text..
echo "git push --force --quiet https://GH_TOKEN@github.com/${GH}.git gh-pages"
git push --force --quiet "https://${GH_TOKEN}@github.com/${GH}.git" gh-pages \
 2>&1 | sed -re "s/${GH_TOKEN}/GH_TOKEN/g"<commit_msg>support: tryfix travis<commit_after>#!/bin/sh -e

# this is an helper
# to use into your travis file
# it is limited to amd64/386 arch
#
# to use it
# curl -L https://raw.githubusercontent.com/mh-cbon/go-bin-rpm/master/setup-deb-repository.sh \
# | GH=mh-cbon/gh-api-cli EMAIL=<EMAIL> sh -xe

# GH=$1
# EMAIL=$2

REPO=`echo ${GH} | cut -d '/' -f 2`
USER=`echo ${GH} | cut -d '/' -f 1`

sudo apt-get install build-essential -y

if type "gh-api-cli" > /dev/null; then
  echo "gh-api-cli already installed"
else
  curl -L https://raw.githubusercontent.com/mh-cbon/latest/master/install.sh | GH=mh-cbon/gh-api-cli sh -xe
fi

git checkout --track -b origin/gh-pages || git checkout -b gh-pages || echo "branch already exists"
git config user.name "${USER}"
git config user.email "${EMAIL}"

rm -fr rpm
mkdir -p rpm/{i386,x86_64}
gh-api-cli dl-assets -o ${USER} -r ${REPO} --out rpm/i386/%r-%v_%a.%e -g "*386*rpm"
gh-api-cli dl-assets -o ${USER} -r ${REPO} --out rpm/x86_64/%r-%v_%a.%e -g "*amd64*rpm"

cat <<EOT > createrepo.sh
yum install createrepo -y
cd /docker/rpm/i386
createrepo .
cd /docker/rpm/x86_64
createrepo .
EOT
docker run -v $PWD:/docker fedora /bin/sh -c "cd /docker && sh ./createrepo.sh"


cat <<EOT > gen-repo-file.sh
DESC=`rpm -qip *.rpm | grep Summary | cut -d ':' -f2 | cut -d ' ' -f2- | tail -n 1`
cat <<EOTin > rpm/${REPO}.repo
[${REPO}]
name=${DESC}
baseurl=https://${USER}.github.io/${REPO}/rpm/\$basearch/
enabled=1
skip_if_unavailable=1
gpgcheck=0
EOTin
EOT
docker run -v $PWD:/docker fedora /bin/sh -c "cd /docker && sh ./gen-repo-file.sh"

rm -f gen-repo-file.sh
rm -f createrepo.sh


git add -A
git commit -m "Created rpm repository"

git status
git branch

set +x # disable debug output because that would display the token in clear text..
echo "git push --force --quiet https://GH_TOKEN@github.com/${GH}.git gh-pages"
git push --force --quiet "https://${GH_TOKEN}@github.com/${GH}.git" gh-pages \
 2>&1 | sed -re "s/${GH_TOKEN}/GH_TOKEN/g"
{'fraction_non_alphanumeric': 0.18714506969540526, 'fraction_numerical': 0.02219927723283428, 'mean_word_length': 3.262926292629263, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 15, 'https://': 10, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '876077', 'n_tokens_mistral': 1715, 'n_tokens_neox': 1562, 'n_words': 443}