diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 194f981..6d3cd21 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -23,7 +23,7 @@ jobs: run: uv python install ${{ matrix.python-version }} - name: Install dependencies - run: uv sync --extra dev + run: uv sync --group dev - name: Lint run: uv run ruff check . @@ -53,7 +53,7 @@ jobs: uses: astral-sh/setup-uv@v7 - name: Install dependencies - run: uv sync --extra docs + run: uv sync --group docs - name: Build docs run: uv run mkdocs build diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 43ce4e9..4a4cce8 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -7,7 +7,7 @@ on: branches: [main] workflow_dispatch: # Manual trigger workflow_run: - workflows: ["Release (Manual)", "Release Please"] + workflows: ["Publish"] types: [completed] permissions: @@ -32,7 +32,7 @@ jobs: uses: astral-sh/setup-uv@v7 - name: Install dependencies - run: uv sync --extra docs + run: uv sync --group docs - name: Build docs run: uv run mkdocs build diff --git a/.github/workflows/latest-deps.yml b/.github/workflows/latest-deps.yml index a8cd16f..80dfe7f 100644 --- a/.github/workflows/latest-deps.yml +++ b/.github/workflows/latest-deps.yml @@ -25,7 +25,7 @@ jobs: run: uv python install ${{ matrix.python-version }} - name: Install with latest dependencies - run: uv sync --extra dev --upgrade + run: uv sync --group dev --upgrade - name: Test run: uv run pytest --cov=xarray_plotly diff --git a/.github/workflows/pr-title.yml b/.github/workflows/pr-title.yml index 21f5b40..a745662 100644 --- a/.github/workflows/pr-title.yml +++ b/.github/workflows/pr-title.yml @@ -2,7 +2,7 @@ name: PR Title Check on: pull_request: - types: [opened, edited, synchronize, reopened] + types: [opened, edited, reopened] jobs: validate: diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml new file mode 100644 index 0000000..9c56a3a --- /dev/null +++ b/.github/workflows/publish.yaml @@ -0,0 +1,71 @@ +name: Publish + +on: + push: + tags: ["v*"] + workflow_call: + inputs: + tag: + required: true + type: string + +concurrency: + group: publish-${{ inputs.tag || github.ref_name }} + cancel-in-progress: false + +permissions: + contents: write + id-token: write + attestations: write + +jobs: + publish: + name: Build & publish to PyPI + runs-on: ubuntu-24.04 + timeout-minutes: 10 + environment: + name: pypi + url: https://pypi.org/project/xarray_plotly + steps: + - uses: actions/checkout@v4 + with: + ref: ${{ inputs.tag || github.ref_name }} + fetch-depth: 0 + + - uses: astral-sh/setup-uv@v7 + with: + enable-cache: true + + - uses: actions/setup-python@v5 + with: + python-version: "3.12" + + - name: Build + run: uv build + + - uses: pypa/gh-action-pypi-publish@release/v1 + + github-release: + name: Create GitHub Release + needs: [publish] + if: github.event_name == 'push' && needs.publish.result == 'success' + runs-on: ubuntu-24.04 + steps: + - uses: actions/checkout@v4 + with: + ref: ${{ github.ref_name }} + + - name: Create GitHub Release + run: | + if gh release view "$TAG" &>/dev/null; then + echo "Release $TAG already exists, skipping." + exit 0 + fi + if [[ "$TAG" == *-* ]]; then + gh release create "$TAG" --generate-notes --prerelease + else + gh release create "$TAG" --generate-notes + fi + env: + GH_TOKEN: ${{ github.token }} + TAG: ${{ github.ref_name }} diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml deleted file mode 100644 index b3c6943..0000000 --- a/.github/workflows/publish.yml +++ /dev/null @@ -1,43 +0,0 @@ -name: Publish - -on: - workflow_dispatch: - inputs: - tag: - description: 'Release tag to publish (e.g. v0.0.15)' - required: true - type: string - workflow_call: - inputs: - tag: - required: true - type: string - -jobs: - publish: - name: Build & publish to PyPI - runs-on: ubuntu-24.04 - timeout-minutes: 10 - environment: - name: pypi - url: https://pypi.org/project/xarray_plotly - permissions: - id-token: write - steps: - - uses: actions/checkout@v6 - with: - ref: ${{ inputs.tag }} - fetch-depth: 0 - - - uses: astral-sh/setup-uv@v7 - with: - enable-cache: true - - - uses: actions/setup-python@v6 - with: - python-version: "3.12" - - - name: Build - run: uv build - - - uses: pypa/gh-action-pypi-publish@release/v1 diff --git a/.github/workflows/release-please.yml b/.github/workflows/release-please.yml deleted file mode 100644 index b50c60d..0000000 --- a/.github/workflows/release-please.yml +++ /dev/null @@ -1,42 +0,0 @@ -name: Release Please - -on: - push: - branches: - - main - -permissions: - contents: write - pull-requests: write - id-token: write # for PyPI trusted publishing - -jobs: - release-please: - runs-on: ubuntu-latest - outputs: - release_created: ${{ steps.release.outputs.release_created }} - tag_name: ${{ steps.release.outputs.tag_name }} - steps: - - uses: googleapis/release-please-action@v4 - id: release - with: - config-file: .release-please-config.json - manifest-file: .release-please-manifest.json - - publish: - needs: release-please - if: ${{ needs.release-please.outputs.release_created }} - runs-on: ubuntu-latest - permissions: - id-token: write - steps: - - uses: actions/checkout@v6 - - - name: Install uv - uses: astral-sh/setup-uv@v7 - - - name: Build package - run: uv build - - - name: Publish to PyPI - uses: pypa/gh-action-pypi-publish@release/v1 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yaml similarity index 67% rename from .github/workflows/release.yml rename to .github/workflows/release.yaml index c1b7665..14a1f18 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yaml @@ -3,16 +3,6 @@ name: Release on: push: branches: [main] - workflow_dispatch: - inputs: - branch: - description: Branch to create the release from - required: true - default: main - prerelease: - description: Create a pre-release - type: boolean - default: false permissions: contents: write @@ -35,17 +25,17 @@ jobs: - uses: googleapis/release-please-action@v4 id: release with: + token: ${{ steps.app-token.outputs.token }} config-file: .release-please-config.json manifest-file: .release-please-manifest.json - token: ${{ steps.app-token.outputs.token }} - target-branch: ${{ inputs.branch || github.ref_name }} - prerelease: ${{ inputs.prerelease }} publish: - needs: [release-please] + needs: release-please if: needs.release-please.outputs.release_created permissions: id-token: write - uses: ./.github/workflows/publish.yml + contents: write + attestations: write + uses: ./.github/workflows/publish.yaml with: tag: ${{ needs.release-please.outputs.tag_name }} diff --git a/.readthedocs.yaml b/.readthedocs.yaml new file mode 100644 index 0000000..a287eb6 --- /dev/null +++ b/.readthedocs.yaml @@ -0,0 +1,18 @@ +version: 2 + +mkdocs: + configuration: mkdocs.yml + +build: + os: ubuntu-24.04 + tools: + python: "3.13" + jobs: + pre_create_environment: + - asdf plugin add uv + - asdf install uv latest + - asdf global uv latest + create_environment: + - uv venv "${READTHEDOCS_VIRTUALENV_PATH}" + install: + - UV_PROJECT_ENVIRONMENT="${READTHEDOCS_VIRTUALENV_PATH}" uv sync --frozen --group docs diff --git a/pyproject.toml b/pyproject.toml index 6ff34f0..692c1a2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -30,15 +30,7 @@ Homepage = "https://github.com/FBumann/xarray_plotly" Documentation = "https://fbumann.github.io/xarray_plotly" Repository = "https://github.com/FBumann/xarray_plotly" -[project.optional-dependencies] -dev = [ - "pytest==9.0.2", - "pytest-cov==7.0.0", - "mypy==1.19.1", - "ruff==0.15.7", - "pre-commit==4.5.1", - "nbstripout==0.9.1", -] +[dependency-groups] docs = [ "mkdocs==1.6.1", "mkdocs-material==9.7.6", @@ -47,6 +39,15 @@ docs = [ "mkdocs-plotly-plugin==0.1.3", "jupyter==1.1.1", ] +dev = [ + {include-group = "docs"}, + "pytest==9.0.2", + "pytest-cov==7.0.0", + "mypy==1.19.1", + "ruff==0.15.7", + "pre-commit==4.5.1", + "nbstripout==0.9.1", +] [project.entry-points."xarray.backends"] # Entry point for xarray to auto-register the accessor (xarray >= 2024.01)