Skip to content

Commit c9821fe

Browse files
authored
Merge pull request #44 from HumanBrainProject/cicd_buildrelease
ci/cd: build on push, release on tag
2 parents d287402 + 3fe5cb4 commit c9821fe

File tree

1 file changed

+64
-0
lines changed

1 file changed

+64
-0
lines changed

.github/workflows/publish.yml

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# adapted from https://packaging.python.org/en/latest/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/#workflow-definition
2+
name: Publish Python 🐍 distribution 📦 to PyPI and TestPyPI
3+
4+
on: push
5+
6+
jobs:
7+
build:
8+
name: Build distribution 📦
9+
runs-on: ubuntu-latest
10+
11+
steps:
12+
- uses: actions/checkout@v4
13+
with:
14+
persist-credentials: false
15+
- name: Set up Python
16+
uses: actions/setup-python@v5
17+
with:
18+
python-version: "3.x"
19+
- name: Install pypa/build
20+
run: >-
21+
python3 -m
22+
pip install
23+
build
24+
--user
25+
- name: Build a binary wheel and a source tarball
26+
run: python3 -m build
27+
- name: Store the distribution packages
28+
uses: actions/upload-artifact@v4
29+
with:
30+
name: python-package-distributions
31+
path: dist/
32+
33+
verify-tag:
34+
name: verify tag conforms
35+
if: startsWith(github.ref, 'refs/tags/')
36+
runs-on: ubuntu-latest
37+
steps:
38+
- name: "Check tag conforms ^[0-9]+\\.[0-9]+\\.[0-9]+$"
39+
run: |
40+
trimmed_tag=${GITHUB_REF#refs/tags/}
41+
echo trimmed_tag='"'$trimmed_tag'"'
42+
exit [[ "$trimmed_tag" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]
43+
44+
publish-to-pypi:
45+
name: >-
46+
Publish Python 🐍 distribution 📦 to PyPI
47+
if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes
48+
needs:
49+
- build
50+
- verify-tag
51+
runs-on: ubuntu-latest
52+
environment:
53+
name: pypi
54+
url: https://pypi.org/p/ebrains-drive
55+
permissions:
56+
id-token: write # IMPORTANT: mandatory for trusted publishing
57+
steps:
58+
- name: Download all the dists
59+
uses: actions/download-artifact@v4
60+
with:
61+
name: python-package-distributions
62+
path: dist/
63+
- name: Publish distribution 📦 to PyPI
64+
uses: pypa/gh-action-pypi-publish@release/v1

0 commit comments

Comments
 (0)