Skip to content

Commit 5e55c7f

Browse files
committed
chore: update the release process to leverage GitHub Actions
1 parent b01175e commit 5e55c7f

File tree

5 files changed

+283
-110
lines changed

5 files changed

+283
-110
lines changed

.github/workflows/publish.yml

Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
name: publish
2+
3+
on:
4+
push:
5+
tags: '\d+.\d+.\d+'
6+
7+
env:
8+
POETRY_VERSION: 1.6
9+
10+
jobs:
11+
on-main-branch-check:
12+
runs-on: ubuntu-latest
13+
outputs:
14+
on_main: ${{ steps.contains_tag.outputs.retval }}
15+
steps:
16+
- uses: actions/checkout@v4
17+
with:
18+
fetch-depth: 0
19+
20+
- uses: rickstaa/action-contains-tag@v1
21+
id: contains_tag
22+
with:
23+
reference: "main"
24+
tag: "${{ github.ref_name }}"
25+
26+
tests:
27+
name: tests
28+
needs: on-main-branch-check
29+
if: ${{ needs.on-main-branch-check.outputs.on_main == 'true' }}
30+
uses: "./.github/workflows/tests.yml"
31+
32+
build-wheels:
33+
name: build wheels
34+
needs: tests
35+
uses: "./.github/workflows/wheels.yml"
36+
37+
build-sdist:
38+
name: build source distribution
39+
needs: tests
40+
runs-on: ubuntu-latest
41+
steps:
42+
- uses: actions/checkout@v4
43+
with:
44+
fetch-depth: 0
45+
submodules: true
46+
47+
- uses: actions/setup-python@v5
48+
with:
49+
python-version: 3.12
50+
51+
- name: Install poetry
52+
run: |
53+
python -m pip install --upgrade pip
54+
python -m pip install poetry==${{env.POETRY_VERSION}}
55+
56+
- name: Configure poetry
57+
shell: bash
58+
run: poetry config virtualenvs.in-project true
59+
60+
- name: Install dependencies
61+
run: poetry install --no-interaction --no-root --without=dev
62+
63+
- name: Install project
64+
run: poetry install --no-interaction --without=dev
65+
66+
- name: Build package
67+
run: poetry build --format=sdist
68+
69+
- uses: actions/upload-artifact@v4
70+
with:
71+
name: pybedlite-sdist
72+
path: dist/*.tar.gz
73+
74+
publish-to-pypi:
75+
runs-on: ubuntu-latest
76+
needs: [build-wheels, build-sdist]
77+
environment: pypi
78+
permissions:
79+
id-token: write
80+
steps:
81+
- uses: actions/download-artifact@v4
82+
with:
83+
path: packages
84+
pattern: 'pybedlite-*'
85+
merge-multiple: true
86+
87+
- uses: pypa/gh-action-pypi-publish@release/v1
88+
with:
89+
packages-dir: packages/
90+
skip-existing: true
91+
verbose: true
92+
93+
make-changelog:
94+
runs-on: ubuntu-latest
95+
needs: publish-to-pypi
96+
outputs:
97+
release_body: ${{ steps.git-cliff.outputs.content }}
98+
steps:
99+
- name: Checkout the Repository at the Tagged Commit
100+
uses: actions/checkout@v4
101+
with:
102+
fetch-depth: 0
103+
ref: ${{ github.ref_name }}
104+
105+
- name: Generate a Changelog
106+
uses: orhun/git-cliff-action@v3
107+
id: git-cliff
108+
with:
109+
config: pyproject.toml
110+
args: --latest --verbose
111+
env:
112+
GITHUB_REPO: ${{ github.repository }}
113+
114+
make-github-release:
115+
runs-on: ubuntu-latest
116+
environment: github
117+
permissions:
118+
contents: write
119+
pull-requests: read
120+
needs: make-changelog
121+
steps:
122+
- name: Create Draft Release
123+
id: create_release
124+
uses: softprops/action-gh-release@v2
125+
env:
126+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
127+
with:
128+
name: ${{ github.ref_name }}
129+
body: |
130+
${{ needs.draft-changelog.outputs.release_body }}
131+
draft: false
132+
prerelease: false

.github/workflows/pythonpackage.yml

Lines changed: 0 additions & 93 deletions
This file was deleted.

.github/workflows/tests.yml

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
name: tests
2+
3+
on:
4+
push:
5+
branches:
6+
- "**"
7+
tags:
8+
- "!**"
9+
workflow_call:
10+
11+
env:
12+
POETRY_VERSION: 1.6
13+
14+
jobs:
15+
unit-tests:
16+
runs-on: ubuntu-latest
17+
environment: github-action-ci
18+
strategy:
19+
matrix:
20+
PYTHON_VERSION: ["3.8", "3.9", "3.10", "3.11"]
21+
22+
steps:
23+
- uses: actions/checkout@v4
24+
with:
25+
submodules: "true"
26+
27+
- name: Set up Python ${{ matrix.PYTHON_VERSION }}
28+
uses: actions/setup-python@v5
29+
with:
30+
python-version: ${{ matrix.PYTHON_VERSION }}
31+
32+
- name: Get full Python version
33+
id: full-python-version
34+
shell: bash
35+
run: echo "version=$(python -c "import sys; print('-'.join(str(v) for v in sys.version_info))")" >> $GITHUB_OUTPUT
36+
37+
- name: Install poetry
38+
run: |
39+
python -m pip install --upgrade pip
40+
python -m pip install poetry==${{env.POETRY_VERSION}}
41+
42+
- name: Configure poetry
43+
shell: bash
44+
run: poetry config virtualenvs.in-project true
45+
46+
- name: Set up cache
47+
uses: actions/cache@v4
48+
id: cache
49+
with:
50+
path: .venv
51+
key: venv-${{ runner.os }}-${{ steps.full-python-version.outputs.version }}-${{ hashFiles('**/poetry.lock') }}
52+
53+
- name: Ensure cache is healthy
54+
if: steps.cache.outputs.cache-hit == 'true'
55+
shell: bash
56+
run: poetry run pip --version >/dev/null 2>&1 || rm -rf .venv
57+
58+
- name: Test the lock file is up to date
59+
run: python -m poetry check --lock
60+
61+
- name: Install dependencies and package
62+
shell: bash
63+
run: |
64+
poetry install --only dev
65+
poetry build
66+
poetry install --extras docs
67+
68+
- name: Run pytest
69+
shell: bash
70+
run: |
71+
poetry run python -m pytest --cov=pybedlite --cov-report=xml --cov-branch
72+
73+
- name: Style checking
74+
shell: bash
75+
run: |
76+
poetry run black --line-length 99 --check pybedlite
77+
78+
- name: Import sorting
79+
shell: bash
80+
run: |
81+
poetry run isort --force-single-line-imports --profile black --check pybedlite
82+
83+
- name: Run lint
84+
shell: bash
85+
run: |
86+
poetry run flake8 --config=ci/flake8.cfg pybedlite
87+
88+
- name: Run mypy
89+
shell: bash
90+
run: |
91+
poetry run mypy -p pybedlite --config=ci/mypy.ini
92+
93+
- name: Run docs
94+
shell: bash
95+
run: |
96+
set -euo pipefail
97+
pushd docs
98+
poetry run make html
99+
popd
100+
101+
- name: Upload code coverage
102+
uses: codecov/[email protected]
103+
with:
104+
token: ${{ secrets.CODECOV_TOKEN }}
105+

0 commit comments

Comments
 (0)