feat(packaging_aur): logging for CI publishing script

This commit is contained in:
Erica Marigold 2023-07-23 22:05:18 +05:30
parent ff628935b4
commit cebf9581e6
No known key found for this signature in database
GPG key ID: 23CD97ABBBCC5ED2
2 changed files with 41 additions and 3 deletions

View file

@ -5,44 +5,65 @@ set -e
source ./utils.sh
function build() {
log "*" "Initializing PKGBUILD patch/build step"
# Get the name of the package to build from the current working directory
dirname=$(pwd)
shopt -s extglob
cwd_name=${dirname%%+(/)}
cwd_name=${cwd_name##*/}
cwd_name=${cwd_name:-/}
cwd_name=${dirname%%+(/)}
cwd_name=${cwd_name##*/}
cwd_name=${cwd_name:-/}
# Move the PKGBUILD for our package into the working directory
mv ../packaging_scripts/$cwd_name.PKGBUILD PKGBUILD
log "#" "Moved \`PKGBUILD\` into working dir"
# Increment the `pkgver`
current_version=$(get_current_version)
new_version=`increment_version $current_version 2> /dev/null`
sed -i 's/$current_version/$new_version/g' PKGBUILD
log "#" "Incremented \`pkgver\`"
# Generate `.SRCINFO`
makepkg --printsrcinfo > .SRCINFO
log "#" "Generated \`.SRCINFO\`"
}
function test() {
log "*" "Initializing makepkg test step"
# Test with our modified `PKGBUILD` in a temporary directory
orig_dir=$(pwd)
testing_dir=$(mktmp)
cp PKGBUILD $testing_dir/ && cd $testing_dir
log "#" "Moved \`PKGBUILD\` into testing directory $testing_dir"
makepkg
log "#" "Finished testing with makepkg"
# Go back to our original directory if all goes well
cd $orig_dir
}
function push() {
log "*" "Initializing AUR push step"
pkgname=$1
version=$2
log "#" "Committing changes to AUR repository"
git add PKGBUILD .SRCINFO
git commit -m "chore(release): $1 v$2"
git push
log "#" "Pushed commit to AUR"
}
# Move our AUR specific config for SSH
@ -55,9 +76,16 @@ declare -a aur_ssh_urls=("ssh://aur@aur.archlinux.org/lune.git" "ssh://aur@aur.a
for ssh_url in "${aur_ssh_urls[@]}"
do
if [ $ssh_url -ne "ssh://aur@aur.archlinux.org/lune-git.git" ]; then
log "*" "Cloning AUR package from $ssh_url"
# NOTE: We need to have our public and private keys in `~/.ssh/aur.pub` & `~/.ssh/aur` respectively
# TODO: Don't just directly try to cd into `lune` in the future
git clone $ssh_url && cd lune
log "*" "Building, testing and pushing changes to AUR"
build && test && push lune `get_current_version`
fi
done
log "*" "AUR packaging routine complete."

View file

@ -15,3 +15,13 @@ function get_current_version() {
printf current_version
}
log_prefix=\x1b[34m[\u001b[0m\x1b[31m
log_suffix=\x1b[34m\x1b[34m]\u001b[0m
function log() {
log_identifier=$1
log_msg=$2
echo -e "$logprefix$log_identifier$log_suffix $log_msg"
}