-
Notifications
You must be signed in to change notification settings - Fork 9
129 lines (113 loc) · 4 KB
/
release.yml
File metadata and controls
129 lines (113 loc) · 4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
name: Build wheels and create release and publish to PyPI
on:
push:
# Disable this for forks. Its expensive, and the PyPI portion will fail later
if: github.repository_owner == "slac-lcls"
# For now, only build for release tags
tags:
- 'v*'
# branches:
# - main
#pull_request:
# branches:
# - main
jobs:
# Build binaries
build_wheels:
name: Build wheels on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]
# Add back Mac and Windows builds when maestro supports them
# os: [ubuntu-latest, windows-latest, macos-latest]
steps:
- uses: actions/checkout@v4
# Cache pip (for speedup)
- name: Cache pip
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('pyproject.toml') }}
restore-keys: |
${{ runner.os }}-pip-
# Cache ccache (for speedup)
- name: Cache ccache
uses: actions/cache@v4
with:
path: .ccache
key: ${{ runner.os }}-ccache-${{ github.ref }}
restore-keys: |
${{ runner.os }}-ccache-
- name: Build wheels
# Check pyproject.toml for supported versions and additional config
uses: pypa/cibuildwheel@v2.22.0
env:
CIBW_TEST_REQUIRES: "pytest"
# Include the C++ test suite binaries
CIBW_TEST_COMMAND: "test_http && test_server && test_maestro_api && pytest {project}/tests/unit"
CIBW_AFTER_BUILD: "ccache -s"
# Could not do tests, but then I can't run them above
# CIBW_CONFIG_SETTINGS: "setup-args=\"-Dinstall_tests=false\" setup-args=\"-Dinstall_utilities=false\""
# Instead of disabling, will just remove them from the wheels afterwards
# Not sure this will work on platforms other than Linux? Not building for those though..
- name: Prune tests from wheels
run: |
for whl in wheelhouse/*.whl; do
echo "Pruning $whl..."
# Find all files inside the wheel that match our test names
# and delete them regardless of which .data/scripts folder they are in
zip -d "$whl" "*test_http" "*test_server" "*test_maestro_api" "*activate_installation"
done
- uses: actions/upload-artifact@v4
with:
name: cibw-wheels-${{ matrix.os }}-${{ strategy.job-index }}
path: ./wheelhouse/*.whl
# Build source distribution
build_sdist:
name: Build source distribution
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: "3.11" # Shouldn't matter
# Meson setup runs, so we still need these unfortunately (for subprojects)
# The code will not actually be compiled for the sdist
- name: Install dependencies
run: |
sudo apt update
sudo apt install -y cmake ninja-build
- name: Build sdist
run: |
python -m pip install build
python -m build --sdist
- uses: actions/upload-artifact@v4
with:
name: cibw-sdist
path: dist/*.tar.gz
# Create release, publish
create_release_and_publish_to_pypi:
needs: [build_wheels, build_sdist]
runs-on: ubuntu-latest
environment: pypi
permissions:
id-token: write
contents: write
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
steps:
- name: Gather build artifacts
uses: actions/download-artifact@v4
with:
pattern: cibw-*
path: dist
merge-multiple: true
# This will publish to PyPI as `psrel`. Only this workflow is linked to the PyPI account
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
files: dist/*
generate_release_notes: true