|
| 1 | +name: Check for New Semble Release |
| 2 | + |
| 3 | +on: |
| 4 | + schedule: |
| 5 | + # Run weekly on Mondays at 9am UTC |
| 6 | + - cron: "0 9 * * 1" |
| 7 | + workflow_dispatch: |
| 8 | + |
| 9 | +permissions: |
| 10 | + contents: write |
| 11 | + |
| 12 | +jobs: |
| 13 | + check: |
| 14 | + runs-on: ubuntu-latest |
| 15 | + outputs: |
| 16 | + new_version: ${{ steps.check.outputs.new_version }} |
| 17 | + should_build: ${{ steps.check.outputs.should_build }} |
| 18 | + |
| 19 | + steps: |
| 20 | + - uses: actions/checkout@v4 |
| 21 | + with: |
| 22 | + fetch-depth: 0 |
| 23 | + |
| 24 | + - name: Check for new semble release |
| 25 | + id: check |
| 26 | + run: | |
| 27 | + # Get latest version from PyPI |
| 28 | + LATEST=$(curl -s https://pypi.org/pypi/semble/json | python3 -c "import sys, json; print(json.load(sys.stdin)['info']['version'])") |
| 29 | + echo "Latest semble version on PyPI: $LATEST" |
| 30 | +
|
| 31 | + # Check if we already have a tag for this version |
| 32 | + if git rev-parse "v${LATEST}" >/dev/null 2>&1; then |
| 33 | + echo "Tag v${LATEST} already exists, skipping." |
| 34 | + echo "should_build=false" >> "$GITHUB_OUTPUT" |
| 35 | + else |
| 36 | + echo "New version detected: ${LATEST}" |
| 37 | + echo "new_version=${LATEST}" >> "$GITHUB_OUTPUT" |
| 38 | + echo "should_build=true" >> "$GITHUB_OUTPUT" |
| 39 | + fi |
| 40 | +
|
| 41 | + update-and-build: |
| 42 | + needs: check |
| 43 | + if: needs.check.outputs.should_build == 'true' |
| 44 | + runs-on: ubuntu-latest |
| 45 | + |
| 46 | + steps: |
| 47 | + - uses: actions/checkout@v4 |
| 48 | + |
| 49 | + - name: Install uv |
| 50 | + uses: astral-sh/setup-uv@v4 |
| 51 | + with: |
| 52 | + version: "latest" |
| 53 | + |
| 54 | + - name: Set up Python |
| 55 | + uses: actions/setup-python@v5 |
| 56 | + with: |
| 57 | + python-version: "3.12" |
| 58 | + |
| 59 | + - name: Update semble dependency |
| 60 | + run: | |
| 61 | + VERSION=${{ needs.check.outputs.new_version }} |
| 62 | + # Update pyproject.toml to pin the new version |
| 63 | + sed -i "s/\"semble>=.*\"/\"semble>=${VERSION}\"/" pyproject.toml |
| 64 | + sed -i "s/\"semble\[mcp\]>=.*\"/\"semble[mcp]>=${VERSION}\"/" pyproject.toml |
| 65 | + # Update the lock file |
| 66 | + uv lock |
| 67 | +
|
| 68 | + - name: Commit and tag |
| 69 | + run: | |
| 70 | + VERSION=${{ needs.check.outputs.new_version }} |
| 71 | + git config user.name "github-actions[bot]" |
| 72 | + git config user.email "github-actions[bot]@users.noreply.github.com" |
| 73 | + git add pyproject.toml uv.lock |
| 74 | + git commit -m "chore: bump semble to v${VERSION}" || echo "No changes to commit" |
| 75 | + git tag "v${VERSION}" |
| 76 | + git push origin main --tags |
0 commit comments