Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/src/archrelease.in
diff options
context:
space:
mode:
Diffstat (limited to 'src/archrelease.in')
-rw-r--r--src/archrelease.in95
1 files changed, 51 insertions, 44 deletions
diff --git a/src/archrelease.in b/src/archrelease.in
index 3490ee2..818b0ca 100644
--- a/src/archrelease.in
+++ b/src/archrelease.in
@@ -2,8 +2,19 @@
#
# SPDX-License-Identifier: GPL-3.0-or-later
-m4_include(lib/common.sh)
-m4_include(lib/valid-tags.sh)
+_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
+
+set -e
+
+
+# Deprecation warning
+if [[ -z $_DEVTOOLS_COMMAND ]]; then
+ warning "${0##*/} is deprecated and will be removed. Use 'pkgctl release' instead"
+fi
# parse command line options
FORCE=
@@ -34,54 +45,50 @@ if [[ ! -f PKGBUILD ]]; then
die 'archrelease: PKGBUILD not found'
fi
-trunk=${PWD##*/}
+# shellcheck source=contrib/makepkg/PKGBUILD.proto
+. ./PKGBUILD
+pkgbase=${pkgbase:-$pkgname}
+pkgver=$(get_full_version "$pkgbase")
+gittag=$(get_tag_from_pkgver "$pkgver")
-# Normally this should be trunk, but it may be something
-# such as 'gnome-unstable'
-IFS='/' read -r -d '' -a parts <<< "$PWD"
-if [[ "${parts[*]:(-2):1}" == "repos" ]]; then
- die 'archrelease: Should not be in repos dir (try from trunk/)'
+# Check if releasing from a branch
+if ! branchname=$(git symbolic-ref --short HEAD); then
+ die 'not on any branch'
fi
-unset parts
-
-if [[ $(svn status -q) ]]; then
- die 'archrelease: You have not committed your changes yet!'
+if [[ "${branchname}" != main ]]; then
+ die 'must be run from the main branch'
fi
-pushd .. >/dev/null
-mapfile -t known_files < <(svn ls -r HEAD "$trunk")
-wait $! || die "failed to discover committed files"
-
-# gracefully handle files containing an "@" character
-known_files=("${known_files[@]/%/@}")
-
-# update repo directory first to avoid a commit failure
-svn up repos
+# Check if remote origin is setup properly
+if ! giturl=$(git remote get-url origin) || [[ ${giturl} != *${GIT_PACKAGING_URL_SSH}* ]]; then
+ die "remote origin is not configured, run 'pkgctl repo configure'"
+fi
+if ! git ls-remote origin >/dev/null; then
+ die "configured remote origin may not exist, run 'pkgctl repo create ${pkgbase}' to create it"
+fi
-for tag in "$@"; do
- stat_busy "Copying %s to %s" "${trunk}" "${tag}"
+msg 'Fetching remote changes'
+git fetch --prune --prune-tags origin || die 'failed to fetch remote changes'
- if [[ -d repos/$tag ]]; then
- mapfile -t trash < <(svn ls --recursive "repos/$tag")
- wait $! || die "failed to discover existing files"
- if (( ${#trash[@]} )); then
- trash=("${trash[@]/#/repos/$tag/}")
- svn rm -q "${trash[@]/%/@}"
- fi
- else
- mkdir -p "repos/$tag"
- svn add --parents -q "repos/$tag"
+# Check if local branch is up to date and contains the latest origin commit
+if remoteref=$(git rev-parse "origin/${branchname}" 2>/dev/null); then
+ if [[ $(git branch "${branchname}" --contains "${remoteref}" --format '%(refname:short)') != "${branchname}" ]]; then
+ die "local branch is out of date, run 'git pull --rebase'"
fi
+fi
- # copy all files at once from trunk to the subdirectory in repos/
- svn copy -q -r HEAD "${known_files[@]/#/$trunk/}" "repos/$tag/"
-
- stat_done
-done
-
-stat_busy "Releasing package"
-printf -v tag_list ", %s" "$@"; tag_list="${tag_list#, }"
-svn commit -q -m "archrelease: copy ${trunk} to $tag_list" || abort
-stat_done
+# 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
+ git push --tags --set-upstream origin main || abort
+ exit 0
+fi
-popd >/dev/null
+msg "Releasing package"
+git tag --sign --message="Package release ${pkgver}" "$gittag" || abort
+git push --tags --set-upstream origin main || abort