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