From cebf9581e6e4c380dd956a31813c6ecccdbda8ff Mon Sep 17 00:00:00 2001 From: Compey Date: Sun, 23 Jul 2023 22:05:18 +0530 Subject: [PATCH] feat(packaging_aur): logging for CI publishing script --- package/aur/publish.sh | 34 +++++++++++++++++++++++++++++++--- package/aur/utils.sh | 10 ++++++++++ 2 files changed, 41 insertions(+), 3 deletions(-) diff --git a/package/aur/publish.sh b/package/aur/publish.sh index 2d1daf0..1dcb04a 100644 --- a/package/aur/publish.sh +++ b/package/aur/publish.sh @@ -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." \ No newline at end of file diff --git a/package/aur/utils.sh b/package/aur/utils.sh index 21d5dc3..ab105fa 100644 --- a/package/aur/utils.sh +++ b/package/aur/utils.sh @@ -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" +} \ No newline at end of file