diff --git a/.github/workflows/nightly-build.yml b/.github/workflows/nightly-build.yml new file mode 100644 index 000000000..678792cf0 --- /dev/null +++ b/.github/workflows/nightly-build.yml @@ -0,0 +1,62 @@ +name: Nightly Build and Publish + +on: + pull_request: + types: + - closed + schedule: + - cron: '0 0 * * *' + +jobs: + nightly_bump_and_publish: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Install uv + uses: astral-sh/setup-uv@v5 + with: + enable-cache: true + cache-dependency-glob: uv.lock + - name: Set up Python + run: uv python install 3.12 + - name: Check for changes on main + id: changes + run: | + git fetch origin main + git log --since="24 hours ago" origin/main --oneline > changes.txt + if [ -s changes.txt ]; then echo "changed=true" >> $GITHUB_OUTPUT; else echo "changed=false" >> $GITHUB_OUTPUT; fi + - name: Bump patch version + if: steps.changes.outputs.changed == 'true' + run: | + python -c " + import toml + import re + + # Read current version + with open('pyproject.toml', 'r') as f: + data = toml.load(f) + + current_version = data['project']['version'] + major, minor, patch = map(int, current_version.split('.')) + + # Bump patch version + new_version = f'{major}.{minor}.{patch + 1}' + data['project']['version'] = new_version + + # Write back + with open('pyproject.toml', 'w') as f: + toml.dump(data, f) + + print(f'Bumped version from {current_version} to {new_version}') + " + git config user.name "github-actions" + git config user.email "github-actions@github.com" + git add pyproject.toml + git commit -m "ci: nightly patch bump" + git push + - name: Build + if: steps.changes.outputs.changed == 'true' + run: uv build + - name: Publish to TestPyPI + if: steps.changes.outputs.changed == 'true' + run: uv publish --repository testpypi \ No newline at end of file