Skip to content

Commit daf4813

Browse files
authored
feat: REL-10782 Introduce server-ai and langchain packages (#69)
Follows on from #64 Arranging the project structure to align with the other SDK projects
2 parents b63dbb5 + 7860c15 commit daf4813

36 files changed

+601
-136
lines changed

.github/actions/build-docs/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: Build Documentation
2-
description: 'Build Documentation.'
2+
description: 'Build Documentation for a package'
33

44
runs:
55
using: composite

.github/actions/build/action.yml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
name: Build distribution files
2-
description: 'Build distribution files'
2+
description: 'Build distribution files for a package'
3+
inputs:
4+
workspace_path:
5+
description: 'Path to the package to build.'
6+
required: true
37
outputs:
48
package-hashes:
59
description: "base64-encoded sha256 hashes of distribution files"
@@ -10,10 +14,11 @@ runs:
1014
steps:
1115
- name: Build distribution files
1216
shell: bash
13-
run: poetry build
17+
run: make -C ${{ inputs.workspace_path }} build
18+
1419
- name: Hash build files for provenance
1520
id: package-hashes
1621
shell: bash
17-
working-directory: ./dist
22+
working-directory: ${{ inputs.workspace_path }}/dist
1823
run: |
1924
echo "package-hashes=$(sha256sum * | base64 -w0)" >> "$GITHUB_OUTPUT"

.github/actions/ci/action.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Shared CI Workflow
2+
description: 'Build, lint, and test a package'
3+
inputs:
4+
workspace_path:
5+
description: 'Path to the package to build/test.'
6+
required: true
7+
python_version:
8+
description: 'Python version to use'
9+
required: false
10+
default: '3.11'
11+
12+
runs:
13+
using: composite
14+
steps:
15+
- name: Set up Python ${{ inputs.python_version }}
16+
uses: actions/setup-python@v5
17+
with:
18+
python-version: ${{ inputs.python_version }}
19+
20+
- name: Install poetry
21+
uses: abatilo/actions-poetry@7b6d33e44b4f08d7021a1dee3c044e9c253d6439
22+
23+
- name: Install Dependencies
24+
shell: bash
25+
working-directory: ${{ inputs.workspace_path }}
26+
run: poetry install
27+
28+
- name: Lint
29+
shell: bash
30+
run: make -C ${{ inputs.workspace_path }} lint
31+
32+
- name: Test
33+
shell: bash
34+
run: make -C ${{ inputs.workspace_path }} test

.github/workflows/ci.yml

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -11,35 +11,28 @@ on:
1111
- '**.md'
1212

1313
jobs:
14-
linux:
14+
server-ai-linux:
1515
runs-on: ubuntu-latest
16-
1716
strategy:
1817
matrix:
1918
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
2019

2120
steps:
2221
- uses: actions/checkout@v4
23-
- name: Set up Python ${{ matrix.python-version }}
24-
uses: actions/setup-python@v5
25-
with:
26-
python-version: ${{ matrix.python-version }}
2722

28-
- name: Install poetry
29-
uses: abatilo/actions-poetry@7b6d33e44b4f08d7021a1dee3c044e9c253d6439
23+
- uses: ./.github/actions/ci
24+
with:
25+
workspace_path: packages/sdk/server-ai
26+
python_version: ${{ matrix.python-version }}
3027

3128
- uses: ./.github/actions/build
32-
- uses: ./.github/actions/build-docs
33-
34-
- name: Run tests
35-
run: make test
29+
with:
30+
workspace_path: packages/sdk/server-ai
3631

37-
- name: Verify typehints
38-
run: make lint
32+
- uses: ./.github/actions/build-docs
3933

40-
windows:
34+
server-ai-windows:
4135
runs-on: windows-latest
42-
4336
defaults:
4437
run:
4538
shell: powershell
@@ -50,6 +43,7 @@ jobs:
5043

5144
steps:
5245
- uses: actions/checkout@v4
46+
5347
- name: Set up Python ${{ matrix.python-version }}
5448
uses: actions/setup-python@v5
5549
with:
@@ -59,7 +53,8 @@ jobs:
5953
uses: abatilo/actions-poetry@7b6d33e44b4f08d7021a1dee3c044e9c253d6439
6054

6155
- name: Install requirements
56+
working-directory: packages/sdk/server-ai
6257
run: poetry install
6358

6459
- name: Run tests
65-
run: make test
60+
run: make -C packages/sdk/server-ai test
Lines changed: 163 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,67 +1,200 @@
1-
name: Run Release Please
1+
# This workflow handles both automated and manual package publishing:
2+
#
3+
# AUTOMATED PUBLISHING (on push to main):
4+
# - Triggered automatically when changes are pushed to the main branch
5+
# - Uses release-please to create releases based on conventional commits
6+
# - Publishes packages to PyPI automatically when release PRs are merged
7+
#
8+
# MANUAL PUBLISHING (via workflow_dispatch):
9+
# - Can be triggered manually from the Actions tab
10+
# - Allows publishing a specific package to PyPI
11+
# - Supports dry-run mode
12+
#
13+
name: release-please
214

315
on:
416
push:
5-
branches: [ main ]
17+
branches:
18+
- main
19+
workflow_dispatch:
20+
inputs:
21+
workspace_path:
22+
description: 'The workspace to publish'
23+
required: true
24+
default: 'packages/sdk/server-ai'
25+
type: choice
26+
options:
27+
- packages/sdk/server-ai
28+
- packages/ai-providers/server-ai-langchain
29+
dry_run:
30+
description: 'Is this a dry run. If so no package will be published.'
31+
type: boolean
32+
required: true
633

734
jobs:
8-
release-package:
35+
release-please:
936
runs-on: ubuntu-latest
1037
permissions:
11-
id-token: write # Needed if using OIDC to get release secrets.
12-
contents: write # Contents and pull-requests are for release-please to make releases.
13-
pull-requests: write
38+
contents: write # Needed for release-please to create releases.
39+
pull-requests: write # Needed for release-please to create/update PRs.
40+
if: github.event_name == 'push'
1441
outputs:
15-
release-created: ${{ steps.release.outputs.release_created }}
16-
upload-tag-name: ${{ steps.release.outputs.tag_name }}
17-
package-hashes: ${{ steps.build.outputs.package-hashes}}
42+
package-server-ai-released: ${{ steps.release.outputs['packages/sdk/server-ai--release_created'] }}
43+
package-server-ai-tag-name: ${{ steps.release.outputs['packages/sdk/server-ai--tag_name'] }}
44+
package-server-ai-langchain-released: ${{ steps.release.outputs['packages/ai-providers/server-ai-langchain--release_created'] }}
45+
package-server-ai-langchain-tag-name: ${{ steps.release.outputs['packages/ai-providers/server-ai-langchain--tag_name'] }}
1846
steps:
1947
- uses: googleapis/release-please-action@v4
2048
id: release
2149

50+
release-server-ai:
51+
runs-on: ubuntu-latest
52+
needs: ['release-please']
53+
permissions:
54+
id-token: write # Needed for OIDC to get release secrets from AWS.
55+
if: ${{ needs.release-please.outputs.package-server-ai-released == 'true' }}
56+
outputs:
57+
package-hashes: ${{ steps.build.outputs.package-hashes }}
58+
steps:
2259
- uses: actions/checkout@v4
23-
if: ${{ steps.release.outputs.releases_created == 'true' }}
2460
with:
25-
fetch-depth: 0 # If you only need the current version keep this.
61+
fetch-depth: 0
2662

2763
- uses: actions/setup-python@v5
28-
if: ${{ steps.release.outputs.releases_created == 'true' }}
2964
with:
30-
python-version: 3.9
65+
python-version: '3.11'
3166

3267
- name: Install poetry
33-
if: ${{ steps.release.outputs.releases_created == 'true' }}
3468
uses: abatilo/actions-poetry@7b6d33e44b4f08d7021a1dee3c044e9c253d6439
3569

70+
- uses: ./.github/actions/ci
71+
with:
72+
workspace_path: packages/sdk/server-ai
73+
74+
- uses: ./.github/actions/build
75+
id: build
76+
with:
77+
workspace_path: packages/sdk/server-ai
78+
3679
- uses: launchdarkly/gh-actions/actions/[email protected]
37-
if: ${{ steps.release.outputs.releases_created == 'true' }}
3880
name: 'Get PyPI token'
3981
with:
4082
aws_assume_role: ${{ vars.AWS_ROLE_ARN }}
4183
ssm_parameter_pairs: '/production/common/releasing/pypi/token = PYPI_AUTH_TOKEN'
4284

85+
- name: Publish to PyPI
86+
uses: pypa/gh-action-pypi-publish@release/v1
87+
with:
88+
password: ${{ env.PYPI_AUTH_TOKEN }}
89+
packages-dir: packages/sdk/server-ai/dist/
90+
91+
release-server-ai-langchain:
92+
runs-on: ubuntu-latest
93+
needs: ['release-please']
94+
permissions:
95+
id-token: write # Needed for OIDC to get release secrets from AWS.
96+
if: ${{ needs.release-please.outputs.package-server-ai-langchain-released == 'true' }}
97+
outputs:
98+
package-hashes: ${{ steps.build.outputs.package-hashes }}
99+
steps:
100+
- uses: actions/checkout@v4
101+
with:
102+
fetch-depth: 0
103+
104+
- uses: actions/setup-python@v5
105+
with:
106+
python-version: '3.11'
107+
108+
- name: Install poetry
109+
uses: abatilo/actions-poetry@7b6d33e44b4f08d7021a1dee3c044e9c253d6439
110+
111+
- uses: ./.github/actions/ci
112+
with:
113+
workspace_path: packages/ai-providers/server-ai-langchain
114+
43115
- uses: ./.github/actions/build
44116
id: build
45-
if: ${{ steps.release.outputs.releases_created == 'true' }}
117+
with:
118+
workspace_path: packages/ai-providers/server-ai-langchain
46119

47-
- uses: ./.github/actions/build-docs
48-
if: ${{ steps.release.outputs.releases_created == 'true' }}
120+
- uses: launchdarkly/gh-actions/actions/[email protected]
121+
name: 'Get PyPI token'
122+
with:
123+
aws_assume_role: ${{ vars.AWS_ROLE_ARN }}
124+
ssm_parameter_pairs: '/production/common/releasing/pypi/token = PYPI_AUTH_TOKEN'
49125

50-
- name: Publish package distributions to PyPI
51-
if: ${{ steps.release.outputs.releases_created == 'true' }}
52-
uses: pypa/gh-action-pypi-publish@release/v1
126+
- name: Publish to PyPI
127+
# Pin the action to a full 40-character commit SHA for security.
128+
# Release v1 commit SHA as of 2024-06-14:
129+
# https://github.com/pypa/gh-action-pypi-publish/releases/tag/v1.8.13
130+
# Commit SHA: 19af04270e8d898ea07a523bb392fa7fe98df87c
131+
uses: pypa/gh-action-pypi-publish@19af04270e8d898ea07a523bb392fa7fe98df87c
132+
with:
133+
password: ${{ env.PYPI_AUTH_TOKEN }}
134+
packages-dir: packages/ai-providers/server-ai-langchain/dist/
135+
136+
manual-publish:
137+
runs-on: ubuntu-latest
138+
if: github.event_name == 'workflow_dispatch'
139+
permissions:
140+
id-token: write # Needed for OIDC to get release secrets from AWS.
141+
contents: read # Needed for actions/checkout.
142+
steps:
143+
- uses: actions/checkout@v4
144+
145+
- uses: actions/setup-python@v5
146+
with:
147+
python-version: '3.11'
148+
149+
- name: Install poetry
150+
uses: abatilo/actions-poetry@7b6d33e44b4f08d7021a1dee3c044e9c253d6439
151+
152+
- uses: ./.github/actions/ci
153+
with:
154+
workspace_path: ${{ inputs.workspace_path }}
155+
156+
- uses: ./.github/actions/build
157+
id: build
158+
with:
159+
workspace_path: ${{ inputs.workspace_path }}
160+
161+
- uses: launchdarkly/gh-actions/actions/[email protected]
162+
if: ${{ inputs.dry_run != true }}
163+
name: 'Get PyPI token'
164+
with:
165+
aws_assume_role: ${{ vars.AWS_ROLE_ARN }}
166+
ssm_parameter_pairs: '/production/common/releasing/pypi/token = PYPI_AUTH_TOKEN'
167+
168+
- name: Publish to PyPI
169+
if: ${{ inputs.dry_run != true }}
170+
# https://github.com/pypa/gh-action-pypi-publish/releases/tag/v1.8.13 - pinned to commit on 2024-04-13
171+
uses: pypa/gh-action-pypi-publish@3cc2c35166dfc1e5ea3bb0491ffdeedcaa50d7c
53172
with:
54-
password: ${{env.PYPI_AUTH_TOKEN}}
173+
password: ${{ env.PYPI_AUTH_TOKEN }}
174+
packages-dir: ${{ inputs.workspace_path }}/dist/
175+
176+
release-server-ai-provenance:
177+
needs: ['release-please', 'release-server-ai']
178+
if: ${{ needs.release-please.outputs.package-server-ai-released == 'true' }}
179+
permissions:
180+
actions: read # Needed for detecting the GitHub Actions environment.
181+
id-token: write # Needed for provenance signing.
182+
contents: write # Needed for uploading assets to the release.
183+
uses: slsa-framework/slsa-github-generator/.github/workflows/[email protected]
184+
with:
185+
base64-subjects: "${{ needs.release-server-ai.outputs.package-hashes }}"
186+
upload-assets: true
187+
upload-tag-name: ${{ needs.release-please.outputs.package-server-ai-tag-name }}
55188

56-
release-provenance:
57-
needs: [ 'release-package' ]
58-
if: ${{ needs.release-package.outputs.release-created == 'true' }}
189+
release-server-ai-langchain-provenance:
190+
needs: ['release-please', 'release-server-ai-langchain']
191+
if: ${{ needs.release-please.outputs.package-server-ai-langchain-released == 'true' }}
59192
permissions:
60-
actions: read
61-
id-token: write
62-
contents: write
193+
actions: read # Needed for detecting the GitHub Actions environment.
194+
id-token: write # Needed for provenance signing.
195+
contents: write # Needed for uploading assets to the release.
63196
uses: slsa-framework/slsa-github-generator/.github/workflows/[email protected]
64197
with:
65-
base64-subjects: "${{ needs.release-package.outputs.package-hashes }}"
198+
base64-subjects: "${{ needs.release-server-ai-langchain.outputs.package-hashes }}"
66199
upload-assets: true
67-
upload-tag-name: ${{ needs.release-package.outputs.upload-tag-name }}
200+
upload-tag-name: ${{ needs.release-please.outputs.package-server-ai-langchain-tag-name }}

.release-please-manifest.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
{
2-
".": "0.10.1"
2+
"packages/sdk/server-ai": "0.10.1",
3+
"packages/ai-providers/server-ai-langchain": "0.1.0"
34
}

0 commit comments

Comments
 (0)