Skip to content

Commit f3a5f3d

Browse files
committed
Publish and create release from changelog
1 parent 38d44e3 commit f3a5f3d

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

.github/workflows/publish.yml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: Publish package to PyPI and create release
2+
3+
on:
4+
push:
5+
branches: [main]
6+
tags:
7+
- "v*" # Push events to matching v*, i.e. v1.0, v20.15.10
8+
9+
jobs:
10+
build:
11+
uses: ./.github/workflows/build.yml
12+
13+
publish:
14+
name: Publish distribution to PyPI
15+
runs-on: ubuntu-latest
16+
if: startsWith(github.ref, 'refs/tags/v')
17+
environment: pypi_prod
18+
needs: [build]
19+
steps:
20+
- name: Checkout code
21+
uses: actions/checkout@v4
22+
- name: Set up Python
23+
uses: actions/setup-python@v5
24+
with:
25+
python-version: 3.12
26+
- name: Install flit
27+
run: |
28+
pip install flit
29+
- name: Publish the distibution to PyPI
30+
run: flit publish
31+
env:
32+
FLIT_INDEX_URL: https://upload.pypi.org/legacy/
33+
FLIT_USERNAME: __token__
34+
FLIT_PASSWORD: ${{ secrets. PYPI_API_TOKEN }}
35+
36+
release:
37+
name: Create release
38+
runs-on: ubuntu-latest
39+
needs: [publish]
40+
steps:
41+
- name: Checkout
42+
uses: actions/checkout@v4
43+
- name: Extract release notes
44+
id: extract-release-notes
45+
uses: ffurrer2/extract-release-notes@v1
46+
- name: Create release
47+
env:
48+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
49+
run: gh release create --notes '${{ steps.extract-release-notes.outputs.release_notes }}' --title ${{ github.ref_name }} ${{ github.ref_name }}

0 commit comments

Comments
 (0)