|
3 | 3 | set -e # trigger failure on error - do not remove! |
4 | 4 | set -x # display command on output |
5 | 5 |
|
| 6 | +## debug |
| 7 | +# TARGET_VERSION="1.2.x" |
| 8 | + |
6 | 9 | if [ -z "${TARGET_VERSION}" ]; then |
7 | 10 | >&2 echo "No TARGET_VERSION specified" |
8 | 11 | exit 1 |
9 | 12 | fi |
10 | 13 | CHGLOG_FILE="${CHGLOG_FILE:-CHANGELOG.md}" |
11 | 14 |
|
12 | | -# update package version |
| 15 | +# Update package version |
13 | 16 | uvx --from=toml-cli toml set --toml-path=pyproject.toml project.version "${TARGET_VERSION}" |
14 | 17 | uv lock --upgrade-package docling-serve |
15 | 18 |
|
16 | | -# collect release notes |
| 19 | +# Extract all docling packages and versions from uv.lock |
| 20 | +DOCVERSIONS=$(uvx --with toml python3 - <<'PY' |
| 21 | +import toml |
| 22 | +data = toml.load("uv.lock") |
| 23 | +for pkg in data.get("package", []): |
| 24 | + if pkg["name"].startswith("docling"): |
| 25 | + print(f"{pkg['name']} {pkg['version']}") |
| 26 | +PY |
| 27 | +) |
| 28 | + |
| 29 | +# Format docling versions list without trailing newline |
| 30 | +DOCLING_VERSIONS="### Docling libraries included in this release:" |
| 31 | +while IFS= read -r line; do |
| 32 | + DOCLING_VERSIONS+=" |
| 33 | +- $line" |
| 34 | +done <<< "$DOCVERSIONS" |
| 35 | + |
| 36 | +# Collect release notes |
17 | 37 | REL_NOTES=$(mktemp) |
18 | 38 | uv run --no-sync semantic-release changelog --unreleased >> "${REL_NOTES}" |
19 | 39 |
|
20 | | -# update changelog |
| 40 | +# Strip trailing blank lines from release notes and append docling versions |
| 41 | +{ |
| 42 | + sed -e :a -e '/^\n*$/{$d;N;};/\n$/ba' "${REL_NOTES}" |
| 43 | + printf "\n" |
| 44 | + printf "%s" "${DOCLING_VERSIONS}" |
| 45 | + printf "\n" |
| 46 | +} > "${REL_NOTES}.tmp" && mv "${REL_NOTES}.tmp" "${REL_NOTES}" |
| 47 | + |
| 48 | +# Update changelog |
21 | 49 | TMP_CHGLOG=$(mktemp) |
22 | 50 | TARGET_TAG_NAME="v${TARGET_VERSION}" |
23 | 51 | RELEASE_URL="$(gh repo view --json url -q ".url")/releases/tag/${TARGET_TAG_NAME}" |
24 | | -printf "## [${TARGET_TAG_NAME}](${RELEASE_URL}) - $(date -Idate)\n\n" >> "${TMP_CHGLOG}" |
25 | | -cat "${REL_NOTES}" >> "${TMP_CHGLOG}" |
26 | | -if [ -f "${CHGLOG_FILE}" ]; then |
27 | | - printf "\n" | cat - "${CHGLOG_FILE}" >> "${TMP_CHGLOG}" |
28 | | -fi |
| 52 | +## debug |
| 53 | +#RELEASE_URL="myrepo/releases/tag/${TARGET_TAG_NAME}" |
| 54 | + |
| 55 | +# Strip leading blank lines from existing changelog to avoid multiple blank lines when appending |
| 56 | +EXISTING_CL=$(sed -e :a -e '/^\n*$/{$d;N;};/\n$/ba' "${CHGLOG_FILE}") |
| 57 | + |
| 58 | +{ |
| 59 | + printf "## [${TARGET_TAG_NAME}](${RELEASE_URL}) - $(date -Idate)\n\n" |
| 60 | + cat "${REL_NOTES}" |
| 61 | + printf "\n" |
| 62 | + printf "%s\n" "${EXISTING_CL}" |
| 63 | +} >> "${TMP_CHGLOG}" |
| 64 | + |
29 | 65 | mv "${TMP_CHGLOG}" "${CHGLOG_FILE}" |
30 | 66 |
|
31 | | -# push changes |
| 67 | +# Push changes |
32 | 68 | git config --global user.name 'github-actions[bot]' |
33 | 69 | git config --global user.email 'github-actions[bot]@users.noreply.github.com' |
34 | 70 | git add pyproject.toml uv.lock "${CHGLOG_FILE}" |
35 | 71 | COMMIT_MSG="chore: bump version to ${TARGET_VERSION} [skip ci]" |
36 | 72 | git commit -m "${COMMIT_MSG}" |
37 | 73 | git push origin main |
38 | 74 |
|
39 | | -# create GitHub release (incl. Git tag) |
| 75 | +# Create GitHub release (incl. Git tag) |
40 | 76 | gh release create "${TARGET_TAG_NAME}" -F "${REL_NOTES}" |
0 commit comments