Skip to content

Commit d0a59a1

Browse files
dolfim-ibmvagenas
andauthored
ci: Add CICD (#1)
* add badges to README Signed-off-by: Michele Dolfi <[email protected]> * add cicd workflows Signed-off-by: Michele Dolfi <[email protected]> * Update .github/actions/setup-poetry/action.yml Co-authored-by: Panos Vagenas <[email protected]> Signed-off-by: Michele Dolfi <[email protected]> * add semantic-release config Signed-off-by: Panos Vagenas <[email protected]> --------- Signed-off-by: Michele Dolfi <[email protected]> Signed-off-by: Michele Dolfi <[email protected]> Signed-off-by: Panos Vagenas <[email protected]> Co-authored-by: Panos Vagenas <[email protected]>
1 parent 7445296 commit d0a59a1

File tree

9 files changed

+196
-2
lines changed

9 files changed

+196
-2
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: 'Set up Poetry and install'
2+
description: 'Set up a specific version of Poetry and install dependencies using caching.'
3+
inputs:
4+
python-version:
5+
description: "Version range or exact version of Python or PyPy to use, using SemVer's version range syntax."
6+
default: '3.11'
7+
runs:
8+
using: 'composite'
9+
steps:
10+
- name: Install poetry
11+
run: pipx install poetry==1.8.3
12+
shell: bash
13+
- uses: actions/setup-python@v4
14+
with:
15+
python-version: ${{ inputs.python-version }}
16+
cache: 'poetry'
17+
- name: Install dependencies
18+
run: poetry install --all-extras
19+
shell: bash

.github/scripts/release.sh

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#!/bin/bash
2+
3+
set -e # trigger failure on error - do not remove!
4+
set -x # display command on output
5+
6+
if [ -z "${TARGET_VERSION}" ]; then
7+
>&2 echo "No TARGET_VERSION specified"
8+
exit 1
9+
fi
10+
CHGLOG_FILE="${CHGLOG_FILE:-CHANGELOG.md}"
11+
12+
# update package version
13+
poetry version "${TARGET_VERSION}"
14+
15+
# collect release notes
16+
REL_NOTES=$(mktemp)
17+
poetry run semantic-release changelog --unreleased >> "${REL_NOTES}"
18+
19+
# update changelog
20+
TMP_CHGLOG=$(mktemp)
21+
TARGET_TAG_NAME="v${TARGET_VERSION}"
22+
RELEASE_URL="$(gh repo view --json url -q ".url")/releases/tag/${TARGET_TAG_NAME}"
23+
printf "## [${TARGET_TAG_NAME}](${RELEASE_URL}) - $(date -Idate)\n\n" >> "${TMP_CHGLOG}"
24+
cat "${REL_NOTES}" >> "${TMP_CHGLOG}"
25+
if [ -f "${CHGLOG_FILE}" ]; then
26+
printf "\n" | cat - "${CHGLOG_FILE}" >> "${TMP_CHGLOG}"
27+
fi
28+
mv "${TMP_CHGLOG}" "${CHGLOG_FILE}"
29+
30+
# push changes
31+
git config --global user.name 'github-actions[bot]'
32+
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
33+
git add pyproject.toml "${CHGLOG_FILE}"
34+
COMMIT_MSG="chore: bump version to ${TARGET_VERSION} [skip ci]"
35+
git commit -m "${COMMIT_MSG}"
36+
git push origin main
37+
38+
# create GitHub release (incl. Git tag)
39+
gh release create "${TARGET_TAG_NAME}" -F "${REL_NOTES}"

.github/workflows/cd.yml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: "Run CD"
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
env:
9+
# disable keyring (https://github.com/actions/runner-images/issues/6185):
10+
PYTHON_KEYRING_BACKEND: keyring.backends.null.Keyring
11+
12+
jobs:
13+
docs:
14+
permissions:
15+
contents: write
16+
runs-on: ubuntu-latest
17+
steps:
18+
- uses: actions/checkout@v3
19+
- uses: ./.github/actions/setup-poetry
20+
- name: Build and push docs
21+
run: poetry run mkdocs gh-deploy --force
22+
code-checks:
23+
uses: ./.github/workflows/checks.yml
24+
pre-release-check:
25+
runs-on: ubuntu-latest
26+
outputs:
27+
TARGET_TAG_V: ${{ steps.version_check.outputs.TRGT_VERSION }}
28+
steps:
29+
- uses: actions/checkout@v3
30+
with:
31+
fetch-depth: 0 # for fetching tags, required for semantic-release
32+
- uses: ./.github/actions/setup-poetry
33+
- name: Check version of potential release
34+
id: version_check
35+
run: |
36+
TRGT_VERSION=$(poetry run semantic-release print-version)
37+
echo "TRGT_VERSION=${TRGT_VERSION}" >> $GITHUB_OUTPUT
38+
echo "${TRGT_VERSION}"
39+
- name: Check notes of potential release
40+
run: poetry run semantic-release changelog --unreleased
41+
release:
42+
needs: [code-checks, pre-release-check]
43+
if: needs.pre-release-check.outputs.TARGET_TAG_V != ''
44+
environment: auto-release
45+
runs-on: ubuntu-latest
46+
concurrency: release
47+
steps:
48+
- uses: actions/checkout@v3
49+
with:
50+
token: ${{ secrets.GH_PAT }}
51+
fetch-depth: 0 # for fetching tags, required for semantic-release
52+
- uses: ./.github/actions/setup-poetry
53+
- name: Run release script
54+
env:
55+
GH_TOKEN: ${{ secrets.GH_PAT }}
56+
TARGET_VERSION: ${{ needs.pre-release-check.outputs.TARGET_TAG_V }}
57+
CHGLOG_FILE: CHANGELOG.md
58+
run: ./.github/scripts/release.sh
59+
shell: bash

.github/workflows/checks.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
on:
2+
workflow_call:
3+
4+
jobs:
5+
run-checks:
6+
runs-on: ubuntu-latest
7+
strategy:
8+
matrix:
9+
python-version: ['3.11', '3.12']
10+
steps:
11+
- uses: actions/checkout@v3
12+
- uses: ./.github/actions/setup-poetry
13+
with:
14+
python-version: ${{ matrix.python-version }}
15+
- name: Run styling check
16+
run: poetry run pre-commit run --all-files

.github/workflows/ci.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: "Run CI"
2+
3+
on:
4+
pull_request:
5+
types: [opened, reopened, synchronize, ready_for_review]
6+
push:
7+
branches:
8+
- "**"
9+
- "!main"
10+
- "!gh-pages"
11+
12+
env:
13+
# disable keyring (https://github.com/actions/runner-images/issues/6185):
14+
PYTHON_KEYRING_BACKEND: keyring.backends.null.Keyring
15+
16+
jobs:
17+
code-checks:
18+
uses: ./.github/workflows/checks.yml

.github/workflows/pypi.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: "Build and publish package"
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
permissions:
8+
contents: read
9+
10+
env:
11+
# disable keyring (https://github.com/actions/runner-images/issues/6185):
12+
PYTHON_KEYRING_BACKEND: keyring.backends.null.Keyring
13+
14+
jobs:
15+
build-and-publish:
16+
runs-on: ubuntu-latest
17+
steps:
18+
- uses: actions/checkout@v3
19+
- uses: ./.github/actions/setup-poetry
20+
- name: Build and publish
21+
run: poetry publish --build --no-interaction --username=__token__ --password=${{ secrets.PYPI_TOKEN }}

CHANGELOG.md

Whitespace-only changes.

README.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,13 @@
1-
# Docling-models
1+
[![PyPI version](https://img.shields.io/pypi/v/docling-ibm-models)](https://pypi.org/project/docling-ibm-models/)
2+
![Python](https://img.shields.io/badge/python-3.11%20%7C%203.12-blue)
3+
[![Poetry](https://img.shields.io/endpoint?url=https://python-poetry.org/badge/v0.json)](https://python-poetry.org/)
4+
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
5+
[![Imports: isort](https://img.shields.io/badge/%20imports-isort-%231674b1?style=flat&labelColor=ef8336)](https://pycqa.github.io/isort/)
6+
[![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white)](https://github.com/pre-commit/pre-commit)
7+
[![Models on Hugging Face](https://img.shields.io/badge/%F0%9F%A4%97%20Hugging%20Face-Model-blue)](https://huggingface.co/ds4sd/docling-models/)
8+
[![License MIT](https://img.shields.io/github/license/ds4sd/deepsearch-toolkit)](https://opensource.org/licenses/MIT)
9+
10+
# Docling IBM models
211

312
AI modules to support the Dockling PDF document conversion project.
413

pyproject.toml

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "docling-ibm-models"
3-
version = "0.2.0"
3+
version = "0.2.0" # DO NOT EDIT, updated automatically
44
description = "This package contains the AI models used by the Docling PDF conversion package"
55
authors = ["Nikos Livathinos <[email protected]>", "Maxim Lysak <[email protected]>", "Ahmed Nassar <[email protected]>", "Christoph Auer <[email protected]>", "Michele Dolfi <[email protected]>", "Peter Staar <[email protected]>"]
66
license = "MIT"
@@ -64,3 +64,16 @@ include = '\.pyi?$'
6464
profile = "black"
6565
line_length = 88
6666
py_version=311
67+
68+
[tool.semantic_release]
69+
# for default values check:
70+
# https://github.com/python-semantic-release/python-semantic-release/blob/v7.32.2/semantic_release/defaults.cfg
71+
72+
version_source = "tag_only"
73+
branch = "main"
74+
75+
# configure types which should trigger minor and patch version bumps respectively
76+
# (note that they must be a subset of the configured allowed types):
77+
parser_angular_allowed_types = "build,chore,ci,docs,feat,fix,perf,style,refactor,test"
78+
parser_angular_minor_types = "feat"
79+
parser_angular_patch_types = "fix,perf"

0 commit comments

Comments
 (0)