Skip to content

Commit 1df62ad

Browse files
authored
ci: workflow improvements (#310)
Signed-off-by: rmdg88 <rmdg88@gmail.com> Signed-off-by: Rui Dias Gomes <66125272+rmdg88@users.noreply.github.com>
1 parent e544947 commit 1df62ad

File tree

6 files changed

+345
-25
lines changed

6 files changed

+345
-25
lines changed

.github/scripts/release.sh

Lines changed: 46 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,38 +3,74 @@
33
set -e # trigger failure on error - do not remove!
44
set -x # display command on output
55

6+
## debug
7+
# TARGET_VERSION="1.2.x"
8+
69
if [ -z "${TARGET_VERSION}" ]; then
710
>&2 echo "No TARGET_VERSION specified"
811
exit 1
912
fi
1013
CHGLOG_FILE="${CHGLOG_FILE:-CHANGELOG.md}"
1114

12-
# update package version
15+
# Update package version
1316
uvx --from=toml-cli toml set --toml-path=pyproject.toml project.version "${TARGET_VERSION}"
1417
uv lock --upgrade-package docling-serve
1518

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
1737
REL_NOTES=$(mktemp)
1838
uv run --no-sync semantic-release changelog --unreleased >> "${REL_NOTES}"
1939

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
2149
TMP_CHGLOG=$(mktemp)
2250
TARGET_TAG_NAME="v${TARGET_VERSION}"
2351
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+
2965
mv "${TMP_CHGLOG}" "${CHGLOG_FILE}"
3066

31-
# push changes
67+
# Push changes
3268
git config --global user.name 'github-actions[bot]'
3369
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
3470
git add pyproject.toml uv.lock "${CHGLOG_FILE}"
3571
COMMIT_MSG="chore: bump version to ${TARGET_VERSION} [skip ci]"
3672
git commit -m "${COMMIT_MSG}"
3773
git push origin main
3874

39-
# create GitHub release (incl. Git tag)
75+
# Create GitHub release (incl. Git tag)
4076
gh release create "${TARGET_TAG_NAME}" -F "${REL_NOTES}"

.github/workflows/actionlint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
actionlint:
1414
runs-on: ubuntu-latest
1515
steps:
16-
- uses: actions/checkout@v4
16+
- uses: actions/checkout@v5
1717
- name: Download actionlint
1818
id: get_actionlint
1919
run: bash <(curl https://raw.githubusercontent.com/rhysd/actionlint/main/scripts/download-actionlint.bash)

.github/workflows/cd.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
outputs:
1212
TARGET_TAG_V: ${{ steps.version_check.outputs.TRGT_VERSION }}
1313
steps:
14-
- uses: actions/checkout@v4
14+
- uses: actions/checkout@v5
1515
with:
1616
fetch-depth: 0 # for fetching tags, required for semantic-release
1717
- name: Install uv and set the python version
@@ -40,7 +40,7 @@ jobs:
4040
with:
4141
app-id: ${{ vars.CI_APP_ID }}
4242
private-key: ${{ secrets.CI_PRIVATE_KEY }}
43-
- uses: actions/checkout@v4
43+
- uses: actions/checkout@v5
4444
with:
4545
token: ${{ steps.app-token.outputs.token }}
4646
fetch-depth: 0 # for fetching tags, required for semantic-release

.github/workflows/job-build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
matrix:
1111
python-version: ['3.12']
1212
steps:
13-
- uses: actions/checkout@v4
13+
- uses: actions/checkout@v5
1414
- name: Install uv and set the python version
1515
uses: astral-sh/setup-uv@v6
1616
with:

.github/workflows/job-checks.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
matrix:
1111
python-version: ['3.12']
1212
steps:
13-
- uses: actions/checkout@v4
13+
- uses: actions/checkout@v5
1414
- name: Install uv and set the python version
1515
uses: astral-sh/setup-uv@v6
1616
with:
@@ -61,7 +61,7 @@ jobs:
6161
markdown-lint:
6262
runs-on: ubuntu-latest
6363
steps:
64-
- uses: actions/checkout@v4
64+
- uses: actions/checkout@v5
6565
- name: markdownlint-cli2-action
6666
uses: DavidAnson/markdownlint-cli2-action@v16
6767
with:

0 commit comments

Comments
 (0)