-
-
Notifications
You must be signed in to change notification settings - Fork 12
/
publish.sh
executable file
·63 lines (49 loc) · 1.74 KB
/
publish.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/bin/bash
set -eu -o pipefail
LATEST_RELEASE=$(curl -sI https://github.com/mikeeq/mbp-fedora-kernel/releases/latest | grep -i "location:" | cut -d'v' -f2 | tr -d '\r')
echo >&2 "===]> Info: LATEST_RELEASE=$LATEST_RELEASE"
echo >&2 "===]> Info: Build mbp-fedora-repo..."
cd yum-repo
docker build -t mbp-fedora-repo --build-arg RELEASE_VERSION="${LATEST_RELEASE}" .
cd ..
echo >&2 "===]> Info: Run mbp-fedora-repo in the background..."
DOCKER_CONTAINER_ID=$(docker run --rm -d mbp-fedora-repo)
echo >&2 "===]> Info: Make a zip file with repo content..."
docker exec -t -u 0 "$DOCKER_CONTAINER_ID" /bin/bash -c '
dnf makecache
dnf install -y zip unzip curl cmake
cd /tmp
curl -L https://github.com/libthinkpad/apindex/archive/refs/tags/2.2.zip -O
unzip 2.2.zip
cd apindex-2.2
cmake . -DCMAKE_INSTALL_PREFIX=/usr
make install
cd /var/repo
apindex .
zip -r /tmp/repo.zip ./
'
echo >&2 "===]> Info: Copy zip file to host..."
docker cp "$DOCKER_CONTAINER_ID":/tmp/repo.zip /tmp/repo.zip
echo >&2 "===]> Info: Change branch to gh-pages..."
git fetch origin gh-pages
git checkout gh-pages
echo >&2 "===]> Info: Remove old RPMs..."
rm -rfv ./*.rpm
rm -rfv ./repodata
rm -rfv ./index.html
rm -rfv ./yum-repo
echo >&2 "===]> Info: Copy zip file to repo..."
cp -rfv /tmp/repo.zip ./
echo >&2 "===]> Info: Unzip..."
unzip repo.zip
echo >&2 "===]> Info: Remove zip..."
rm -rfv repo.zip
echo >&2 "===]> Info: Add git config..."
git config user.name "CI-GitHubActions"
git config user.email "ci@github-actions.com"
echo >&2 "===]> Info: Add, commit, push changes to gh-pages remote..."
git add .
git commit -m "Release: $LATEST_RELEASE, date: $(date +'%Y%m%d_%H%M%S')"
git push origin gh-pages
echo >&2 "===]> Info: Stop mbp-fedora-repo container..."
docker stop "$DOCKER_CONTAINER_ID"