Felipe97/llama-cpp-compiled
01.2k
1#!/bin/bash2# Generate the description of a release: the previous release version, the3# change log and the link to the nightly release corresponding to the commit being released.4#5# Usage: make-release-desc.sh <version>6# <version>: current release version (v<maj>.<min>.<pat>, the leading v is optional)7#8# The previous version is the highest plain semver tag (v<maj>.<min>.<pat>)9# strictly below <version>. The change log lists all commits between the10# previous version tag and the release commit, one line per commit.11#12# The release commit is the commit <version> points at when the tag exists,13# HEAD otherwise. The nightly release is the b* tag pointing at that commit14# (release.yml tags the same commit); the link is only generated when that15# tag exists.16#17# Env (when running in GitHub Actions):18# GITHUB_OUTPUT: previous_tag, changelog_title, changelog, nightly and nightly_tag19# are written here20# GITHUB_REPOSITORY: owner/repo, used to build the nightly release URL (skipped when unset)21set -euo pipefail22 23if [[ $# -ne 1 ]]; then24 echo "Usage: $(basename "$0") <version>"25 exit 126fi27VERSION="$1"28 29# Accept the version with or without the leading v, reject anything else30if [[ "${VERSION}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then31 VERSION="v${VERSION}"32elif [[ ! "${VERSION}" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then33 echo "Error: invalid version '${VERSION}' (expected v<maj>.<min>.<pat>)"34 exit 135fi36 37# Make sure all remote tags are available locally (skipped on local runs without origin)38if ! git fetch --tags origin 2>/dev/null; then39 echo "Warning: could not fetch tags from origin (local run?)"40fi41 42# Release commit: the commit <version> points at when the tag exists, HEAD otherwise.43if ! RELEASE_COMMIT="$(git rev-parse -q --verify "refs/tags/${VERSION}^{commit}" 2>/dev/null)"; then44 RELEASE_COMMIT="$(git rev-parse HEAD)"45fi46 47echo "Release commit: $(git rev-parse --short "${RELEASE_COMMIT}")"48 49PREV="$( { git tag --list; echo "${VERSION}"; } \50 | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+$' \51 | sort -V \52 | awk -v cur="${VERSION}" '$0 == cur { exit } { prev = $0 } END { print prev }')"53 54if [[ -n "${PREV}" ]]; then55 CHANGELOG="$(git log --oneline "${PREV}..${RELEASE_COMMIT}")"56 CHANGELOG_TITLE="Changelog since ${PREV}"57else58 CHANGELOG="(no previous release tag found)"59 CHANGELOG_TITLE="Changelog"60fi61 62# Nightly release: the b* tag pointing at the release commit (|| true: no match is not an error)63NIGHTLY_TAG="$(git tag --points-at "${RELEASE_COMMIT}" | grep -E '(^|-)b[0-9]+(-[0-9a-f]{7})?$' | head -n 1 || true)"64 65NIGHTLY=""66if [[ -n "${NIGHTLY_TAG}" ]]; then67 if [[ -n "${GITHUB_REPOSITORY:-}" ]]; then68 NIGHTLY_URL="https://github.com/${GITHUB_REPOSITORY}/releases/tag/${NIGHTLY_TAG}"69 NIGHTLY="**Nightly build:** [${NIGHTLY_TAG}](${NIGHTLY_URL})"70 echo "Nightly release: ${NIGHTLY_URL}"71 fi72else73 echo "No nightly release found for commit $(git rev-parse --short "${RELEASE_COMMIT}")"74fi75 76echo "Previous version: ${PREV:-none}"77echo "${CHANGELOG}"78 79if [[ -n "${GITHUB_OUTPUT:-}" ]]; then80 {81 echo "previous_tag=${PREV}"82 echo "changelog_title=${CHANGELOG_TITLE}"83 echo "nightly=${NIGHTLY}"84 echo "nightly_tag=${NIGHTLY_TAG}"85 echo "changelog<<CHANGELOG_EOF"86 echo "${CHANGELOG}"87 echo "CHANGELOG_EOF"88 } >> "${GITHUB_OUTPUT}"89fi90 