Skip to content
Merged

Dev #248

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
28 changes: 25 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,29 @@ permissions:

jobs:
test:
name: Test (${{ matrix.python-version }}, pandas ${{ matrix.pandas-label }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ['3.9', '3.12']
include:
- python-version: '3.10'
pandas-label: '2.2.3'
pandas-spec: 'pandas==2.2.3'
- python-version: '3.12'
pandas-label: '2.2.3'
pandas-spec: 'pandas==2.2.3'
- python-version: '3.12'
pandas-label: '3.x'
pandas-spec: 'pandas>=3,<4'
- python-version: '3.14'
pandas-label: '3.x'
pandas-spec: 'pandas>=3,<4'

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
Expand All @@ -30,6 +46,10 @@ jobs:
- name: Upgrade pip, setuptools, and packaging
run: |
python -m pip install --upgrade pip setuptools packaging

- name: Pin pandas ${{ matrix.pandas-label }}
run: |
python -m pip install --upgrade "${{ matrix.pandas-spec }}"

- name: Cache src directory
uses: actions/cache@v4
Expand Down Expand Up @@ -62,11 +82,13 @@ jobs:
python3 test.py -t GRCh37

- name: Build and push Docker image
if: github.ref == 'refs/heads/master' && github.event_name == 'push' && matrix.python-version == '3.12'
if: github.ref == 'refs/heads/master' && github.event_name == 'push' && matrix.python-version == '3.12' && matrix.pandas-label == '3.x'
run: |
echo "Starting Docker deployment to GHCR for sigprofilersuite..."

VERSION_TAG=$(grep "VERSION = " setup.py | cut -d'"' -f2)
python -m pip install --upgrade setuptools_scm
VERSION_TAG=$(python -m setuptools_scm)
VERSION_TAG=${VERSION_TAG//+/-}

# Get the repository name and convert it to lowercase
REPO_NAME=$(basename ${{ github.repository }} | tr '[:upper:]' '[:lower:]')
Expand Down
92 changes: 92 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
name: Release

on:
push:
tags:
- "v*"
release:
types:
- published
workflow_dispatch:

jobs:
build:
name: Build distributions
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0

- name: Set up Python 3.12
uses: actions/setup-python@v6
with:
python-version: "3.12"

- name: Install build tooling
run: |
python -m pip install --upgrade pip build twine

- name: Build distributions
run: |
python -m build

- name: Check distributions
run: |
python -m twine check dist/*

- name: Verify package version
run: |
python -m pip install dist/*.whl
python -c "import SigProfilerMatrixGenerator; print(SigProfilerMatrixGenerator.__version__)"

- name: Upload distributions
uses: actions/upload-artifact@v7
with:
name: python-package-distributions
path: dist/
if-no-files-found: error

publish-testpypi:
name: Publish to TestPyPI
needs: build
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
environment:
name: testpypi
url: https://test.pypi.org/p/SigProfilerMatrixGenerator
permissions:
id-token: write
steps:
- name: Download distributions
uses: actions/download-artifact@v5
with:
name: python-package-distributions
path: dist/

- name: Publish package distributions to TestPyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/

publish-pypi:
name: Publish to PyPI
needs: build
if: github.event_name == 'release' && github.event.action == 'published'
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/SigProfilerMatrixGenerator
permissions:
id-token: write
steps:
- name: Download distributions
uses: actions/download-artifact@v5
with:
name: python-package-distributions
path: dist/

- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

# MkDocs build output
/site/
SigProfilerMatrixGenerator/version.py
SigProfilerMatrixGenerator/_version.py
SigProfilerMatrixGenerator/references/chromosomes/tsb/
SigProfilerMatrixGenerator/references/vcf_files/*_bench/input/
SigProfilerMatrixGenerator/references/vcf_files/*_bench/output/
Expand Down
145 changes: 145 additions & 0 deletions RELEASE_ADMIN.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
# SigProfilerMatrixGenerator Release Administration

This repository publishes Python distributions through GitHub Actions and PyPI
Trusted Publishing. The release process intentionally has two publish steps:

1. Push a version tag such as `v1.3.7` to publish to TestPyPI.
2. Publish a GitHub Release for that same tag to publish to PyPI.

Merging into `master` does not publish a Python package by itself.

## Required GitHub Setup

Create these GitHub environments:

```text
testpypi
pypi
```

The environment names must exactly match `.github/workflows/release.yml`.
The `pypi` environment should require reviewer approval before deployment.

## Required TestPyPI Trusted Publisher

Configure this from TestPyPI:

```text
PyPI Project Name: SigProfilerMatrixGenerator
Owner: SigProfilerSuite
Repository name: SigProfilerMatrixGenerator
Workflow name: release.yml
Environment name: testpypi
```

If the project does not exist on TestPyPI yet, use the pending trusted
publisher flow to create it on first publish.

## Required PyPI Trusted Publisher

Configure this from the existing PyPI project:

```text
PyPI Project Name: SigProfilerMatrixGenerator
Owner: SigProfilerSuite
Repository name: SigProfilerMatrixGenerator
Workflow name: release.yml
Environment name: pypi
```

For an existing PyPI project, configure this from:

```text
PyPI -> Your projects -> SigProfilerMatrixGenerator -> Manage -> Publishing
```

If `Manage` is disabled, ask a current project owner to add your PyPI account
as an owner or maintainer with publishing permissions.

## Versioning

Package versions are derived from Git tags by `setuptools_scm`.

Release tags must start with `v`, for example:

```text
v1.3.7
```

The package version for that tag becomes:

```text
1.3.7
```

Untagged commits produce development versions, for example:

```text
1.3.7.dev2+gabcdef0.d20260524
```

The generated file `SigProfilerMatrixGenerator/_version.py` is ignored and
must not be committed.

## Release Flow

First merge the release-ready branch into `master` through the repository's
normal review process.

Then create and push the tag:

```bash
git checkout master
git pull origin master
git tag -a v1.3.7 -m "v1.3.7"
git push origin v1.3.7
```

The pushed tag triggers `.github/workflows/release.yml` and publishes to
TestPyPI.

After TestPyPI is verified, publish a GitHub Release for the same tag. That
release event triggers the PyPI publish job.

## Verification

After the tag push, verify the GitHub Actions run:

- build job passed
- `twine check` passed
- package version printed correctly
- TestPyPI publish job passed

Optional TestPyPI install check:

```bash
python -m pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple SigProfilerMatrixGenerator==1.3.7
python -c "import SigProfilerMatrixGenerator; print(SigProfilerMatrixGenerator.__version__)"
```

After publishing the GitHub Release, verify the PyPI job and package page:

```text
https://pypi.org/project/SigProfilerMatrixGenerator/
```

Optional PyPI install check:

```bash
python -m pip install SigProfilerMatrixGenerator==1.3.7
python -c "import SigProfilerMatrixGenerator; print(SigProfilerMatrixGenerator.__version__)"
```

## Troubleshooting

If the package version is `0+unknown`, check that:

- the release workflow checkout uses `fetch-depth: 0`
- the tag exists locally and remotely
- the tag starts with `v`

If Trusted Publishing fails, check that:

- the TestPyPI/PyPI trusted publisher values exactly match this repository
- the GitHub environment name is `testpypi` or `pypi`
- the publish job has `id-token: write`
4 changes: 2 additions & 2 deletions SigProfilerMatrixGenerator/scripts/SVMatrixGenerator.py
Original file line number Diff line number Diff line change
Expand Up @@ -920,9 +920,9 @@ def annotateBedpe(sv_bedpe):

check_exist_list = sample_bps["id"][sample_bps["is_clustered"]]
sample_bps["is_clustered"][
np.in1d(sample_bps["id"].values, check_exist_list.values)
np.isin(sample_bps["id"].values, check_exist_list.values)
] = True
sv_bedpe["is_clustered"] = np.in1d(
sv_bedpe["is_clustered"] = np.isin(
sv_bedpe["id"], sample_bps["id"][sample_bps["is_clustered"]]
)
sv_bedpe = processBEDPE(sv_bedpe)
Expand Down
Loading
Loading