From 2e96ca8f6e9cc9d1f9ed7d7958666d5326a3480a Mon Sep 17 00:00:00 2001 From: Carson McManus Date: Sun, 14 Nov 2021 12:30:30 -0500 Subject: [PATCH] move aur publish to separate script --- scripts/full-release.sh | 14 ----------- scripts/publish-aur.sh | 55 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+), 14 deletions(-) create mode 100644 scripts/publish-aur.sh diff --git a/scripts/full-release.sh b/scripts/full-release.sh index 8f014b9..9d2f1e9 100755 --- a/scripts/full-release.sh +++ b/scripts/full-release.sh @@ -76,17 +76,3 @@ if [[ $DRY_RUN == false ]]; then fi gh release create "$VERSION" --title "$VERSION" --draft "$BIN_PATH" "./steamguard-cli_$RAW_VERSION-0.deb" fi - -# update PKGBUILD for AUR -if [[ -d "aur" ]]; then - rm -rf aur -fi -git clone ssh://aur@aur.archlinux.org/steamguard-cli-git.git aur -cp PKGBUILD aur/PKGBUILD -cd aur -git commit -m "release $VERSION" PKGBUILD -if [[ $DRY_RUN == false ]]; then - git push - rm -rf aur -fi -cd .. diff --git a/scripts/publish-aur.sh b/scripts/publish-aur.sh new file mode 100644 index 0000000..9f73e90 --- /dev/null +++ b/scripts/publish-aur.sh @@ -0,0 +1,55 @@ +#!/bin/bash +set -e + +DRY_RUN=true + +POSITIONAL=() +while [[ $# -gt 0 ]]; do + key="$1" + + case $key in + --execute) + DRY_RUN=false + shift # past argument + ;; + *) # unknown option + POSITIONAL+=("$1") # save it in an array for later + shift # past argument + ;; + esac +done + +# prerequisites +if ! command -v makepkg &> /dev/null; then + echo "Error: makepkg is not installed" + exit 1 +fi +if ! command -v git &> /dev/null; then + echo "Error: git is not installed" + exit 2 +fi + + +# get version info +BIN_PATH="target/release/steamguard-cli" +RAW_VERSION="$("$BIN_PATH" --version | cut -d " " -f 2)" +TAGGED_VERSION="$(git tag | grep "^v" | tail -n 1 | tr -d v)" +if [[ "v$RAW_VERSION" != "v$TAGGED_VERSION" ]]; then + echo "Version mismatch: $RAW_VERSION != $TAGGED_VERSION" + exit 10 +fi +VERSION="v$RAW_VERSION" + +# update PKGBUILD for AUR +if [[ -d "aur" ]]; then + rm -rf aur +fi +git clone ssh://aur@aur.archlinux.org/steamguard-cli-git.git aur +cp PKGBUILD aur/PKGBUILD +cd aur +git commit -m "release $VERSION" PKGBUILD +if [[ $DRY_RUN == false ]]; then + git push + rm -rf aur +fi +cd .. \ No newline at end of file