- CPack DEB configuration (cmake/Packaging.cmake): dependencies from dpkg-shlibdeps, udisks2 recommended, strip. - AppStream metadata, installed with the desktop file and the icons; tools/release.sh adds each release to it. - tools/appimage.sh: AppImage of the GTK interface and openpu-cli with linuxdeploy and its GTK plugin (x86_64 and aarch64). - Release workflow: .deb, AppImage and openpu-cli tarball for x86_64 and arm64, attached to the release of a vX.Y.Z tag, or kept as artifacts on a manual run. tools/release.sh edits the release when the workflow created it first. - The GTK interface finds its translations next to the executable (../share/locale), for relocatable installs. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WDASLCiN764v685boRVYar
59 lines
3.3 KiB
Bash
59 lines
3.3 KiB
Bash
#!/bin/sh
|
|
# SPDX-License-Identifier: MIT
|
|
# Cut a release: set project(VERSION) in CMakeLists.txt, date the "Unreleased" section of
|
|
# CHANGELOG.md, commit, create the annotated tag vX.Y.Z, push to every remote (GitHub origin and
|
|
# the Gitea mirror) and publish the GitHub release that the in-app update check reads.
|
|
#
|
|
# usage: tools/release.sh X.Y.Z [--no-push]
|
|
set -eu
|
|
|
|
VERSION=${1:-}
|
|
PUSH=1
|
|
[ "${2:-}" = "--no-push" ] && PUSH=0
|
|
echo "$VERSION" | grep -Eq '^[0-9]+\.[0-9]+\.[0-9]+$' || { echo "usage: $0 X.Y.Z [--no-push]" >&2; exit 2; }
|
|
|
|
cd "$(dirname "$0")/.."
|
|
[ -z "$(git status --porcelain)" ] || { echo "the working tree is not clean" >&2; exit 1; }
|
|
git rev-parse -q --verify "refs/tags/v$VERSION" >/dev/null && { echo "tag v$VERSION already exists" >&2; exit 1; }
|
|
grep -q '^## \[Unreleased\]' CHANGELOG.md || { echo "CHANGELOG.md has no [Unreleased] section" >&2; exit 1; }
|
|
PREVIOUS=$(git describe --tags --abbrev=0 --match 'v[0-9]*' 2>/dev/null || true)
|
|
|
|
TODAY=$(date +%Y-%m-%d)
|
|
sed -i "s/^project(openpu VERSION [0-9.]* /project(openpu VERSION $VERSION /" CMakeLists.txt
|
|
grep -q "^project(openpu VERSION $VERSION " CMakeLists.txt || { echo "cannot update CMakeLists.txt" >&2; exit 1; }
|
|
# New release section under an empty Unreleased one, and comparison links at the bottom.
|
|
sed -i "s/^## \[Unreleased\]$/## [Unreleased]\n\n## [$VERSION] - $TODAY/" CHANGELOG.md
|
|
sed -i "s|^\[Unreleased\]: \(.*\)/compare/v[0-9.]*\.\.\.HEAD$|[Unreleased]: \1/compare/v$VERSION...HEAD\n[$VERSION]: \1/releases/tag/v$VERSION|" CHANGELOG.md
|
|
|
|
# AppStream metadata lists the releases, newest first.
|
|
sed -i "s|^ <releases>$| <releases>\n <release version=\"$VERSION\" date=\"$TODAY\"/>|" data/io.github.openpu.OpenPU.metainfo.xml
|
|
grep -q "<release version=\"$VERSION\"" data/io.github.openpu.OpenPU.metainfo.xml || { echo "cannot update the metainfo" >&2; exit 1; }
|
|
|
|
git add CMakeLists.txt CHANGELOG.md data/io.github.openpu.OpenPU.metainfo.xml
|
|
# RELEASE_TRAILER: optional trailer lines appended to the release commit message (e.g. co-authors).
|
|
git commit -q -m "release: v$VERSION" ${RELEASE_TRAILER:+-m "$RELEASE_TRAILER"}
|
|
# Plain string comparison (not a regex: "[" and "." in the heading would be special).
|
|
NOTES=$(awk -v v="$VERSION" 'index($0, "## [" v "]") == 1 {on=1; next}
|
|
on && (index($0, "## ") == 1 || index($0, "[") == 1) {exit}
|
|
on {print}' CHANGELOG.md | sed -e '/./,$!d')
|
|
[ -n "$NOTES" ] || { echo "no release notes found for $VERSION in CHANGELOG.md" >&2; exit 1; }
|
|
git tag -a "v$VERSION" -m "OpenPU $VERSION" -m "$NOTES"
|
|
echo "tagged v$VERSION (previous: ${PREVIOUS:-none})"
|
|
|
|
[ "$PUSH" = 1 ] || exit 0
|
|
for remote in $(git remote); do
|
|
git push --follow-tags "$remote" HEAD
|
|
done
|
|
GH=$(command -v gh || command -v gh.exe || true)
|
|
[ -z "$GH" ] && [ -x "/c/Program Files/GitHub CLI/gh.exe" ] && GH="/c/Program Files/GitHub CLI/gh.exe"
|
|
if [ -n "$GH" ]; then
|
|
# The release workflow may have created the release already (to attach the binaries).
|
|
if "$GH" release view "v$VERSION" >/dev/null 2>&1; then
|
|
printf '%s\n' "$NOTES" | "$GH" release edit "v$VERSION" --title "OpenPU $VERSION" --notes-file -
|
|
else
|
|
printf '%s\n' "$NOTES" | "$GH" release create "v$VERSION" --verify-tag --title "OpenPU $VERSION" --notes-file -
|
|
fi
|
|
else
|
|
echo "gh not found: create the GitHub release for v$VERSION by hand" >&2
|
|
fi
|