diff --git a/.github/workflows/check-release.yml b/.github/workflows/check-release.yml new file mode 100644 index 0000000..583b3ad --- /dev/null +++ b/.github/workflows/check-release.yml @@ -0,0 +1,76 @@ +name: Check for New Semble Release + +on: + schedule: + # Run weekly on Mondays at 9am UTC + - cron: "0 9 * * 1" + workflow_dispatch: + +permissions: + contents: write + +jobs: + check: + runs-on: ubuntu-latest + outputs: + new_version: ${{ steps.check.outputs.new_version }} + should_build: ${{ steps.check.outputs.should_build }} + + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Check for new semble release + id: check + run: | + # Get latest version from PyPI + LATEST=$(curl -s https://pypi.org/pypi/semble/json | python3 -c "import sys, json; print(json.load(sys.stdin)['info']['version'])") + echo "Latest semble version on PyPI: $LATEST" + + # Check if we already have a tag for this version + if git rev-parse "v${LATEST}" >/dev/null 2>&1; then + echo "Tag v${LATEST} already exists, skipping." + echo "should_build=false" >> "$GITHUB_OUTPUT" + else + echo "New version detected: ${LATEST}" + echo "new_version=${LATEST}" >> "$GITHUB_OUTPUT" + echo "should_build=true" >> "$GITHUB_OUTPUT" + fi + + update-and-build: + needs: check + if: needs.check.outputs.should_build == 'true' + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - name: Install uv + uses: astral-sh/setup-uv@v4 + with: + version: "latest" + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: "3.12" + + - name: Update semble dependency + run: | + VERSION=${{ needs.check.outputs.new_version }} + # Update pyproject.toml to pin the new version + sed -i "s/\"semble>=.*\"/\"semble>=${VERSION}\"/" pyproject.toml + sed -i "s/\"semble\[mcp\]>=.*\"/\"semble[mcp]>=${VERSION}\"/" pyproject.toml + # Update the lock file + uv lock + + - name: Commit and tag + run: | + VERSION=${{ needs.check.outputs.new_version }} + git config user.name "github-actions[bot]" + git config user.email "github-actions[bot]@users.noreply.github.com" + git add pyproject.toml uv.lock + git commit -m "chore: bump semble to v${VERSION}" || echo "No changes to commit" + git tag "v${VERSION}" + git push origin main --tags