diff --git a/.github/workflows/prepare-release-auto.yml b/.github/workflows/prepare-release-auto.yml new file mode 100644 index 0000000..aecfeeb --- /dev/null +++ b/.github/workflows/prepare-release-auto.yml @@ -0,0 +1,118 @@ +name: Prepare Release (Auto) + +on: + workflow_dispatch: + inputs: + bump: + description: Version bump type + required: true + default: patch + type: choice + options: + - patch + - minor + - major + +permissions: + contents: write + +concurrency: + group: prepare-release-${{ github.ref }} + cancel-in-progress: false + +jobs: + prepare_release: + name: Prepare Release + runs-on: ubuntu-latest + if: ${{ github.ref_name == 'master' }} + steps: + - name: Checkout Repository + uses: actions/checkout@v6 + with: + fetch-depth: 0 + + - name: Setup JupyterLab Maintainer Tools + uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1 + with: + python_version: "3.11" + pnpm_version: "10" + python_package_manager: "uv pip" + + - name: Install build dependencies + run: | + python -m pip install --upgrade pip + python -m pip install "jupyterlab>=4.0.0,<5" hatch + + - name: Bump package version + id: bump + env: + BUMP_TYPE: ${{ github.event.inputs.bump }} + run: | + python - <<'PY' + import json + import os + from pathlib import Path + + bump = os.environ["BUMP_TYPE"] + package_json = Path("package.json") + data = json.loads(package_json.read_text()) + + major, minor, patch = map(int, data["version"].split(".")) + if bump == "major": + major, minor, patch = major + 1, 0, 0 + elif bump == "minor": + minor, patch = minor + 1, 0 + elif bump == "patch": + patch += 1 + else: + raise ValueError(f"Unsupported bump type: {bump}") + + new_version = f"{major}.{minor}.{patch}" + data["version"] = new_version + package_json.write_text(json.dumps(data, indent=2) + "\n") + + with open(os.environ["GITHUB_OUTPUT"], "a", encoding="utf-8") as fh: + fh.write(f"new_version={new_version}\n") + PY + + - name: Install dependencies + run: pnpm install --frozen-lockfile + + - name: Run lint + run: pnpm run lint:check + + - name: Run tests + run: pnpm run test + + - name: Build distribution + run: hatch build + + - name: Commit release version + env: + VERSION: ${{ steps.bump.outputs.new_version }} + run: | + git config user.name "github-actions[bot]" + git config user.email "github-actions[bot]@users.noreply.github.com" + git add package.json + git commit -m "chore(release): v${VERSION}" + + - name: Push release commit + run: git push origin HEAD:master + + - name: Create and push release tag + env: + VERSION: ${{ steps.bump.outputs.new_version }} + run: | + git tag "v${VERSION}" + git push origin "v${VERSION}" + + - name: Create draft release + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + VERSION: ${{ steps.bump.outputs.new_version }} + run: | + gh release create "v${VERSION}" \ + --target master \ + --draft \ + --generate-notes \ + --title "v${VERSION}" diff --git a/.github/workflows/publish-test.yml b/.github/workflows/publish-test.yml index 81a0af5..58907a5 100644 --- a/.github/workflows/publish-test.yml +++ b/.github/workflows/publish-test.yml @@ -27,7 +27,7 @@ jobs: - name: Install build dependencies run: | python -m pip install --upgrade pip - python -m pip install "jupyterlab>=4.0.0,<5" hatch jupyter_builder + python -m pip install "jupyterlab>=4.0.0,<5" hatch - name: Build Distribution run: hatch build - name: Publish to TestPyPI diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index cef9fb9..12d649c 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -25,7 +25,7 @@ jobs: - name: Install build dependencies run: | python -m pip install --upgrade pip - python -m pip install "jupyterlab>=4.0.0,<5" hatch jupyter_builder + python -m pip install "jupyterlab>=4.0.0,<5" hatch - name: Build Distribution run: hatch build - name: Publish to PyPI diff --git a/pyproject.toml b/pyproject.toml index 0e079c8..06006dc 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -42,7 +42,7 @@ dev = [ [build-system] -requires = ["hatchling>=1.5.0", "jupyterlab>=4.0.0,<5", "hatch-nodejs-version", "jupyter_builder"] +requires = ["hatchling>=1.5.0", "jupyterlab>=4.0.0,<5", "hatch-nodejs-version", "hatch-jupyter-builder"] build-backend = "hatchling.build" [tool.hatch.version]