Michele Dolfi commited on
Commit
d78583d
·
unverified ·
1 Parent(s): 9cdf9cf

ci: add semantic release and build/publish python wheel (#41)

Browse files
.github/PULL_REQUEST_TEMPLATE.md ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!-- Thank you for contributing to Docling! -->
2
+
3
+ <!-- STEPS TO FOLLOW:
4
+ 1. Add a description of the changes (frequently the same as the commit description)
5
+ 2. Enter the issue number next to "Resolves #" below (if there is no tracking issue resolved, **remove that section**)
6
+ 3. Make sure the PR title follows the **Commit Message Formatting**: https://www.conventionalcommits.org/en/v1.0.0/#summary.
7
+ -->
8
+
9
+ <!-- Uncomment this section with the issue number if an issue is being resolved
10
+ **Issue resolved by this Pull Request:**
11
+ Resolves #
12
+ --->
.github/SECURITY.md ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Security and Disclosure Information Policy for the Docling Project
2
+
3
+ The Docling team and community take security bugs seriously. We appreciate your efforts to responsibly disclose your findings, and will make every effort to acknowledge your contributions.
4
+
5
+ ## Reporting a Vulnerability
6
+
7
+ If you think you've identified a security issue in an Docling project repository, please DO NOT report the issue publicly via the GitHub issue tracker, etc.
8
+
9
+ Instead, send an email with as many details as possible to [[email protected]](mailto:[email protected]). This is a private mailing list for the maintainers team.
10
+
11
+ Please do not create a public issue.
12
+
13
+ ## Security Vulnerability Response
14
+
15
+ Each report is acknowledged and analyzed by the core maintainers within 3 working days.
16
+
17
+ Any vulnerability information shared with core maintainers stays within the Docling project and will not be disseminated to other projects unless it is necessary to get the issue fixed.
18
+
19
+ After the initial reply to your report, the security team will keep you informed of the progress towards a fix and full announcement, and may ask for additional information or guidance.
20
+
21
+ ## Security Alerts
22
+
23
+ We will send announcements of security vulnerabilities and steps to remediate on the [Docling announcements](https://github.com/DS4SD/docling/discussions/categories/announcements).
.github/actions/setup-poetry/action.yml CHANGED
@@ -3,12 +3,12 @@ description: 'Set up a specific version of Poetry and install dependencies using
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:
 
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.12'
7
  runs:
8
  using: 'composite'
9
  steps:
10
  - name: Install poetry
11
+ run: pipx install poetry==1.8.5
12
  shell: bash
13
  - uses: actions/setup-python@v4
14
  with:
.github/mergify.yml ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ merge_protections:
2
+ - name: Enforce conventional commit
3
+ description: Make sure that we follow https://www.conventionalcommits.org/en/v1.0.0/
4
+ if:
5
+ - base = main
6
+ success_conditions:
7
+ - "title ~=
8
+ ^(fix|feat|docs|style|refactor|perf|test|build|ci|chore|revert)(?:\\(.+\
9
+ \\))?(!)?:"
.github/scripts/release.sh ADDED
@@ -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 ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ name: "Run CD"
2
+
3
+ on:
4
+ workflow_dispatch:
5
+
6
+ jobs:
7
+ code-checks:
8
+ uses: ./.github/workflows/job-checks.yml
9
+ pre-release-check:
10
+ runs-on: ubuntu-latest
11
+ outputs:
12
+ TARGET_TAG_V: ${{ steps.version_check.outputs.TRGT_VERSION }}
13
+ steps:
14
+ - uses: actions/checkout@v4
15
+ with:
16
+ fetch-depth: 0 # for fetching tags, required for semantic-release
17
+ - uses: ./.github/actions/setup-poetry
18
+ - name: Check version of potential release
19
+ id: version_check
20
+ run: |
21
+ TRGT_VERSION=$(poetry run semantic-release print-version)
22
+ echo "TRGT_VERSION=${TRGT_VERSION}" >> "$GITHUB_OUTPUT"
23
+ echo "${TRGT_VERSION}"
24
+ - name: Check notes of potential release
25
+ run: poetry run semantic-release changelog --unreleased
26
+ release:
27
+ needs: [code-checks, pre-release-check]
28
+ if: needs.pre-release-check.outputs.TARGET_TAG_V != ''
29
+ environment: auto-release
30
+ runs-on: ubuntu-latest
31
+ concurrency: release
32
+ steps:
33
+ - uses: actions/create-github-app-token@v1
34
+ id: app-token
35
+ with:
36
+ app-id: ${{ vars.CI_APP_ID }}
37
+ private-key: ${{ secrets.CI_PRIVATE_KEY }}
38
+ - uses: actions/checkout@v4
39
+ with:
40
+ token: ${{ steps.app-token.outputs.token }}
41
+ fetch-depth: 0 # for fetching tags, required for semantic-release
42
+ - uses: ./.github/actions/setup-poetry
43
+ - name: Run release script
44
+ env:
45
+ GH_TOKEN: ${{ steps.app-token.outputs.token }}
46
+ TARGET_VERSION: ${{ needs.pre-release-check.outputs.TARGET_TAG_V }}
47
+ CHGLOG_FILE: CHANGELOG.md
48
+ run: ./.github/scripts/release.sh
49
+ shell: bash
.github/workflows/ci-images-dryrun.yml ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ name: Dry run docling-serve image building
2
+
3
+ on:
4
+ workflow_call:
5
+
6
+ concurrency:
7
+ group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
8
+ cancel-in-progress: true
9
+
10
+ jobs:
11
+ build_cpu_image:
12
+ name: Build docling-serve "CPU only" container image
13
+ permissions:
14
+ packages: write
15
+ contents: read
16
+ attestations: write
17
+ id-token: write
18
+
19
+ uses: ./.github/workflows/job-image.yml
20
+ with:
21
+ publish: false
22
+ build_args: |
23
+ --build-arg CPU_ONLY=true
24
+ ghcr_image_name: ds4sd/docling-serve-cpu
25
+ quay_image_name: ""
26
+
27
+
28
+ build_gpu_image:
29
+ name: Build docling-serve (with GPU support) container image
30
+ permissions:
31
+ packages: write
32
+ contents: read
33
+ attestations: write
34
+ id-token: write
35
+
36
+ uses: ./.github/workflows/job-image.yml
37
+ with:
38
+ publish: false
39
+ build_args: |
40
+ --build-arg CPU_ONLY=false
41
+ ghcr_image_name: ds4sd/docling-serve
42
+ quay_image_name: ""
.github/workflows/ci.yml ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ name: "Run CI"
2
+
3
+ on:
4
+ push:
5
+ branches: ["main"]
6
+ pull_request:
7
+ branches: ["main"]
8
+
9
+ jobs:
10
+ code-checks:
11
+ # if: ${{ github.event_name == 'push' || (github.event.pull_request.head.repo.full_name != 'DS4SD/docling-serve' && github.event.pull_request.head.repo.full_name != 'ds4sd/docling-serve') }}
12
+ uses: ./.github/workflows/job-checks.yml
13
+ permissions:
14
+ packages: write
15
+ contents: read
16
+ attestations: write
17
+ id-token: write
18
+
19
+ build-images:
20
+ uses: ./.github/workflows/ci-images-dryrun.yml
21
+ permissions:
22
+ packages: write
23
+ contents: read
24
+ attestations: write
25
+ id-token: write
.github/workflows/images-dryrun.yml DELETED
@@ -1,105 +0,0 @@
1
- name: Dry run docling-serve image building
2
-
3
- on:
4
- pull_request:
5
- branches: ["main"]
6
-
7
- env:
8
- GHCR_REGISTRY: ghcr.io
9
- GHCR_DOCLING_SERVE_CPU_IMAGE_NAME: ds4sd/docling-serve-cpu
10
- GHCR_DOCLING_SERVE_GPU_IMAGE_NAME: ds4sd/docling-serve
11
-
12
- jobs:
13
- build_cpu_image:
14
- name: Build docling-serve "CPU only" container image
15
- runs-on: ubuntu-latest
16
- permissions:
17
- packages: write
18
- contents: read
19
- attestations: write
20
- id-token: write
21
-
22
- steps:
23
- - name: Check out the repo
24
- uses: actions/checkout@v4
25
-
26
- - name: Set up Docker Buildx
27
- uses: docker/setup-buildx-action@v3
28
-
29
- - name: Cache Docker layers
30
- uses: actions/cache@v4
31
- with:
32
- path: /tmp/.buildx-cache
33
- key: ${{ runner.os }}-buildx-${{ github.sha }}
34
- restore-keys: |
35
- ${{ runner.os }}-buildx-
36
-
37
- - name: Extract metadata (tags, labels) for docling-serve (CPU only) ghcr image
38
- id: ghcr_serve_cpu_meta
39
- uses: docker/metadata-action@v5
40
- with:
41
- images: ${{ env.GHCR_REGISTRY }}/${{ env.GHCR_DOCLING_SERVE_CPU_IMAGE_NAME }}
42
-
43
- - name: Build docling-serve-cpu image
44
- id: build-serve-cpu-ghcr
45
- uses: docker/build-push-action@v5
46
- with:
47
- context: .
48
- push: false
49
- tags: ${{ steps.ghcr_serve_cpu_meta.outputs.tags }}
50
- labels: ${{ steps.ghcr_serve_cpu_meta.outputs.labels }}
51
- platforms: linux/amd64, linux/arm64
52
- cache-from: type=gha
53
- cache-to: type=gha,mode=max
54
- file: Containerfile
55
- build-args: |
56
- --build-arg CPU_ONLY=true
57
-
58
- - name: Remove Local Docker Images
59
- run: |
60
- docker image prune -af
61
-
62
- build_gpu_image:
63
- name: Build docling-serve (with GPU support) container image
64
- runs-on: ubuntu-latest
65
- permissions:
66
- packages: write
67
- contents: read
68
- attestations: write
69
- id-token: write
70
-
71
- steps:
72
- - name: Check out the repo
73
- uses: actions/checkout@v4
74
-
75
- - name: Set up Docker Buildx
76
- uses: docker/setup-buildx-action@v3
77
-
78
- - name: Cache Docker layers
79
- uses: actions/cache@v4
80
- with:
81
- path: /tmp/.buildx-cache
82
- key: ${{ runner.os }}-buildx-${{ github.sha }}
83
- restore-keys: |
84
- ${{ runner.os }}-buildx-
85
-
86
- - name: Extract metadata (tags, labels) for docling-serve (GPU) ghcr image
87
- id: ghcr_serve_gpu_meta
88
- uses: docker/metadata-action@v5
89
- with:
90
- images: ${{ env.GHCR_REGISTRY }}/${{ env.GHCR_DOCLING_SERVE_GPU_IMAGE_NAME }}
91
-
92
- - name: Build docling-serve (GPU) image
93
- id: build-serve-gpu-ghcr
94
- uses: docker/build-push-action@v5
95
- with:
96
- context: .
97
- push: false
98
- tags: ${{ steps.ghcr_serve_gpu_meta.outputs.tags }}
99
- labels: ${{ steps.ghcr_serve_gpu_meta.outputs.labels }}
100
- platforms: linux/amd64,linux/arm64
101
- cache-from: type=gha
102
- cache-to: type=gha,mode=max
103
- file: Containerfile
104
- build-args: |
105
- --build-arg CPU_ONLY=false
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
.github/workflows/images.yml CHANGED
@@ -7,190 +7,52 @@ on:
7
  tags:
8
  - 'v*'
9
 
10
- env:
11
- GHCR_REGISTRY: ghcr.io
12
- GHCR_DOCLING_SERVE_CPU_IMAGE_NAME: ds4sd/docling-serve-cpu
13
- GHCR_DOCLING_SERVE_GPU_IMAGE_NAME: ds4sd/docling-serve
14
- QUAY_REGISTRY: quay.io
15
- QUAY_DOCLING_SERVE_CPU_IMAGE_NAME: ds4sd/docling-serve-cpu
16
- QUAY_DOCLING_SERVE_GPU_IMAGE_NAME: ds4sd/docling-serve
 
 
 
 
17
 
18
  jobs:
19
  build_and_publish_cpu_images:
20
  name: Push docling-serve "CPU only" container image to GHCR and QUAY
21
- runs-on: ubuntu-latest
22
- environment: registry-creds
23
  permissions:
24
  packages: write
25
  contents: read
26
  attestations: write
27
  id-token: write
 
28
 
29
- steps:
30
- - name: Check out the repo
31
- uses: actions/checkout@v4
 
 
 
 
 
32
 
33
- - name: Log in to the GHCR container image registry
34
- uses: docker/login-action@v3
35
- with:
36
- registry: ${{ env.GHCR_REGISTRY }}
37
- username: ${{ github.actor }}
38
- password: ${{ secrets.GITHUB_TOKEN }}
39
-
40
- - name: Log in to the Quay container image registry
41
- uses: docker/login-action@v3
42
- with:
43
- registry: ${{ env.QUAY_REGISTRY }}
44
- username: ${{ secrets.QUAY_USERNAME }}
45
- password: ${{ secrets.QUAY_TOKEN }}
46
-
47
- - name: Set up Docker Buildx
48
- uses: docker/setup-buildx-action@v3
49
-
50
- - name: Cache Docker layers
51
- uses: actions/cache@v4
52
- with:
53
- path: /tmp/.buildx-cache
54
- key: ${{ runner.os }}-buildx-${{ github.sha }}
55
- restore-keys: |
56
- ${{ runner.os }}-buildx-
57
-
58
- - name: Extract metadata (tags, labels) for docling-serve (CPU only) ghcr image
59
- id: ghcr_serve_cpu_meta
60
- uses: docker/metadata-action@v5
61
- with:
62
- images: ${{ env.GHCR_REGISTRY }}/${{ env.GHCR_DOCLING_SERVE_CPU_IMAGE_NAME }}
63
-
64
- - name: Build and push docling-serve-cpu image to ghcr.io
65
- id: push-serve-cpu-ghcr
66
- uses: docker/build-push-action@v5
67
- with:
68
- context: .
69
- push: true
70
- tags: ${{ steps.ghcr_serve_cpu_meta.outputs.tags }}
71
- labels: ${{ steps.ghcr_serve_cpu_meta.outputs.labels }}
72
- platforms: linux/amd64, linux/arm64
73
- cache-from: type=gha
74
- cache-to: type=gha,mode=max
75
- file: Containerfile
76
- build-args: |
77
- --build-arg CPU_ONLY=true
78
-
79
- - name: Generate artifact attestation
80
- uses: actions/attest-build-provenance@v1
81
- with:
82
- subject-name: ${{ env.GHCR_REGISTRY }}/${{ env.GHCR_DOCLING_SERVE_CPU_IMAGE_NAME}}
83
- subject-digest: ${{ steps.push-serve-cpu-ghcr.outputs.digest }}
84
- push-to-registry: true
85
-
86
- - name: Extract metadata (tags, labels) for docling-serve (CPU only) quay image
87
- id: quay_serve_cpu_meta
88
- uses: docker/metadata-action@v5
89
- with:
90
- images: ${{ env.QUAY_REGISTRY }}/${{ env.QUAY_DOCLING_SERVE_CPU_IMAGE_NAME }}
91
-
92
- - name: Build and push docling-serve-cpu image to quay.io
93
- id: push-serve-cpu-quay
94
- uses: docker/build-push-action@v5
95
- with:
96
- context: .
97
- push: true
98
- tags: ${{ steps.quay_serve_cpu_meta.outputs.tags }}
99
- labels: ${{ steps.quay_serve_cpu_meta.outputs.labels }}
100
- platforms: linux/amd64, linux/arm64
101
- cache-from: type=gha
102
- cache-to: type=gha,mode=max
103
- file: Containerfile
104
- build-args: |
105
- --build-arg CPU_ONLY=true
106
- - name: Remove Local Docker Images
107
- run: |
108
- docker image prune -af
109
 
110
  build_and_publish_gpu_images:
111
  name: Push docling-serve (with GPU support) container image to GHCR and QUAY
112
- runs-on: ubuntu-latest
113
- environment: registry-creds
114
  permissions:
115
  packages: write
116
  contents: read
117
  attestations: write
118
  id-token: write
119
 
120
- steps:
121
- - name: Check out the repo
122
- uses: actions/checkout@v4
123
-
124
- - name: Log in to the GHCR container image registry
125
- uses: docker/login-action@v3
126
- with:
127
- registry: ${{ env.GHCR_REGISTRY }}
128
- username: ${{ github.actor }}
129
- password: ${{ secrets.GITHUB_TOKEN }}
130
-
131
- - name: Log in to the Quay container image registry
132
- uses: docker/login-action@v3
133
- with:
134
- registry: ${{ env.QUAY_REGISTRY }}
135
- username: ${{ secrets.QUAY_USERNAME }}
136
- password: ${{ secrets.QUAY_TOKEN }}
137
-
138
- - name: Set up Docker Buildx
139
- uses: docker/setup-buildx-action@v3
140
-
141
- - name: Cache Docker layers
142
- uses: actions/cache@v4
143
- with:
144
- path: /tmp/.buildx-cache
145
- key: ${{ runner.os }}-buildx-${{ github.sha }}
146
- restore-keys: |
147
- ${{ runner.os }}-buildx-
148
-
149
- - name: Extract metadata (tags, labels) for docling-serve (GPU) ghcr image
150
- id: ghcr_serve_gpu_meta
151
- uses: docker/metadata-action@v5
152
- with:
153
- images: ${{ env.GHCR_REGISTRY }}/${{ env.GHCR_DOCLING_SERVE_GPU_IMAGE_NAME }}
154
-
155
- - name: Build and push docling-serve (GPU) image to ghcr.io
156
- id: push-serve-gpu-ghcr
157
- uses: docker/build-push-action@v5
158
- with:
159
- context: .
160
- push: true
161
- tags: ${{ steps.ghcr_serve_gpu_meta.outputs.tags }}
162
- labels: ${{ steps.ghcr_serve_gpu_meta.outputs.labels }}
163
- platforms: linux/amd64,linux/arm64
164
- cache-from: type=gha
165
- cache-to: type=gha,mode=max
166
- file: Containerfile
167
- build-args: |
168
- --build-arg CPU_ONLY=false
169
-
170
- - name: Generate artifact attestation
171
- uses: actions/attest-build-provenance@v1
172
- with:
173
- subject-name: ${{ env.GHCR_REGISTRY }}/${{ env.GHCR_DOCLING_SERVE_GPU_IMAGE_NAME}}
174
- subject-digest: ${{ steps.push-serve-gpu-ghcr.outputs.digest }}
175
- push-to-registry: true
176
-
177
- - name: Extract metadata (tags, labels) for docling-serve (GPU) quay image
178
- id: quay_serve_gpu_meta
179
- uses: docker/metadata-action@v5
180
- with:
181
- images: ${{ env.QUAY_REGISTRY }}/${{ env.QUAY_DOCLING_SERVE_GPU_IMAGE_NAME }}
182
 
183
- - name: Build and push docling-serve (GPU) image to quay.io
184
- id: push-serve-gpu-quay
185
- uses: docker/build-push-action@v5
186
- with:
187
- context: .
188
- push: true
189
- tags: ${{ steps.quay_serve_gpu_meta.outputs.tags }}
190
- labels: ${{ steps.quay_serve_gpu_meta.outputs.labels }}
191
- platforms: linux/amd64,linux/arm64
192
- cache-from: type=gha
193
- cache-to: type=gha,mode=max
194
- file: Containerfile
195
- build-args: |
196
- --build-arg CPU_ONLY=false
 
7
  tags:
8
  - 'v*'
9
 
10
+ # env:
11
+ # GHCR_REGISTRY: ghcr.io
12
+ # # GHCR_DOCLING_SERVE_CPU_IMAGE_NAME: ds4sd/docling-serve-cpu
13
+ # # GHCR_DOCLING_SERVE_GPU_IMAGE_NAME: ds4sd/docling-serve
14
+ # QUAY_REGISTRY: quay.io
15
+ # # QUAY_DOCLING_SERVE_CPU_IMAGE_NAME: ds4sd/docling-serve-cpu
16
+ # # QUAY_DOCLING_SERVE_GPU_IMAGE_NAME: ds4sd/docling-serve
17
+
18
+ concurrency:
19
+ group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
20
+ cancel-in-progress: true
21
 
22
  jobs:
23
  build_and_publish_cpu_images:
24
  name: Push docling-serve "CPU only" container image to GHCR and QUAY
 
 
25
  permissions:
26
  packages: write
27
  contents: read
28
  attestations: write
29
  id-token: write
30
+ secrets: inherit
31
 
32
+ uses: ./.github/workflows/job-image.yml
33
+ with:
34
+ publish: true
35
+ environment: registry-creds
36
+ build_args: |
37
+ --build-arg CPU_ONLY=true
38
+ ghcr_image_name: ds4sd/docling-serve-cpu
39
+ quay_image_name: ds4sd/docling-serve-cpu
40
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
41
 
42
  build_and_publish_gpu_images:
43
  name: Push docling-serve (with GPU support) container image to GHCR and QUAY
 
 
44
  permissions:
45
  packages: write
46
  contents: read
47
  attestations: write
48
  id-token: write
49
 
50
+ uses: ./.github/workflows/job-image.yml
51
+ with:
52
+ publish: true
53
+ environment: registry-creds
54
+ build_args: |
55
+ --build-arg CPU_ONLY=false
56
+ ghcr_image_name: ds4sd/docling-serve
57
+ quay_image_name: ds4sd/docling-serve
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
58
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
.github/workflows/{checks.yml → job-checks.yml} RENAMED
@@ -1,20 +1,14 @@
1
- name: Run linter checks
2
- on:
3
- push:
4
- branches: ["main"]
5
- pull_request:
6
- branches: ["main"]
7
 
8
- concurrency:
9
- group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
10
- cancel-in-progress: true
11
 
12
  jobs:
13
  py-lint:
14
  runs-on: ubuntu-latest
15
  strategy:
16
  matrix:
17
- python-version: ['3.11']
18
  steps:
19
  - uses: actions/checkout@v4
20
  - uses: ./.github/actions/setup-poetry
 
1
+ name: Run checks
 
 
 
 
 
2
 
3
+ on:
4
+ workflow_call:
 
5
 
6
  jobs:
7
  py-lint:
8
  runs-on: ubuntu-latest
9
  strategy:
10
  matrix:
11
+ python-version: ['3.12']
12
  steps:
13
  - uses: actions/checkout@v4
14
  - uses: ./.github/actions/setup-poetry
.github/workflows/job-image.yml ADDED
@@ -0,0 +1,145 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ name: Build docling-serve container image
2
+
3
+ on:
4
+ workflow_call:
5
+ inputs:
6
+ build_args:
7
+ type: string
8
+ description: "Extra build arguments for the build."
9
+ default: ""
10
+ ghcr_image_name:
11
+ type: string
12
+ description: "Name of the image for GHCR."
13
+ quay_image_name:
14
+ type: string
15
+ description: "Name of the image Quay."
16
+ platforms:
17
+ type: string
18
+ description: "Platform argument for building images."
19
+ default: linux/amd64, linux/arm64
20
+ publish:
21
+ type: boolean
22
+ description: "If true, the images will be published."
23
+ default: false
24
+ environment:
25
+ type: string
26
+ description: "GH Action environment"
27
+ default: ""
28
+
29
+ env:
30
+ GHCR_REGISTRY: ghcr.io
31
+ # GHCR_DOCLING_SERVE_CPU_IMAGE_NAME: ds4sd/docling-serve-cpu
32
+ # GHCR_DOCLING_SERVE_GPU_IMAGE_NAME: ds4sd/docling-serve
33
+ QUAY_REGISTRY: quay.io
34
+ # QUAY_DOCLING_SERVE_CPU_IMAGE_NAME: ds4sd/docling-serve-cpu
35
+ # QUAY_DOCLING_SERVE_GPU_IMAGE_NAME: ds4sd/docling-serve
36
+
37
+ jobs:
38
+ image:
39
+ runs-on: ubuntu-latest
40
+ permissions:
41
+ packages: write
42
+ contents: read
43
+ attestations: write
44
+ id-token: write
45
+ environment: ${{ inputs.environment }}
46
+
47
+ steps:
48
+ - name: Free up space in github runner
49
+ # Free space as indicated here : https://github.com/actions/runner-images/issues/2840#issuecomment-790492173
50
+ run: |
51
+ df -h
52
+ sudo rm -rf "/usr/local/share/boost"
53
+ sudo rm -rf "$AGENT_TOOLSDIRECTORY"
54
+ sudo rm -rf /usr/share/dotnet /opt/ghc /usr/local/lib/android /usr/local/share/powershell /usr/share/swift /usr/local/.ghcup
55
+ # shellcheck disable=SC2046
56
+ sudo docker rmi "$(docker image ls -aq)" >/dev/null 2>&1 || true
57
+ df -h
58
+
59
+ - name: Check out the repo
60
+ uses: actions/checkout@v4
61
+
62
+ - name: Log in to the GHCR container image registry
63
+ if: ${{ inputs.publish }}
64
+ uses: docker/login-action@v3
65
+ with:
66
+ registry: ${{ env.GHCR_REGISTRY }}
67
+ username: ${{ github.actor }}
68
+ password: ${{ secrets.GITHUB_TOKEN }}
69
+
70
+ - name: Log in to the Quay container image registry
71
+ if: ${{ inputs.publish }}
72
+ uses: docker/login-action@v3
73
+ with:
74
+ registry: ${{ env.QUAY_REGISTRY }}
75
+ username: ${{ secrets.QUAY_USERNAME }}
76
+ password: ${{ secrets.QUAY_TOKEN }}
77
+
78
+ - name: Set up Docker Buildx
79
+ uses: docker/setup-buildx-action@v3
80
+
81
+ - name: Cache Docker layers
82
+ uses: actions/cache@v4
83
+ with:
84
+ path: /tmp/.buildx-cache
85
+ key: ${{ runner.os }}-buildx-${{ github.sha }}
86
+ restore-keys: |
87
+ ${{ runner.os }}-buildx-
88
+
89
+ - name: Extract metadata (tags, labels) for docling-serve ghcr image
90
+ id: ghcr_meta
91
+ uses: docker/metadata-action@v5
92
+ with:
93
+ images: ${{ env.GHCR_REGISTRY }}/${{ inputs.ghcr_image_name }}
94
+
95
+ - name: Build and push image to ghcr.io
96
+ id: ghcr_push
97
+ uses: docker/build-push-action@v5
98
+ with:
99
+ context: .
100
+ push: ${{ inputs.publish }}
101
+ tags: ${{ steps.ghcr_meta.outputs.tags }}
102
+ labels: ${{ steps.ghcr_meta.outputs.labels }}
103
+ platforms: ${{ inputs.platforms}}
104
+ cache-from: type=gha
105
+ cache-to: type=gha,mode=max
106
+ file: Containerfile
107
+ build-args: ${{ inputs.build_args }}
108
+ # |
109
+ # --build-arg CPU_ONLY=true
110
+
111
+ - name: Generate artifact attestation
112
+ if: ${{ inputs.publish }}
113
+ uses: actions/attest-build-provenance@v1
114
+ with:
115
+ subject-name: ${{ env.GHCR_REGISTRY }}/${{ inputs.ghcr_image_name }}
116
+ subject-digest: ${{ steps.ghcr_push.outputs.digest }}
117
+ push-to-registry: true
118
+
119
+ - name: Extract metadata (tags, labels) for docling-serve quay image
120
+ if: ${{ inputs.publish }}
121
+ id: quay_meta
122
+ uses: docker/metadata-action@v5
123
+ with:
124
+ images: ${{ env.QUAY_REGISTRY }}/${{ inputs.quay_image_name }}
125
+
126
+ - name: Build and push image to quay.io
127
+ if: ${{ inputs.publish }}
128
+ # id: push-serve-cpu-quay
129
+ uses: docker/build-push-action@v5
130
+ with:
131
+ context: .
132
+ push: ${{ inputs.publish }}
133
+ tags: ${{ steps.quay_meta.outputs.tags }}
134
+ labels: ${{ steps.quay_meta.outputs.labels }}
135
+ platforms: ${{ inputs.platforms}}
136
+ cache-from: type=gha
137
+ cache-to: type=gha,mode=max
138
+ file: Containerfile
139
+ build-args: ${{ inputs.build_args }}
140
+ # |
141
+ # --build-arg CPU_ONLY=true
142
+
143
+ - name: Remove Local Docker Images
144
+ run: |
145
+ docker image prune -af
.github/workflows/pypi.yml ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ name: "Build and publish package"
2
+
3
+ on:
4
+ release:
5
+ types: [published]
6
+
7
+ permissions:
8
+ contents: read
9
+
10
+ jobs:
11
+ build-and-publish:
12
+ runs-on: ubuntu-latest
13
+ environment:
14
+ name: pypi
15
+ url: https://pypi.org/p/docling-serve # Replace <package-name> with your PyPI project name
16
+ permissions:
17
+ id-token: write # IMPORTANT: mandatory for trusted publishing
18
+ steps:
19
+ - uses: actions/checkout@v4
20
+ - uses: ./.github/actions/setup-poetry
21
+ - name: Build
22
+ run: poetry build
23
+ - name: Publish distribution 📦 to PyPI
24
+ uses: pypa/gh-action-pypi-publish@release/v1
25
+ with:
26
+ # currently not working with reusable workflows
27
+ attestations: false
.gitignore CHANGED
@@ -1,5 +1,7 @@
1
  model_artifacts/
2
  scratch/
 
 
3
 
4
  # Created by https://www.toptal.com/developers/gitignore/api/python,macos,virtualenv,pycharm,visualstudiocode,emacs,vim,jupyternotebooks
5
  # Edit at https://www.toptal.com/developers/gitignore?templates=python,macos,virtualenv,pycharm,visualstudiocode,emacs,vim,jupyternotebooks
 
1
  model_artifacts/
2
  scratch/
3
+ .md-lint
4
+ actionlint
5
 
6
  # Created by https://www.toptal.com/developers/gitignore/api/python,macos,virtualenv,pycharm,visualstudiocode,emacs,vim,jupyternotebooks
7
  # Edit at https://www.toptal.com/developers/gitignore?templates=python,macos,virtualenv,pycharm,visualstudiocode,emacs,vim,jupyternotebooks
poetry.lock CHANGED
The diff for this file is too large to render. See raw diff
 
pyproject.toml CHANGED
@@ -1,6 +1,6 @@
1
  [tool.poetry]
2
  name = "docling-serve"
3
- version = "0.2.0"
4
  description = "Running Docling as a service"
5
  license = "MIT"
6
  authors = [
@@ -97,6 +97,7 @@ pytest = "^8.3.4"
97
  pytest-asyncio = "^0.24.0"
98
  pytest-check = "^2.4.1"
99
  mypy = "^1.11.2"
 
100
 
101
  [build-system]
102
  requires = ["poetry-core"]
@@ -150,3 +151,16 @@ addopts = "-rA --color=yes --tb=short --maxfail=5"
150
  markers = [
151
  "asyncio",
152
  ]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  [tool.poetry]
2
  name = "docling-serve"
3
+ version = "0.2.0" # DO NOT EDIT, updated automatically
4
  description = "Running Docling as a service"
5
  license = "MIT"
6
  authors = [
 
97
  pytest-asyncio = "^0.24.0"
98
  pytest-check = "^2.4.1"
99
  mypy = "^1.11.2"
100
+ python-semantic-release = "^7.32.2"
101
 
102
  [build-system]
103
  requires = ["poetry-core"]
 
151
  markers = [
152
  "asyncio",
153
  ]
154
+
155
+ [tool.semantic_release]
156
+ # for default values check:
157
+ # https://github.com/python-semantic-release/python-semantic-release/blob/v7.32.2/semantic_release/defaults.cfg
158
+
159
+ version_source = "tag_only"
160
+ branch = "main"
161
+
162
+ # configure types which should trigger minor and patch version bumps respectively
163
+ # (note that they must be a subset of the configured allowed types):
164
+ parser_angular_allowed_types = "build,chore,ci,docs,feat,fix,perf,style,refactor,test"
165
+ parser_angular_minor_types = "feat"
166
+ parser_angular_patch_types = "fix,perf"