Skip to content

Commit db2393a

Browse files
committed
[TASK] pypi publish support
1 parent 93af224 commit db2393a

File tree

2 files changed

+142
-0
lines changed

2 files changed

+142
-0
lines changed

.github/workflows/pypi-publish.yml

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
name: Publish bact-mat-utils to PyPI and TestPyPI
2+
3+
on: push
4+
5+
jobs:
6+
build:
7+
name: Build distribution
8+
runs-on: ubuntu-latest
9+
10+
steps:
11+
- uses: actions/checkout@v4
12+
- name: Set up Python
13+
uses: actions/setup-python@v5
14+
with:
15+
python-version: "3.x"
16+
- name: Install pypa/build
17+
run: >-
18+
python3 -m
19+
pip install
20+
build
21+
--user
22+
- name: Build a binary wheel and a source tarball
23+
run: python3 -m build
24+
- name: Store the distribution packages
25+
uses: actions/upload-artifact@v4
26+
with:
27+
name: python-package-distributions
28+
path: dist/
29+
30+
publish-to-pypi:
31+
name: >-
32+
Publish accml distribution to PyPI
33+
if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes
34+
needs:
35+
- build
36+
runs-on: ubuntu-latest
37+
environment:
38+
name: pypi
39+
url: https://pypi.org/p/bact-math-utils # Replace <package-name> with your PyPI project name
40+
permissions:
41+
id-token: write # IMPORTANT: mandatory for trusted publishing
42+
43+
steps:
44+
- name: Download all the dists
45+
uses: actions/download-artifact@v4
46+
with:
47+
name: python-package-distributions
48+
path: dist/
49+
- name: Publish distribution to PyPI
50+
uses: pypa/gh-action-pypi-publish@release/v1
51+
52+
github-release:
53+
name: >-
54+
Sign accl with Sigstore and upload them to GitHub Release
55+
needs:
56+
- publish-to-pypi
57+
runs-on: ubuntu-latest
58+
59+
permissions:
60+
contents: write # IMPORTANT: mandatory for making GitHub Releases
61+
id-token: write # IMPORTANT: mandatory for sigstore
62+
63+
steps:
64+
- name: Download all the dists
65+
uses: actions/download-artifact@v4
66+
with:
67+
name: python-package-distributions
68+
path: dist/
69+
- name: Sign the dists with Sigstore
70+
uses: sigstore/[email protected]
71+
with:
72+
inputs: >-
73+
./dist/*.tar.gz
74+
./dist/*.whl
75+
- name: Create GitHub Release
76+
env:
77+
GITHUB_TOKEN: ${{ github.token }}
78+
run: >-
79+
gh release create
80+
'${{ github.ref_name }}'
81+
--repo '${{ github.repository }}'
82+
--notes ""
83+
- name: Upload artifact signatures to GitHub Release
84+
env:
85+
GITHUB_TOKEN: ${{ github.token }}
86+
# Upload to GitHub Release using the `gh` CLI.
87+
# `dist/` contains the built packages, and the
88+
# sigstore-produced signatures and certificates.
89+
run: >-
90+
gh release upload
91+
'${{ github.ref_name }}' dist/**
92+
--repo '${{ github.repository }}'
93+
94+
publish-to-testpypi:
95+
name: Publish accml to TestPyPI
96+
needs:
97+
- build
98+
runs-on: ubuntu-latest
99+
100+
environment:
101+
name: testpypi
102+
url: https://test.pypi.org/p/bact-math-utils
103+
104+
permissions:
105+
id-token: write # IMPORTANT: mandatory for trusted publishing
106+
107+
steps:
108+
- name: Download all the dists
109+
uses: actions/download-artifact@v4
110+
with:
111+
name: python-package-distributions
112+
path: dist/
113+
- name: Publish distribution to TestPyPI
114+
uses: pypa/gh-action-pypi-publish@release/v1
115+
with:
116+
repository-url: https://test.pypi.org/legacy/

pyproject.toml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
[build-system]
2+
requires = [ "poetry-core>=1.0.0",]
3+
build-backend = "poetry.core.masonry.api"
4+
5+
[tool.poetry]
6+
name = "accml"
7+
version = "0.0.0"
8+
description = "python accelerator middle layer"
9+
authors = ["Pierre Schnizer", "Teresia Olsson"]
10+
license = "GPL-3.0"
11+
homepage = "https://github.com/hz-b/bact-math-utils"
12+
documentation = "https://github.com/hz-b/bact-math-utils"
13+
repository = "https://github.com/hz-b/bact-math-utils"
14+
keywords = []
15+
classifiers = [
16+
"Development Status :: 4 - Beta",
17+
"Intended Audience :: Science/Research",
18+
"Programming Language :: Python :: 3",
19+
"Topic :: Scientific/Engineering :: Physics",
20+
]
21+
22+
[tool.poetry.dependencies]
23+
python = ">=3.7"
24+
25+
26+

0 commit comments

Comments
 (0)