From bc45a7fbe36361e80aa751c358940644b662bbe1 Mon Sep 17 00:00:00 2001 From: Greyson LaLonde Date: Fri, 6 Mar 2026 18:32:52 -0500 Subject: [PATCH] feat: create action for nightly releases --- .github/workflows/nightly.yml | 127 ++++++++++++++++++++++++++++++++++ 1 file changed, 127 insertions(+) create mode 100644 .github/workflows/nightly.yml diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml new file mode 100644 index 000000000..309014dfe --- /dev/null +++ b/.github/workflows/nightly.yml @@ -0,0 +1,127 @@ +name: Nightly Canary Release + +on: + schedule: + - cron: '0 6 * * *' # daily at 6am UTC + workflow_dispatch: + +jobs: + check: + name: Check for new commits + runs-on: ubuntu-latest + permissions: + contents: read + outputs: + has_changes: ${{ steps.check.outputs.has_changes }} + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Check for commits in last 24h + id: check + run: | + RECENT=$(git log --since="24 hours ago" --oneline | head -1) + if [ -n "$RECENT" ]; then + echo "has_changes=true" >> "$GITHUB_OUTPUT" + else + echo "has_changes=false" >> "$GITHUB_OUTPUT" + fi + + build: + name: Build nightly packages + needs: check + if: needs.check.outputs.has_changes == 'true' || github.event_name == 'workflow_dispatch' + runs-on: ubuntu-latest + permissions: + contents: read + steps: + - uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: "3.12" + + - name: Install uv + uses: astral-sh/setup-uv@v4 + + - name: Stamp nightly versions + run: | + DATE=$(date +%Y%m%d) + for init_file in \ + lib/crewai/src/crewai/__init__.py \ + lib/crewai-tools/src/crewai_tools/__init__.py \ + lib/crewai-files/src/crewai_files/__init__.py; do + CURRENT=$(python -c " + import re + text = open('$init_file').read() + print(re.search(r'__version__\s*=\s*\"(.*?)\"\s*$', text, re.MULTILINE).group(1)) + ") + NIGHTLY="${CURRENT}.dev${DATE}" + sed -i "s/__version__ = .*/__version__ = \"${NIGHTLY}\"/" "$init_file" + echo "$init_file: $CURRENT -> $NIGHTLY" + done + + # Update cross-package dependency pins to nightly versions + sed -i "s/\"crewai-tools==[^\"]*\"/\"crewai-tools==${NIGHTLY}\"/" lib/crewai/pyproject.toml + sed -i "s/\"crewai==[^\"]*\"/\"crewai==${NIGHTLY}\"/" lib/crewai-tools/pyproject.toml + echo "Updated cross-package dependency pins to ${NIGHTLY}" + + - name: Build packages + run: | + uv build --all-packages + rm dist/.gitignore + + - name: Upload artifacts + uses: actions/upload-artifact@v4 + with: + name: dist + path: dist/ + + publish: + name: Publish nightly to PyPI + needs: build + runs-on: ubuntu-latest + environment: + name: pypi + url: https://pypi.org/p/crewai + permissions: + id-token: write + contents: read + steps: + - uses: actions/checkout@v4 + + - name: Install uv + uses: astral-sh/setup-uv@v6 + with: + version: "0.8.4" + python-version: "3.12" + enable-cache: false + + - name: Download artifacts + uses: actions/download-artifact@v4 + with: + name: dist + path: dist + + - name: Publish to PyPI + env: + UV_PUBLISH_TOKEN: ${{ secrets.PYPI_API_TOKEN }} + run: | + failed=0 + for package in dist/*; do + if [[ "$package" == *"crewai_devtools"* ]]; then + echo "Skipping private package: $package" + continue + fi + echo "Publishing $package" + if ! uv publish "$package"; then + echo "Failed to publish $package" + failed=1 + fi + done + if [ $failed -eq 1 ]; then + echo "Some packages failed to publish" + exit 1 + fi \ No newline at end of file