Skip to content

Commit b61413e

Browse files
Setup release workflow
1 parent d852dd3 commit b61413e

File tree

2 files changed

+79
-2
lines changed

2 files changed

+79
-2
lines changed

.github/workflows/release.yaml

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- v*
7+
8+
jobs:
9+
build-wheels:
10+
name: Build wheels for ${{ matrix.os }}
11+
runs-on: ${{ matrix.os }}
12+
strategy:
13+
matrix:
14+
os: [ubuntu-latest, macos-13, macos-14]
15+
16+
steps:
17+
- uses: actions/checkout@v4
18+
19+
- uses: actions/setup-python@v3
20+
21+
- name: Install cibuildwheel
22+
run: python -m pip install cibuildwheel==2.16.5
23+
24+
- name: Build wheels
25+
run: python -m cibuildwheel --output-dir wheelhouse
26+
env:
27+
CIBW_PROJECT_REQUIRES_PYTHON: ">=3.7"
28+
29+
- uses: actions/upload-artifact@v4
30+
with:
31+
name: dist-wheels-${{ matrix.os }}-${{ strategy.job-index }}
32+
path: ./wheelhouse/*.whl
33+
34+
build-sdist:
35+
name: Build source distribution
36+
runs-on: ubuntu-latest
37+
steps:
38+
- uses: actions/checkout@v4
39+
40+
- name: Build sdist
41+
run: pipx run build --sdist
42+
43+
- uses: actions/upload-artifact@v4
44+
with:
45+
name: dist-sdist
46+
path: dist/*.tar.gz
47+
48+
publish-to-pypi:
49+
name: Publish to PyPI
50+
runs-on: ubuntu-latest
51+
needs: [build-wheels, build-sdist]
52+
environment:
53+
name: pypi
54+
url: https://pypi.org/p/xsuite-kernels
55+
permissions:
56+
id-token: write
57+
58+
steps:
59+
- name: Check tag is a public release
60+
id: check-tag
61+
run: |
62+
if [[ ${{ github.event.ref }} =~ ^refs/tags/v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
63+
echo "match=true" >> $GITHUB_OUTPUT
64+
fi
65+
66+
- name: Download all the dists
67+
if: steps.check-tag.outputs.match == 'true'
68+
uses: actions/download-artifact@v4
69+
with:
70+
pattern: dist-*
71+
path: dist
72+
merge-multiple: true
73+
74+
- name: Publish to PyPI
75+
if: steps.check-tag.outputs.match == 'true'
76+
uses: pypa/gh-action-pypi-publish@release/v1

pyproject.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[build-system]
22
requires = [
33
"setuptools>=64",
4-
# "setuptools-scm>=8",
4+
"setuptools-scm[toml]>=8",
55
"xtrack==0.56.1",
66
"xfields==0.15.0",
77
"xcoll==0.3.5",
@@ -30,7 +30,8 @@ dynamic = ["version"]
3030
[project.scripts]
3131
xsuite-kernels = "xsuite_kernels.cli:main"
3232

33-
#[tool.setuptools_scm]
33+
[tool.setuptools_scm]
34+
# empty for default configuration
3435

3536
# The very non-obvious way files can be included in either sdist or bdist with
3637
# setuptools. We need to list the file in:

0 commit comments

Comments
 (0)