Skip to content

Commit

Permalink
Add PyPI release CI
Browse files Browse the repository at this point in the history
Add PyPI package to README and update install docs

Add mkdocs jupyter plugin for docs

Add Python 3.9 to CI

Build example notebook in docs site

Fix README badge again

Rename repo and package to just 'datalab-api'

Fix release action

Add CHANGELOG to docs build

Add missing release CI file

Fix docs badge

Add CODEOWNERS

Separate release and publish workflows

Use 3.11 for build step

Fix release for the last time (tonight)
  • Loading branch information
ml-evs committed Apr 14, 2024
1 parent fbe3382 commit 3f5d785
Show file tree
Hide file tree
Showing 10 changed files with 134 additions and 17 deletions.
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* @ml-evs
3 changes: 3 additions & 0 deletions .github/utils/release_tag_msg.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
TAG_NAME

The full release changelog can be seen in the [online docs](https://datalab-python-api.readthedocs.io/latest/changelog).
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ jobs:
steps:
- uses: actions/checkout@v3

- name: Set up Python 3.10
- name: Set up Python 3.9
uses: actions/setup-python@v4
with:
python-version: "3.10"
python-version: "3.9"

- name: Install dependencies
run: |
Expand Down
103 changes: 103 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
name: Publish and release on PyPI

on:
release:
types:
- published

env:
PUBLISH_UPDATE_BRANCH: main
GIT_USER_NAME: datalab developers
GIT_USER_EMAIL: "datalab@odbx.science"

jobs:

release:
name: Release new version
runs-on: ubuntu-latest
permissions:
id-token: write
if: github.repository == 'datalab-org/datalab-api' && startsWith(github.ref, 'refs/tags/v')

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: true
fetch-depth: 0
ref: ${{ env.PUBLISH_UPDATE_BRANCH }}

- name: Update changelog
uses: CharMixer/auto-changelog-action@v1
with:
token: ${{ secrets.ORG_RELEASE_PAT }}
release_branch: ${{ env.PUBLISH_UPDATE_BRANCH }}
exclude_labels: "duplicate,question,invalid,wontfix,dependency_updates,skip_changelog"

- name: Configure git and commit CHANGELOG
run: |
git config --global user.email "${GIT_USER_EMAIL}"
git config --global user.name "${GIT_USER_NAME}"
git commit CHANGELOG.md -m "Release ${GITHUB_REF#refs/tags/}"
- name: Move tag to new HEAD
run: |
TAG_MSG=.github/utils/release_tag_msg.txt
sed -i "s|TAG_NAME|${GITHUB_REF#refs/tags/}|" "${TAG_MSG}"
git tag -af -F "${TAG_MSG}" ${GITHUB_REF#refs/tags/}
- name: Update '${{ env.PUBLISH_UPDATE_BRANCH }}'
uses: CasperWA/push-protected@v2
with:
token: ${{ secrets.ORG_RELEASE_PAT }}
branch: ${{ env.PUBLISH_UPDATE_BRANCH }}
unprotect_reviews: true
sleep: 15
force: true
tags: true

- name: Create release-specific changelog
uses: CharMixer/auto-changelog-action@v1
with:
token: ${{ secrets.ORG_RELEASE_PAT }}
release_branch: ${{ env.PUBLISH_UPDATE_BRANCH }}
since_tag: "${{ env.PREVIOUS_VERSION }}"
output: "release_changelog.md"
exclude_labels: "duplicate,question,invalid,wontfix,dependency_updates,CI,skip_changelog"

- name: Append changelog to release body
run: |
gh api /repos/${{ github.repository }}/releases/${{ github.event.release.id }} --jq '.body' > release_body.md
cat release_changelog.md >> release_body.md
gh api /repos/${{ github.repository }}/releases/${{ github.event.release.id }} -X PATCH -F body='@release_body.md'
env:
GITHUB_TOKEN: ${{ secrets.ORG_RELEASE_PAT }}

publish:
name: "Publish on PyPI"
runs-on: ubuntu-latest
permissions:
id-token: write
if: github.repository == 'datalab-org/datalab-api' && startsWith(github.ref, 'refs/tags/v')
needs: [release]

steps:

- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: true
fetch-depth: 0
ref: ${{ env.PUBLISH_UPDATE_BRANCH }}
- name: Set up Python 3.11
uses: actions/setup-python@v5
with:
python-version: '3.11'

- name: Build source distribution
run: |
pip install -U build
python -m build
- name: Publish package to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
22 changes: 12 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# <div align="center"><i>datalab</i> Python API</div>

<div align="center">
<a href="https://datalab-python-api.readthedocs.io/en/latest/?badge=stable">
<a href="https://datalab-python-api.readthedocs.io/en/stable/?badge=stable">
<img src="https://readthedocs.org/projects/datalab-python-api/badge/?version=stable"></img>
</a>
</div>

A simple Python API that can interact with [datalab](https://github.com/the-grey-group/datalab) instances.
A simple Python API that can interact with [*datalab*](https://github.com/the-grey-group/datalab) instances.

The idea here is to provide a set of utility functions and models for manipulating samples, cells, inventory, files, users and metadata associated with *datalab* entries in an automated way.

Expand All @@ -19,26 +19,28 @@ If you have any suggestions or feedback, please post it there.

## Installation

The API can be used by installing this repository with `pip`, ideally in a fresh Python environment (created using e.g., conda, virtualenv or other related tools -- if you're not sure about this, ask).
The API can be used by installing this repository with `pip`, ideally in a fresh Python 3.9+ environment (created using e.g., conda, virtualenv or other related tools -- if you're not sure about this, ask).

Either from PyPI, for the latest released version:

```shell
git clone git@github.com:datalab-org/datalab-python-api
cd datalab-python-api
pip install .
pip install datalab-api
```

or via (may require public release first):
or for the latest development version from GitHub:

```shell
pip install git+https://github.com/datalab-org/datalab-python-api
git clone git@github.com:datalab-org/datalab-api
cd datalab-api
pip install .
```

## Usage

Example usage as a Jupyter notebook can be found in the `examples` directory or
in the [online documentation](https://datalab-python-api.readthedocs.io/), as
in the [online documentation](https://datalab-api.readthedocs.io/), as
well as the full [API
documentation](https://datalab-python-api.readthedocs.io/en/latest/reference/).
documentation](https://datalab-api.readthedocs.io/en/latest/reference/).

### Authentication

Expand Down
2 changes: 2 additions & 0 deletions docs/.pages
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
nav:
- index.md
- reference.md
- "Example notebook": examples/client_example.ipynb
- changelog.md
1 change: 1 addition & 0 deletions docs/changelog.md
File renamed without changes.
12 changes: 8 additions & 4 deletions mkdocs.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
site_name: datalab-python-api
site_name: datalab-api
site_description: Documentation for the datalab Python API
site_url: https://the-datalab-python-api.readthedocs.io
site_url: https://datalab-api.readthedocs.io

theme:
name: material
Expand Down Expand Up @@ -32,8 +32,8 @@ theme:
features:
- content.code.copy

repo_name: datalab-org/datalab-python-api
repo_url: https://github.com/datalab-org/datalab-python-api
repo_name: datalab-org/datalab-api
repo_url: https://github.com/datalab-org/datalab-api

docs_dir: "./docs"

Expand Down Expand Up @@ -95,6 +95,10 @@ plugins:
- autorefs
- search:
lang: en
- mkdocs-jupyter:
execute: false
allow_errors: false
include_requirejs: true

watch:
- src
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ docs = [
"mkdocs",
"mkdocs-material",
"mkdocstrings[python-legacy]",
"mkdocs-awesome-pages-plugin"
"mkdocs-awesome-pages-plugin",
"mkdocs-jupyter",
]

cli = [
Expand Down

0 comments on commit 3f5d785

Please sign in to comment.