From d365deded0a6a73a3025bf7310a89e33f097ec1a Mon Sep 17 00:00:00 2001 From: Erica Marigold Date: Sun, 23 Jul 2023 21:32:05 +0530 Subject: [PATCH] feat(packaging_aur): create publish script --- package/aur/publish.sh | 60 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 package/aur/publish.sh diff --git a/package/aur/publish.sh b/package/aur/publish.sh new file mode 100644 index 0000000..f5b2864 --- /dev/null +++ b/package/aur/publish.sh @@ -0,0 +1,60 @@ +#!/bin/bash + +set -e + +function build() { + # 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:-/} + + # Move the PKGBUILD for our package into the working directory + mv ../packaging_scripts/$cwd_name.PKGBUILD PKGBUILD + + # 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 + + # Generate `.SRCINFO` + makepkg --printsrcinfo > .SRCINFO +} + +function test() { + # Test with our modified `PKGBUILD` in a temporary directory + orig_dir=$(pwd) + testing_dir=$(mktmp) + cp PKGBUILD $testing_dir/ && cd $testing_dir + + makepkg + + # Go back to our original directory if all goes well + cd $orig_dir +} + +function push() { + pkgname=$1 + version=$2 + + git add PKGBUILD .SRCINFO + git commit -m "chore(release): $1 v$2" +} + +# Move our AUR specific config for SSH +mv ./ssh_config ~/.ssh/config + +# Declare our AUR git URLs +declare -a aur_ssh_urls=("ssh://aur@aur.archlinux.org/lune.git" "ssh://aur@aur.archlinux.org/lune-git.git") + +# As for now, we only publish the precompiled binary to the AUR +for ssh_url in "${aur_ssh_urls[@]}" +do + if [ $ssh_url -ne "ssh://aur@aur.archlinux.org/lune-git.git" ]; then + # TODO: Don't just directly try to cd into `lune` in the future + git clone $ssh_url && cd lune + build && test && push lune `get_current_version` + fi +done