Skip to content

Commit f6e73dd

Browse files
authored
Build and publish to python package on tag push
1 parent 7b97147 commit f6e73dd

File tree

1 file changed

+92
-4
lines changed

1 file changed

+92
-4
lines changed

.github/workflows/release.yml

Lines changed: 92 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,95 @@
1-
name: Release Project Version
1+
name: Release Version
22

33
on:
4-
pull_request:
54
push:
6-
branches:
7-
- main
5+
tags:
6+
- "v*"
7+
8+
jobs:
9+
10+
# Build Python Package.
11+
build-package:
12+
name: Build Package
13+
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- name: 🛎 Checkout
18+
uses: actions/checkout@v4
19+
with:
20+
ref: ${{ github.head_ref }}
21+
22+
- name: 🐍 Setup Python
23+
uses: actions/setup-python@v5
24+
with:
25+
python-version: "3.13"
26+
cache: "pip"
27+
28+
- name: 📦 Install Hatch
29+
uses: pypa/hatch@install
30+
31+
- name: 🔨 Build Package
32+
run: hatch build
33+
34+
- name: ⬆️ Upload Artifacts
35+
uses: actions/upload-pages-artifact@v3
36+
with:
37+
name: python-package-distributions
38+
path: dist/
39+
40+
# Publishing to PyPI
41+
publish-to-test-pypi:
42+
name: Publish to Test PyPI
43+
44+
needs: build-package
45+
46+
runs-on: ubuntu-latest
47+
48+
environment:
49+
name: testpypi
50+
url: https://testpypi.org/p/ephys-link
51+
52+
permissions:
53+
id-token: write
54+
55+
steps:
56+
- name: ⬇️ Download Artifacts
57+
uses: actions/download-artifact@v4
58+
with:
59+
name: python-package-distributions
60+
path: dist/
61+
62+
- name: Publish distribution 📦 to PyPI
63+
uses: pypa/gh-action-pypi-publish@release/v1
64+
65+
publish-to-pypi:
66+
name: Publish to PyPI
67+
68+
needs: publish-to-test-pypi
69+
70+
runs-on: ubuntu-latest
71+
72+
environment:
73+
name: pypi
74+
url: https://pypi.org/p/ephys-link
75+
76+
permissions:
77+
id-token: write
78+
79+
steps:
80+
- name: ⬇️ Download Artifacts
81+
uses: actions/download-artifact@v4
82+
with:
83+
name: python-package-distributions
84+
path: dist/
85+
86+
- name: Publish distribution 📦 to PyPI
87+
uses: pypa/gh-action-pypi-publish@release/v1
88+
89+
# Build Windows executable.
90+
build-executable:
91+
name: Build Executable
92+
93+
runs-on: windows-latest
94+
95+

0 commit comments

Comments
 (0)