Skip to content

Commit 290e619

Browse files
committed
build: update release CI/CD pipeline to create the tag and release
1 parent dc80502 commit 290e619

File tree

3 files changed

+125
-67
lines changed

3 files changed

+125
-67
lines changed

.github/workflows/pypi.yaml

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

.github/workflows/release.yaml

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
name: Create Release
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
release_notes:
7+
description: 'Release notes'
8+
type: string
9+
required: false
10+
default: ''
11+
upload_to_pypi:
12+
description: 'Upload the release to PyPI'
13+
type: boolean
14+
required: false
15+
default: true
16+
17+
permissions:
18+
actions: write
19+
contents: write
20+
21+
jobs:
22+
build:
23+
name: Build
24+
runs-on: ubuntu-latest
25+
outputs:
26+
version: ${{ steps.get-version.outputs.VERSION }}
27+
28+
steps:
29+
- name: Checkout project
30+
uses: actions/checkout@v4
31+
32+
- name: Setup Python
33+
uses: actions/setup-python@v5
34+
with:
35+
python-version: "3.11"
36+
37+
- name: Install Poetry
38+
uses: abatilo/actions-poetry@v4
39+
with:
40+
poetry-version: "1.8.5"
41+
42+
- name: Setup a local virtual environment
43+
run: |
44+
poetry config virtualenvs.create true --local
45+
poetry config virtualenvs.in-project true --local
46+
47+
- name: Define a cache for the virtual environment based on the dependencies lock file
48+
uses: actions/cache@v4
49+
with:
50+
path: ./.venv
51+
key: venv-${{ hashFiles('poetry.lock') }}
52+
53+
- name: Build
54+
run: |
55+
poetry install
56+
poetry build
57+
58+
- name: Get package version to create a new tag and release
59+
id: get-version
60+
run: echo "VERSION=$(poetry version --short)" >> $GITHUB_OUTPUT
61+
62+
- name: Upload build artifacts
63+
uses: actions/upload-artifact@v4
64+
with:
65+
name: csaps-packages
66+
path: dist/*
67+
overwrite: true
68+
69+
publish:
70+
name: Publish
71+
needs: [ build ]
72+
runs-on: ubuntu-latest
73+
environment:
74+
name: release
75+
url: https://pypi.org/project/csaps
76+
permissions:
77+
id-token: write
78+
env:
79+
TAG_NAME: v${{ needs.build.outputs.version }}
80+
81+
steps:
82+
- uses: actions/download-artifact@v4
83+
with:
84+
name: csaps-packages
85+
path: dist
86+
87+
- name: Check tag ${{ TAG_NAME }}
88+
uses: mukunku/tag-exists-action@v1.6.0
89+
id: check-tag
90+
with:
91+
tag: ${{ TAG_NAME }}
92+
93+
- name: Create tag ${{ TAG_NAME }}
94+
if: ${{ steps.check-tag.outputs.exists == 'false' }}
95+
uses: actions/github-script@v7
96+
with:
97+
script: |
98+
github.rest.git.createRef({
99+
owner: context.repo.owner,
100+
repo: context.repo.repo,
101+
ref: 'refs/tags/${{ TAG_NAME }}',
102+
sha: context.sha
103+
})
104+
105+
- name: Create release ${{ TAG_NAME }}
106+
uses: softprops/action-gh-release@v2
107+
with:
108+
name: ${{ TAG_NAME }}
109+
tag_name: ${{ TAG_NAME }}
110+
files: dist/*
111+
body: inputs.release_notes
112+
113+
- name: Upload to PyPI
114+
if: ${{ inputs.upload_to_pypi }}
115+
uses: pypa/gh-action-pypi-publish@release/v1

README.md

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@ Use pip for installing:
2222
pip install -U csaps
2323
```
2424

25+
or Poetry:
26+
27+
```
28+
poetry add csaps
29+
```
30+
2531
The module depends only on NumPy and SciPy. Python 3.9 or above is supported.
2632

2733
## Simple Examples
@@ -96,9 +102,10 @@ More examples of usage and the full documentation can be found at https://csaps.
96102
We use pytest for testing.
97103

98104
```
99-
cd /path/to/csaps/project/directory
100-
pip install -e .[tests]
101-
pytest
105+
git clone https://github.com/espdev/csaps.git
106+
cd csaps
107+
poetry install
108+
poetry run poe test
102109
```
103110

104111
## Algorithm and Implementation

0 commit comments

Comments
 (0)