Skip to content

Commit d0b06d3

Browse files
authored
chore: setup nightly releases (#808)
1 parent 2ff290d commit d0b06d3

13 files changed

+500
-34
lines changed

.github/scripts/deploy_docs.sh

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,10 @@ echo $GCP_KEY | base64 -d >> gcp_creds.json
66
gcloud auth activate-service-account --key-file gcp_creds.json
77
gcloud config set project ds-internal-db-ally
88

9-
# Build the documentation
10-
uv run mkdocs build
11-
129
# Upload built docs to a bucket
13-
gcloud storage cp -r site/* gs://ragbits-documentation
10+
gcloud storage rsync . gs://ragbits-documentation --recursive --delete-unmatched-destination-objects
1411

1512
# Invalidate cached content in the CDN
1613
gcloud compute url-maps invalidate-cdn-cache ragbits-documentation-lb \
17-
--path "/*" --async
14+
--path "/*" --async
15+
Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
name: Nightly Build
2+
3+
on:
4+
schedule:
5+
- cron: '0 2 * * *' # Daily at 2 AM UTC
6+
workflow_dispatch: # Manual trigger for testing
7+
8+
jobs:
9+
check-for-changes:
10+
runs-on: ubuntu-latest
11+
outputs:
12+
should-build: ${{ steps.check.outputs.should-build }}
13+
commit-hash: ${{ steps.check.outputs.commit-hash }}
14+
nightly-version: ${{ steps.check.outputs.nightly-version }}
15+
steps:
16+
- name: Checkout develop branch
17+
uses: actions/checkout@v4
18+
with:
19+
ref: develop
20+
fetch-depth: 0
21+
22+
- name: Check if nightly build needed
23+
id: check
24+
run: |
25+
# Get the latest commit hash on develop
26+
COMMIT_HASH=$(git rev-parse --short HEAD)
27+
echo "commit-hash=$COMMIT_HASH" >> "$GITHUB_OUTPUT"
28+
29+
# Check if we already built this commit as nightly
30+
LAST_NIGHTLY_TAG=$(git tag -l "*dev*" --sort=-version:refname | head -1)
31+
if [ -n "$LAST_NIGHTLY_TAG" ]; then
32+
# Get the commit that the last nightly tag points to
33+
LAST_NIGHTLY_COMMIT=$(git rev-list -n 1 $LAST_NIGHTLY_TAG)
34+
CURRENT_COMMIT=$(git rev-parse HEAD)
35+
if [ "$CURRENT_COMMIT" = "$LAST_NIGHTLY_COMMIT" ]; then
36+
echo "should-build=false" >> "$GITHUB_OUTPUT"
37+
echo "No new commits since last nightly build"
38+
exit 0
39+
fi
40+
fi
41+
42+
# Generate nightly version
43+
BASE_VERSION=$(python -c "
44+
try:
45+
import tomllib
46+
except ImportError:
47+
import tomli as tomllib
48+
with open('packages/ragbits/pyproject.toml', 'rb') as f:
49+
data = tomllib.load(f)
50+
print(data['project']['version'])
51+
")
52+
# Use timestamp for unique nightly version (PEP 440 compliant)
53+
TIMESTAMP=$(date +%Y%m%d%H%M)
54+
NIGHTLY_VERSION="${BASE_VERSION}.dev${TIMESTAMP}"
55+
56+
echo "should-build=true" >> "$GITHUB_OUTPUT"
57+
echo "nightly-version=$NIGHTLY_VERSION" >> "$GITHUB_OUTPUT"
58+
echo "Will build nightly version: $NIGHTLY_VERSION"
59+
60+
build-and-publish:
61+
needs: check-for-changes
62+
if: needs.check-for-changes.outputs.should-build == 'true'
63+
runs-on: ubuntu-latest
64+
steps:
65+
- name: Checkout develop branch
66+
uses: actions/checkout@v4
67+
with:
68+
ref: develop
69+
70+
- name: Install uv
71+
uses: astral-sh/setup-uv@v2
72+
with:
73+
version: ${{ vars.UV_VERSION || '0.6.9' }}
74+
75+
- name: Set up Python
76+
uses: actions/setup-python@v4
77+
with:
78+
python-version: "3.10"
79+
80+
- name: Update package versions for nightly
81+
run: |
82+
uv run scripts/update_nightly_versions.py "${{ needs.check-for-changes.outputs.nightly-version }}"
83+
84+
- name: Install dependencies
85+
run: |
86+
uv sync --all-extras
87+
88+
- name: Build packages
89+
run: |
90+
for dir in packages/*/; do
91+
echo "Building $dir"
92+
uv build "$dir" --out-dir dist
93+
done
94+
95+
- name: Publish to PyPI
96+
run: |
97+
uv tool run twine upload dist/* --verbose
98+
env:
99+
TWINE_USERNAME: __token__
100+
TWINE_REPOSITORY_URL: ${{ vars.PYPI_REPOSITORY_URL || 'https://test.pypi.org/legacy/' }}
101+
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
102+
103+
- name: Deploy nightly documentation
104+
shell: bash
105+
run: uv run mike deploy --push nightly
106+
107+
- name: Create git tag for nightly
108+
run: |
109+
git tag "${{ needs.check-for-changes.outputs.nightly-version }}"
110+
git push origin "${{ needs.check-for-changes.outputs.nightly-version }}"
111+
env:
112+
GH_TOKEN: ${{ secrets.GH_TOKEN }}
113+
114+
- name: Notify on failure
115+
if: failure()
116+
run: |
117+
echo "Nightly build failed for commit ${{ needs.check-for-changes.outputs.commit-hash }}"
118+
echo "Version attempted: ${{ needs.check-for-changes.outputs.nightly-version }}"

.github/workflows/prepare-release.yml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,20 @@ jobs:
3838
with:
3939
python-version: "3.10"
4040

41+
- name: Get base version from main branch
42+
id: base_version
43+
run: |
44+
# Get the latest version from main branch to use as base for version bump
45+
git fetch origin main
46+
BASE_VERSION=$(git show origin/main:packages/${{ github.event.inputs.packageName }}/pyproject.toml | grep 'version =' | cut -d '"' -f2 | head -1)
47+
echo "base-version=$BASE_VERSION" >> "$GITHUB_OUTPUT"
48+
echo "Using base version from main branch: $BASE_VERSION"
49+
4150
- name: Update packages
4251
id: packages_update
4352
run: |
44-
echo old_version=`grep version packages/${{ github.event.inputs.packageName }}/pyproject.toml | cut -d \" -f2` >> $GITHUB_OUTPUT
45-
uv run scripts/update_ragbits_package.py ${{ github.event.inputs.packageName }} ${{ github.event.inputs.updateType }}
53+
echo old_version=${{ steps.base_version.outputs.base-version }} >> $GITHUB_OUTPUT
54+
uv run scripts/update_ragbits_package.py ${{ github.event.inputs.packageName }} ${{ github.event.inputs.updateType }} ${{ steps.base_version.outputs.base-version }}
4655
echo new_version=`grep version packages/${{ github.event.inputs.packageName }}/pyproject.toml | cut -d \" -f2` >> $GITHUB_OUTPUT
4756
uv sync
4857

.github/workflows/publish-docs.yaml

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
name: Publish documentation
22

33
on:
4-
release:
4+
push:
55
branches:
6-
- main
6+
- gh-pages
77
workflow_dispatch:
88

99
jobs:
@@ -16,24 +16,6 @@ jobs:
1616
steps:
1717
- uses: actions/checkout@v4
1818

19-
- name: Install uv
20-
uses: astral-sh/setup-uv@v2
21-
with:
22-
version: ${{ vars.UV_VERSION || '0.6.9' }}
23-
24-
- name: Set up Python 3.10
25-
uses: actions/setup-python@v4
26-
with:
27-
python-version: "3.10"
28-
29-
- name: Cache Dependencies
30-
uses: actions/cache@v3
31-
with:
32-
path: ~/.cache/uv
33-
key: ${{ runner.os }}-pip-${{ hashFiles('**/pyproject.toml') }}
34-
restore-keys: |
35-
${{ runner.os }}-pip-
36-
3719
- name: Deploy docs
3820
shell: bash
3921
run: uv run ./.github/scripts/deploy_docs.sh

.github/workflows/publish-pypi.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,10 @@ jobs:
5252
env:
5353
TWINE_USERNAME: __token__
5454
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
55+
TWINE_REPOSITORY_URL: ${{ vars.PYPI_URL || 'https://test.pypi.org/legacy/' }}
56+
57+
- name: Deploy documentation
58+
run: |
59+
uv run mike deploy --push stable
60+
env:
61+
GH_TOKEN: ${{ secrets.GH_TOKEN }}
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
name: Sync Develop After Release
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
check-if-release:
10+
runs-on: ubuntu-latest
11+
outputs:
12+
is-release: ${{ steps.check.outputs.is-release }}
13+
release-version: ${{ steps.check.outputs.release-version }}
14+
steps:
15+
- name: Checkout main branch
16+
uses: actions/checkout@v4
17+
with:
18+
fetch-depth: 2
19+
20+
- name: Check if this is a release commit
21+
id: check
22+
run: |
23+
# Check if the latest commit message indicates a release
24+
COMMIT_MESSAGE=$(git log -1 --pretty=format:"%s")
25+
26+
if [[ "$COMMIT_MESSAGE" =~ ^release\(.+\):.*v([0-9]+\.[0-9]+\.[0-9]+)$ ]]; then
27+
echo "is-release=true" >> "$GITHUB_OUTPUT"
28+
RELEASE_VERSION=$(echo "$COMMIT_MESSAGE" | sed -n 's/.*v\([0-9]\+\.[0-9]\+\.[0-9]\+\).*/\1/p')
29+
echo "release-version=$RELEASE_VERSION" >> "$GITHUB_OUTPUT"
30+
echo "Detected release commit with version: $RELEASE_VERSION"
31+
else
32+
echo "is-release=false" >> "$GITHUB_OUTPUT"
33+
echo "Not a release commit"
34+
fi
35+
36+
sync-develop:
37+
needs: check-if-release
38+
if: needs.check-if-release.outputs.is-release == 'true'
39+
runs-on: ubuntu-latest
40+
steps:
41+
- name: Checkout repository
42+
uses: actions/checkout@v4
43+
with:
44+
token: ${{ secrets.GH_TOKEN }}
45+
fetch-depth: 0
46+
47+
- name: Install uv
48+
uses: astral-sh/setup-uv@v2
49+
with:
50+
version: ${{ vars.UV_VERSION || '0.6.9' }}
51+
52+
- name: Set up Python
53+
uses: actions/setup-python@v4
54+
with:
55+
python-version: "3.10"
56+
57+
- name: Configure Git
58+
run: |
59+
git config user.name "ds-ragbits-robot"
60+
git config user.email "[email protected]"
61+
62+
- name: Switch to develop and update versions
63+
run: |
64+
# Switch to develop branch
65+
git checkout develop
66+
git pull origin develop
67+
68+
# Calculate next development version
69+
RELEASE_VERSION="${{ needs.check-if-release.outputs.release-version }}"
70+
IFS='.' read -ra VERSION_PARTS <<< "$RELEASE_VERSION"
71+
MAJOR=${VERSION_PARTS[0]}
72+
MINOR=${VERSION_PARTS[1]}
73+
PATCH=${VERSION_PARTS[2]}
74+
75+
# Increment minor version for next development cycle
76+
NEXT_MINOR=$((MINOR + 1))
77+
NEXT_DEV_VERSION="$MAJOR.$NEXT_MINOR.0"
78+
79+
echo "Updating develop to base version: $NEXT_DEV_VERSION"
80+
81+
# Update all package versions to next development version
82+
uv run scripts/update_develop_versions.py "$NEXT_DEV_VERSION"
83+
84+
if git diff --quiet; then
85+
echo "No changes to commit"
86+
else
87+
git add .
88+
git commit -m "chore: bump develop base version to $NEXT_DEV_VERSION"
89+
git push origin develop
90+
echo "Successfully updated develop branch to version $NEXT_DEV_VERSION"
91+
fi
92+
env:
93+
GH_TOKEN: ${{ secrets.GH_TOKEN }}

README.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,26 @@
4949

5050
## Installation
5151

52-
To get started quickly, you can install with:
52+
### Stable Release
53+
54+
To get started quickly, you can install the latest stable release with:
5355

5456
```sh
5557
pip install ragbits
5658
```
5759

60+
### Nightly Builds
61+
62+
For the latest development features, you can install nightly builds that are automatically published from the `develop` branch:
63+
64+
```sh
65+
pip install ragbits --pre
66+
```
67+
68+
**Note:** Nightly builds include the latest features and bug fixes but may be less stable than official releases. They follow the version format `X.Y.Z.devYYYYMMDDHHMM`.
69+
70+
### Package Contents
71+
5872
This is a starter bundle of packages, containing:
5973

6074
- [`ragbits-core`](https://github.com/deepsense-ai/ragbits/tree/main/packages/ragbits-core) - fundamental tools for working with prompts, LLMs and vector databases.

mkdocs.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,11 @@ markdown_extensions:
156156
plugins:
157157
- search
158158
- autorefs
159+
- mike:
160+
version_selector: true
161+
css_dir: css
162+
javascript_dir: js
163+
canonical_version: null
159164
- mkdocstrings:
160165
handlers:
161166
python:
@@ -175,6 +180,8 @@ plugins:
175180
show_symbol_type_toc: true
176181
show_signature_annotations: true
177182
extra:
183+
version:
184+
provider: mike
178185
social:
179186
- icon: fontawesome/brands/github
180187
link: https://github.com/deepsense-ai

pyproject.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ dependencies = [
1212
"ragbits-guardrails[openai]",
1313
"ragbits-chat",
1414
"ragbits-agents[a2a,cli,mcp]",
15+
"mike>=2.1.3",
1516
]
1617

1718
[tool.uv]
@@ -29,6 +30,7 @@ dev-dependencies = [
2930
"mkdocs-click>=0.8.1",
3031
"mkdocstrings>=0.26.1",
3132
"mkdocstrings-python>=1.11.1",
33+
"mike>=2.1.0",
3234
"griffe>=1.3.2",
3335
"griffe-typingdoc>=0.2.7",
3436
"types-PyYAML>=6.0.2",

0 commit comments

Comments
 (0)