-
Notifications
You must be signed in to change notification settings - Fork 1
/
action.sh
executable file
·111 lines (82 loc) · 2.39 KB
/
action.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
#!/bin/bash
# Higly inspired from kaz/archlinux-repository-boilerplate
ARCH=x86_64
MAKEFLAGS="-j$(nproc)"
: ${BUILD_USER:="builder"}
: ${PKGS_DIR=/tmp/__pkgs__}
: ${CCACHE_DIR:="/tmp/ccache"}
: ${GITHUB_ACTOR:=""}
: ${GIT_REMOTE:=""}
: ${GIT_BRANCH:="gh-pages"}
GITHUB_REPO_OWNER=${GITHUB_REPOSITORY%/*}
ARCH_REPO_NAME=heera
create_local() {
mkdir -pv $PKGS_DIR/x86_64
# Create the package database (Ignore warnings)
repo-add $PKGS_DIR/x86_64/pkgs.db.tar.gz
}
update_local_repo() {
repo-add "$PKGS_DIR"/pkgs.db.tar.gz "$PKGS_DIR/x86_64/"*.pkg.tar.zst
pacman -Sy
}
verify_packages() {
cd "$PKGS_DIR/x86_64"
pacman -Sy namcap --noconfirm
for PACKAGE in $(find . -name "*.pkg.tar.zst"); do
echo "For "$PACKAGE" :"
namcap $PACKAGE || { echo "ERROR IN $PACKAGE"; true; }
done
}
initialize() {
pacman -Syu --noconfirm --needed git wget ccache ninja
echo "${BUILD_USER} ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/${BUILD_USER}
echo "cache_dir = ${CCACHE_DIR}" > /etc/ccache.conf
useradd -m ${BUILD_USER}
chown -R ${BUILD_USER}:${BUILD_USER} .
}
build() {
export MAKEFLAGS="-j$(nproc)"
printf "[heera]\nSigLevel = Optional\nServer = https://heera-os.github.io/archrepo-stable/\$arch\n" >> /etc/pacman.conf
pacman -Sy
mkdir -pv "${PKGS_DIR}"
for PKGBUILD_PATH in $(find . -name "PKGBUILD"); do
pkgbuild_dir=${PKGBUILD_PATH%PKGBUILD}
cd "$pkgbuild_dir"
sudo -u "${BUILD_USER}" makepkg -s --noconfirm --needed || true
cd ..
done
}
ci_build() {
export MAKEFLAGS="-j$(nproc)"
mkdir -pv "${PKGS_DIR}"
for PKGBUILD_PATH in $(find . -name "PKGBUILD"); do
pkgbuild_dir=${PKGBUILD_PATH%PKGBUILD}
pushd "$pkgbuild_dir"
sudo -u "${BUILD_USER}" makepkg -sfr --noconfirm --needed
cp -v *.pkg.tar.zst "${PKGS_DIR}/x86_64/"
update_local_repo
popd
done
}
publish() {
# Expecting the branch is cloned at "${GITHUB_BRANCH}"
cd "${GIT_BRANCH}"
rm -rfv "${ARCH}" # To remove older packages
mkdir "${ARCH}"
# Remove older commit
git reset --soft HEAD^
# Add the packages
cd "${ARCH}"
find "${PKGS_DIR}" -name "*.pkg.tar.zst" -exec cp -v "{}" . \;
repo-add $ARCH_REPO_NAME.db.tar.gz *.pkg.tar.zst
rename '.tar.gz' '' *.tar.gz
# Commit
git add --all --verbose
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
git config user.name "${GITHUB_ACTOR}"
git commit -m "Updated at $(date +'%d/%m/%Y %H:%M:%S')"
# Push
git push -fu origin "${GIT_BRANCH}"
}
set -xe
"$@"