char-fork/llama.cpp

git clone https://git.t4t.associates/char-fork/llama.cpp

Georgi Gerganovci : add nightly-tag.txt to make-release (#27485)e467c2ff6

char/aliceai-t5-moe
3.3 KiB89 linesraw
1#!/bin/bash
2# Generate the description of a release: the previous release version, the
3# 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 the
10# 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 commit
14# (release.yml tags the same commit); the link is only generated when that
15# tag exists.
16#
17# Env (when running in GitHub Actions):
18#   GITHUB_OUTPUT: previous_tag, changelog_title, changelog, nightly and nightly_tag
19#     are written here
20#   GITHUB_REPOSITORY: owner/repo, used to build the nightly release URL (skipped when unset)
21set -euo pipefail
22
23if [[ $# -ne 1 ]]; then
24    echo "Usage: $(basename "$0") <version>"
25    exit 1
26fi
27VERSION="$1"
28
29# Accept the version with or without the leading v, reject anything else
30if [[ "${VERSION}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
31    VERSION="v${VERSION}"
32elif [[ ! "${VERSION}" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
33    echo "Error: invalid version '${VERSION}' (expected v<maj>.<min>.<pat>)"
34    exit 1
35fi
36
37# Make sure all remote tags are available locally (skipped on local runs without origin)
38if ! git fetch --tags origin 2>/dev/null; then
39    echo "Warning: could not fetch tags from origin (local run?)"
40fi
41
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)"; then
44    RELEASE_COMMIT="$(git rev-parse HEAD)"
45fi
46
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}" ]]; then
55    CHANGELOG="$(git log --oneline "${PREV}..${RELEASE_COMMIT}")"
56    CHANGELOG_TITLE="Changelog since ${PREV}"
57else
58    CHANGELOG="(no previous release tag found)"
59    CHANGELOG_TITLE="Changelog"
60fi
61
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}" ]]; then
67    if [[ -n "${GITHUB_REPOSITORY:-}" ]]; then
68        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    fi
72else
73    echo "No nightly release found for commit $(git rev-parse --short "${RELEASE_COMMIT}")"
74fi
75
76echo "Previous version: ${PREV:-none}"
77echo "${CHANGELOG}"
78
79if [[ -n "${GITHUB_OUTPUT:-}" ]]; then
80    {
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}"
89fi