| #!/bin/sh |
| # SPDX-License-Identifier: GPL-2.0-or-later |
| # |
| # Finalize a release (possibly prepared with AI agent assistance) |
| # Amends the version bump commit to add Signed-off-by, then creates a |
| # signed annotated tag from the drafted tag message. |
| |
| set -e |
| |
| usage() { |
| echo "Usage: $0 <tag-message-file>" >&2 |
| echo "" >&2 |
| echo "Run this from the repository root with VERSION.txt updated" >&2 |
| echo "and a draft tag message in given file." >&2 |
| exit 1 |
| } |
| |
| TAG_MSG_FILE="$1" |
| if [ -z "$TAG_MSG_FILE" ] || [ ! -f "$TAG_MSG_FILE" ]; then |
| usage |
| fi |
| |
| VERSION=$(cat VERSION.txt) |
| TAG="v${VERSION}" |
| |
| if git rev-parse "$TAG" >/dev/null 2>&1; then |
| echo "Error: tag $TAG already exists" >&2 |
| exit 1 |
| fi |
| |
| HEAD_SUBJECT=$(git log -1 --format=%s) |
| EXPECTED="Bump version to $TAG" |
| if [ "$HEAD_SUBJECT" != "$EXPECTED" ]; then |
| echo "Error: HEAD commit subject is:" >&2 |
| echo " $HEAD_SUBJECT" >&2 |
| echo "Expected:" >&2 |
| echo " $EXPECTED" >&2 |
| exit 1 |
| fi |
| |
| echo "Version: $VERSION" |
| echo "Tag: $TAG" |
| echo "" |
| echo "--- Tag message ---" |
| cat "$TAG_MSG_FILE" |
| echo "--- End tag message ---" |
| echo "" |
| |
| printf "Proceed? [y/N] " |
| read answer |
| case "$answer" in |
| y|Y) ;; |
| *) echo "Aborted."; exit 1 ;; |
| esac |
| |
| git commit --amend -s --no-edit |
| git tag -s "$TAG" -F "$TAG_MSG_FILE" |
| |
| echo "" |
| echo "Created signed tag $TAG." |
| echo "Review with: git show $TAG" |
| echo "" |
| |
| git push origin main "$TAG" |
| git push github main "$TAG" |
| git push gitlab main "$TAG" |
| |
| SCRIPTDIR=$(dirname "$0") |
| |
| printf "Upload to kernel.org via kup? [y/N] " |
| read answer |
| case "$answer" in |
| y|Y) "$SCRIPTDIR/kup-dtc" "$VERSION" ;; |
| *) echo "Skipping kup upload." ;; |
| esac |
| |
| TAG_BODY=$(git tag -l --format='%(contents:body)' "$TAG") |
| |
| ANNOUNCE="announce-${TAG}.txt" |
| cat > "$ANNOUNCE" <<MAIL |
| To: devicetree-compiler@vger.kernel.org |
| Subject: DTC $VERSION released |
| |
| DTC $VERSION is now available. |
| |
| Git tree: |
| https://git.kernel.org/pub/scm/utils/dtc/dtc.git |
| |
| Tagged release ($TAG): |
| https://git.kernel.org/pub/scm/utils/dtc/dtc.git/tag/?h=$TAG |
| |
| Tarball: |
| https://kernel.org/pub/software/utils/dtc/dtc-${VERSION}.tar.gz |
| |
| $TAG_BODY |
| MAIL |
| |
| echo "Announcement draft written to $ANNOUNCE" |