From bcc0a88020be7f65a5968721fb2483df160a3023 Mon Sep 17 00:00:00 2001 From: Samuel Burbulla Date: Wed, 10 Apr 2024 17:21:14 +0200 Subject: [PATCH] Set up release pipeline. --- .bumpversion.toml | 5 ++++ .github/workflows/docs.yml | 20 ++++++++++++--- .github/workflows/publish.yml | 38 ++++++++++++++++++++++++++++ CONTRIBUTING.md | 17 +++++++++++++ README.md | 10 ++++++-- build_scripts/release.sh | 17 +++++++++++++ docs/getting-started/installation.md | 7 +++-- mkdocs.yml | 9 +++---- pyproject.toml | 10 ++++---- src/continuiti/__init__.py | 1 - 10 files changed, 113 insertions(+), 21 deletions(-) create mode 100644 .bumpversion.toml create mode 100644 .github/workflows/publish.yml create mode 100755 build_scripts/release.sh diff --git a/.bumpversion.toml b/.bumpversion.toml new file mode 100644 index 00000000..06b310ed --- /dev/null +++ b/.bumpversion.toml @@ -0,0 +1,5 @@ +[tool.bumpversion] +current_version = "0.1.0" + +[[tool.bumpversion.files]] +filename = "pyproject.toml" diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 2ca59af0..bd7b3af1 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -3,6 +3,9 @@ name: Documentation on: push: branches: [main] + release: + types: [published] + workflow_dispatch: permissions: contents: write @@ -15,13 +18,11 @@ jobs: uses: actions/checkout@v4 with: lfs: "true" + fetch-depth: 0 # fetch all commits/branches - name: Configure Git Credentials run: | git config user.name github-actions[bot] git config user.email github-actions[bot]@users.noreply.github.com - - uses: actions/setup-python@v4 - with: - python-version: 3.11 - name: Setup Python uses: actions/setup-python@v5 with: @@ -30,4 +31,15 @@ jobs: - name: Install run: | pip install ".[dev]" - - run: mkdocs gh-deploy --force + - name: Get Current Version + if: ${{ github.event_name == 'release' }} + run: | + export CURRENT_VERSION=$(bump-my-version show current_version) + echo CURRENT_VERSION=$CURRENT_VERSION >> $GITHUB_ENV + shell: bash + - name: Publish release + if: ${{ github.event_name == 'release' }} + run: mike deploy --push --update-aliases ${{ env.CURRENT_VERSION }} latest + - name: Publish development + if: ${{ github.event_name == 'push' }} + run: mike deploy development --push diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 00000000..186a5411 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,38 @@ +name: Publish package + +on: + release: + types: [published] + workflow_dispatch: + +jobs: + publish: + runs-on: ubuntu-latest + concurrency: + group: publish + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + lfs: "true" + - name: Setup Python + uses: actions/setup-python@v5 + with: + python-version: 3.11 + cache: "pip" + - name: Install + run: | + pip install ".[dev]" + - name: Get Current Version + run: | + export CURRENT_VERSION=$(bump-my-version show current_version) + echo CURRENT_VERSION=$CURRENT_VERSION >> $GITHUB_ENV + shell: bash + - name: Build and publish to PyPI + env: + TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} + TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} + run: | + python3 -m pip install --upgrade build twine + python3 -m build + python3 -m twine upload --verbose --non-interactive dist/* diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 1d291150..5d31375e 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -145,3 +145,20 @@ dark mode, add the tag *invertible-output*, i.e. ] ``` This applies a simple CSS-filter to the output image of the cell. + + +## Release process + +In order to create a new release, make sure that the project's venv is active +and the repository is clean and on the main branch. + +Create a new release using the script `build_scripts/release.sh`. +This script will create a release tag on the repository and bump +the version number: + +```shell +./build_scripts/release.sh +``` + +Afterwards, create a GitHub release for that tag. That will a trigger a CI +pipeline that will automatically create a package and publish it from CI to PyPI. diff --git a/README.md b/README.md index a94928dc..b466445a 100644 --- a/README.md +++ b/README.md @@ -18,11 +18,17 @@ operator learning is particularly useful in scientific machine learning, relevant benchmarks. ## Installation -Clone the repository and install the package using pip. +Install the package using pip: +```shell +pip install continuiti +``` + +Or install the latest development version from the repository: + ``` git clone https://github.com/aai-institute/continuiti.git cd continuiti -pip install -e . +pip install -e .[dev] ``` ## Usage diff --git a/build_scripts/release.sh b/build_scripts/release.sh new file mode 100755 index 00000000..cb674727 --- /dev/null +++ b/build_scripts/release.sh @@ -0,0 +1,17 @@ +# Usage: ./build_scripts/release.sh + +RELEASE_VERSION=$(bump-my-version show current_version) +MAIN=main + +echo "Checking out $MAIN branch" +git checkout $MAIN +git pull origin $MAIN + +echo "Creating tag $RELEASE_BRANCH" +git tag -a "$RELEASE_VERSION" -m "Release ${RELEASE_VERSION}" +git push --tags origin $MAIN + +echo "Bumping to next patch version" +bump-my-version bump --commit patch + +git push origin $MAIN diff --git a/docs/getting-started/installation.md b/docs/getting-started/installation.md index 06b898be..7c428f5c 100644 --- a/docs/getting-started/installation.md +++ b/docs/getting-started/installation.md @@ -7,13 +7,12 @@ alias: # Installing continuiti -To install the latest development version use: +Install the latest version of **continuiti** using pip: ``` -git clone https://github.com/aai-institute/continuiti.git -cd continuiti -pip install -e . +pip install continuiti ``` + ## Dependencies **continuiti** requires Python>=3.9 and is built on top of diff --git a/mkdocs.yml b/mkdocs.yml index 1fcbce83..824640b1 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -33,11 +33,10 @@ plugins: caption_position: bottom - macros - mike: - canonical_version: stable + canonical_version: latest - search - section-index - alias: - use_relative_link: true verbose: true - gen-files: scripts: @@ -131,12 +130,12 @@ extra: copyright_link: https://appliedai-institute.de version: provider: mike - default: stable + default: latest social: - icon: fontawesome/brands/github link: https://github.com/aai-institute/continuiti - # - icon: fontawesome/brands/python - # link: https://pypi.org/project/continuiti/ + - icon: fontawesome/brands/python + link: https://pypi.org/project/continuiti/ - icon: fontawesome/brands/twitter link: https://twitter.com/appliedAI_gGmbH - icon: fontawesome/brands/linkedin diff --git a/pyproject.toml b/pyproject.toml index 2082706e..6e5fec48 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -21,7 +21,7 @@ keywords = [ "Artificial Intelligence", "Machine Learning", "Mathematics", "Physics", "Operator Learning", "Physics-Informed ML", "Neural Operator", "DeepONet", ] -dynamic = ["version"] +version = "0.1.0" dependencies = [ "setuptools", "numpy", @@ -68,14 +68,14 @@ dev = [ "mknotebooks>=0.8.0", "neoteroi-mkdocs", "pygments", -] -[tool.setuptools.dynamic] -version = {attr = "continuiti.__version__"} + # === Releasing === + "bump-my-version", +] [tool.setuptools.packages.find] where = ["src"] -include = ["continuiti"] +include = ["continuiti*"] [project.urls] Repository = "https://github.com/aai-institute/continuiti.git" diff --git a/src/continuiti/__init__.py b/src/continuiti/__init__.py index f3e51017..4e5400fa 100644 --- a/src/continuiti/__init__.py +++ b/src/continuiti/__init__.py @@ -36,7 +36,6 @@ ::/cards:: """ -__version__ = "0.0.0" __all__ = [ "benchmarks",