-
Notifications
You must be signed in to change notification settings - Fork 8
ci: support release automatically #50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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}" | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -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 | ||||||||||||||
|
Comment on lines
+30
to
32
|
||||||||||||||
| python -m pip install "jupyterlab>=4.0.0,<5" hatch | |
| - name: Build Distribution | |
| run: hatch build | |
| python -m pip install "jupyterlab>=4.0.0,<5" build | |
| - name: Build Distribution | |
| run: python -m build |
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -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 | ||||||||||||||
|
Comment on lines
+28
to
30
|
||||||||||||||
| python -m pip install "jupyterlab>=4.0.0,<5" hatch | |
| - name: Build Distribution | |
| run: hatch build | |
| python -m pip install "jupyterlab>=4.0.0,<5" build | |
| - name: Build Distribution | |
| run: python -m build |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -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"] | ||||||
|
||||||
| requires = ["hatchling>=1.5.0", "jupyterlab>=4.0.0,<5", "hatch-nodejs-version", "hatch-jupyter-builder"] | |
| requires = ["hatchling>=1.5.0", "jupyterlab>=4.0.0,<5", "hatch-nodejs-version", "hatch-jupyter-builder>=0.5"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The repo’s documented/CI build path is
python -m build(RELEASE.md:39-40, .github/workflows/ci.yml:87-92), but this workflow useshatch build. Consider switching this step topython -m buildso the auto-release validation uses the same build mechanism as CI/publishing (and adjust the earlier dependency install accordingly).