Skip to content
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

fix: dev release process #992

Open
wants to merge 5 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
102 changes: 32 additions & 70 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ name: Release

"on":
push:
branches: ["main", "release/**", "dev"]
branches:
- main

workflow_dispatch:

concurrency:
group: deploy
Expand All @@ -13,98 +16,70 @@ env:

jobs:
release:
# Ensure the workflow can be run only from main & dev branches!
if: ${{ github.ref == 'refs/heads/main' || github.ref == 'refs/heads/dev' }}
runs-on: ubuntu-latest
concurrency: release
outputs:
released: ${{ steps.semrelease.outputs.released }}
permissions:
# NOTE: this enables trusted publishing.
# See https://github.com/pypa/gh-action-pypi-publish/tree/release/v1#trusted-publishing
# and https://blog.pypi.org/posts/2023-04-20-introducing-trusted-publishers/
id-token: write
contents: write

steps:
# NOTE: commits using GITHUB_TOKEN does not trigger workflows
- uses: actions/create-github-app-token@v1
id: trigger-token
with:
app-id: ${{ vars.TRIGGER_WORKFLOW_GH_APP_ID}}
private-key: ${{ secrets.TRIGGER_WORKFLOW_GH_APP_KEY }}
- uses: actions/checkout@v4
with:
fetch-depth: 0
repository: opentargets/gentropy
token: ${{ secrets.GITHUB_TOKEN }}
persist-credentials: false

- name: Python Semantic Release
ref: ${{ github.ref_name }}
- uses: python-semantic-release/[email protected]
id: semrelease
uses: python-semantic-release/[email protected]
with:
github_token: ${{ steps.trigger-token.outputs.token }}

- name: Publish package to GitHub Release
uses: python-semantic-release/upload-to-gh-release@main
# NOTE: semrelease output is a string, so we need to compare it to a string
if: steps.semrelease.outputs.released == 'true'
github_token: ${{ secrets.GITHUB_TOKEN }}
- uses: python-semantic-release/[email protected]
if: ${{ steps.semrelease.outputs.released }} == 'true'
with:
# NOTE: allow to start the workflow when push action on tag gets executed
# requires using GH_APP to authenitcate, otherwise push authorised with
# the GITHUB_TOKEN does not trigger the tag artifact workflow.
# see https://github.com/actions/create-github-app-token
github_token: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ steps.semrelease.outputs.tag }}

- name: Store the distribution packages
- uses: actions/upload-artifact@v4
if: steps.semrelease.outputs.released == 'true'
uses: actions/upload-artifact@v4
with:
name: python-package-distributions
path: dist/

publish-to-pypi:
publish-to-testpypi:
name: Publish 📦 in TestPyPI
needs: release
name: Publish 📦 in PyPI
if: github.ref == 'refs/heads/main' && needs.release.outputs.released == 'true'
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/gentropy
name: testpypi
url: https://test.pypi.org/p/gentropy
permissions:
id-token: write # IMPORTANT: mandatory for trusted publishing
steps:
- name: Download all the dists
uses: actions/download-artifact@v4
- uses: actions/download-artifact@v4
with:
name: python-package-distributions
path: dist/
- name: Publish distribution 📦 to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
- uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/

publish-to-testpypi:
name: Publish 📦 in TestPyPI
needs: release
publish-to-pypi:
needs:
- release
- publish-to-testpypi
name: Publish 📦 in PyPI
if: github.ref == 'refs/heads/main' && needs.release.outputs.released == 'true'
runs-on: ubuntu-latest

environment:
name: testpypi
url: https://test.pypi.org/p/gentropy

name: pypi
url: https://pypi.org/p/gentropy
permissions:
id-token: write # IMPORTANT: mandatory for trusted publishing

steps:
- name: Download all the dists
uses: actions/download-artifact@v4
- uses: actions/download-artifact@v4
with:
name: python-package-distributions
path: dist/
- name: Publish distribution 📦 to TestPyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/
- uses: pypa/gh-action-pypi-publish@release/v1

documentation:
needs: release
Expand All @@ -115,23 +90,10 @@ jobs:
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Python
uses: actions/setup-python@v4
- uses: actions/setup-python@v4
with:
python-version: ${{ env.PYTHON_VERSION_DEFAULT }}
- name: Install uv
uses: astral-sh/setup-uv@v5
- name: Load cached venv
id: cached-dependencies
uses: actions/cache@v4
with:
path: .venv
key: |
venv-${{ runner.os }}-\
${{ env.PYTHON_VERSION_DEFAULT }}-\
${{ hashFiles('**/uv.lock') }}
- name: Install dependencies
if: steps.cached-dependencies.outputs.cache-hit != 'true'
run: uv sync --group docs
- uses: astral-sh/setup-uv@v5
- run: uv sync --group docs
- name: Publish docs
run: uv run mkdocs gh-deploy --force
Binary file added docs/assets/imgs/development-flow.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
24 changes: 24 additions & 0 deletions docs/development/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,3 +84,27 @@ For more details on each of these steps, see the sections below.
### Support for python versions

As of version 2.1.X gentropy supports multiple python versions. To ensure compatibility with all supported versions, unit tests are run for each of the minor python release from 3.10 to 3.12. Make sure your changes are compatible with all supported versions.

### Development process

The development follows simplified Git Flow process that includes usage of

- `dev` (development branch)
- `feature` branches
- `main` (production branch)

The development starts with creating new `feature` branch based on the `dev` branch. Once the feature is ready, the Pull Request for the `dev` branch is created and CI/CD Checks are performed to ensure that the code is compliant with the project conventions. Once the PR is approved, the feature branch is merged into the `dev` branch.

#### Development releases

One can create the dev release tagged by `vX.Y.Z-dev.V` tag. This release will not trigger the CI/CD pipeline to publish the package to the PyPi repository. The release is done by triggering the `Release` GitHub action.

#### Production releases

Once per week, the `Trigger PR for release` github action creates a Pull Request from `dev` to `main` branch, when the PR is approved, the `Release` GitHub action is triggered to create a production release tagged by `vX.Y.Z` tag. This release triggers the CI/CD pipeline to publish the package to the _TestPyPi_ repository. If it is successful, then the actual deployment to the _PyPI_ repository is done. The deployment to the PyPi repository must be verified by the gentropy maintainer.

Below you can find a simplified diagram of the development process.

<div align="center">
<img width="800" height="400" src="../../assets/imgs/development-flow.png" alt="development process">
</div>
18 changes: 5 additions & 13 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -92,28 +92,20 @@ packages = ["src/gentropy"]
match = "(main|master)"
prerelease = false

[tool.semantic_release.branches."release"]
match = "release/*"
[tool.semantic_release.branches.dev]
match = "dev"
prerelease = true
prerelease_token = "rc"

[tool.semantic_release.publish]
dist_glob_patterns = ["dist/*"]
upload_to_vcs_release = true

[tool.semantic_release.changelog]
[tool.semantic-release.changelog.default_templates]
changelog_file = "CHANGELOG.md"
exclude_commit_patterns = ["chore\\(release\\):"]

[tool.semantic_release.branches."step"]
match = "(build|chore|ci|docs|feat|fix|perf|style|refactor|test)"
prerelease = true
prerelease_token = "alpha"

[tool.semantic_release.branches."dev"]
match = "dev"
prerelease = true
prerelease_token = "dev"
[tool.semantic-release.changelog]
exclude_commit_patterns = ["chore\\(release\\):"]

[build-system]
requires = ["hatchling"]
Expand Down
Loading