#!/bin/bash # # SPDX-License-Identifier: GPL-3.0-or-later _DEVTOOLS_LIBRARY_DIR=${_DEVTOOLS_LIBRARY_DIR:-@pkgdatadir@} # shellcheck source=src/lib/common.sh source "${_DEVTOOLS_LIBRARY_DIR}"/lib/common.sh # shellcheck source=src/lib/valid-tags.sh source "${_DEVTOOLS_LIBRARY_DIR}"/lib/valid-tags.sh # parse command line options FORCE= while getopts ':f' flag; do case $flag in f) FORCE=1 ;; :) die "Option requires an argument -- '%s'" "$OPTARG" ;; \?) die "Invalid option -- '%s'" "$OPTARG" ;; esac done shift $(( OPTIND - 1 )) if ! (( $# )); then echo 'Usage: archrelease [-f] ...' exit 1 fi # validate repo is really repo-arch if [[ -z $FORCE ]]; then for tag in "$@"; do if ! in_array "$tag" "${_tags[@]}"; then die "archrelease: Invalid tag: '%s' (use -f to force release)" "$tag" fi done fi if [[ ! -f PKGBUILD ]]; then die 'archrelease: PKGBUILD not found' fi . ./PKGBUILD pkgbase=${pkgbase:-$pkgname} pkgver=$(get_full_version "$pkgbase") gittag=$(get_tag_from_pkgver "$pkgver") if git rev-parse "$gittag" >/dev/null 2>&1; then die "archrelease: the tag $gittag for version $pkgver already exists in the repository!" fi # If the tag exists we check if it's properly signed and that it # matches the working directory PKGBUILD. if git tag --verify "$gittag" &> /dev/null; then cwd_checksum=$(sha256sum PKGBUILD|cut -d' ' -f1) tag_checksum=$(git show "${gittag}:PKGBUILD" | sha256sum |cut -d' ' -f1) if [[ "$cwd_checksum" != "$tag_checksum" ]]; then die "tagged PKGBUILD is not the same as the working dir PKGBUILD" fi exit 0 fi stat_busy "Releasing package" git tag --sign --message="Package release ${pkgver}" "$gittag" || abort git push --tags main || abort stat_done