Skip to content

Commit 859a8f3

Browse files
Added release workflow step to test the distribution
1 parent 46c8966 commit 859a8f3

File tree

2 files changed

+50
-14
lines changed

2 files changed

+50
-14
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: 'Build Python Package'
2+
description: 'Sets up Python, builds package, and validates it'
3+
inputs:
4+
python-version:
5+
description: 'Python version to use'
6+
required: false
7+
default: '3.8'
8+
9+
runs:
10+
using: "composite"
11+
steps:
12+
- name: Set up Python ${{ inputs.python-version }}
13+
uses: actions/setup-python@v5
14+
with:
15+
python-version: ${{ inputs.python-version }}
16+
17+
- name: Upgrade pip and setuptools
18+
shell: bash
19+
run: python -m pip install --upgrade pip setuptools
20+
21+
- name: Install dependencies
22+
shell: bash
23+
run: pip install twine wheel
24+
25+
- name: Setup deployment
26+
shell: bash
27+
run: python setup.py sdist bdist_wheel
28+
29+
- name: Validate deployment
30+
shell: bash
31+
run: twine check dist/*

.github/workflows/release.yaml

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,25 @@ on:
66
- '*'
77

88
jobs:
9-
deploy:
9+
release-test:
10+
runs-on: ubuntu-22.04
11+
steps:
12+
- uses: actions/checkout@v4
13+
14+
- uses: ./.github/actions/build-package
15+
16+
- name: Set up a fresh environment and run tests
17+
run: |
18+
python -m venv venv
19+
source venv/bin/activate
20+
pip install dist/*.tar.gz
21+
pip install dist/*.whl
22+
pip install -e .[test]
23+
pytest
24+
25+
release:
1026
runs-on: ubuntu-22.04
11-
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
27+
needs: release-test
1228

1329
steps:
1430
- uses: actions/checkout@v4
@@ -24,18 +40,7 @@ jobs:
2440
echo "Checking that package version [v$PKG_VERSION] matches release tag [${{ github.ref_name }}]"
2541
[ "${{ github.ref_type }}" = "tag" ] && [ "${{ github.ref_name }}" = "v$PKG_VERSION" ]
2642
27-
- name: Upgrade pip and setuptools
28-
run: |
29-
python -m pip install --upgrade pip setuptools
30-
31-
- name: Install dependencies
32-
run: pip install twine wheel
33-
34-
- name: Setup deployment
35-
run: python setup.py sdist bdist_wheel
36-
37-
- name: Validate deployment
38-
run: twine check dist/*
43+
- uses: ./.github/actions/build-package
3944

4045
- name: Run deployment
4146
run:

0 commit comments

Comments
 (0)