-
Notifications
You must be signed in to change notification settings - Fork 1
186 lines (173 loc) · 5.23 KB
/
release.yml
File metadata and controls
186 lines (173 loc) · 5.23 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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
name: Release
on:
push:
branches: [main]
workflow_dispatch:
permissions:
contents: read
jobs:
release:
runs-on: ubuntu-latest
concurrency:
group: release-${{ github.ref_name }}
cancel-in-progress: false
permissions:
contents: write
outputs:
released: ${{ steps.semantic-release.outputs.released || 'false' }}
tag: ${{ steps.semantic-release.outputs.tag }}
steps:
- name: Checkout release branch
uses: actions/checkout@v4
with:
ref: ${{ github.ref_name }}
- name: Force branch to workflow sha
run: git reset --hard ${{ github.sha }}
- name: Run semantic release
id: semantic-release
uses: python-semantic-release/python-semantic-release@v10.5.3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
git_committer_name: github-actions
git_committer_email: actions@users.noreply.github.com
build: false
build-wheels:
needs: release
if: needs.release.outputs.released == 'true'
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
target: x86_64
- os: ubuntu-latest
target: aarch64
- os: macos-14
target: aarch64
- os: macos-15-intel
target: x86_64
- os: windows-latest
target: x64
steps:
- uses: actions/checkout@v4
with:
ref: ${{ needs.release.outputs.tag }}
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Build wheels
uses: PyO3/maturin-action@v1
with:
target: ${{ matrix.target }}
args: --release --out dist -i 3.10 3.11 3.12 3.13
manylinux: auto
- uses: actions/upload-artifact@v4
with:
name: wheels-${{ matrix.os }}-${{ matrix.target }}
path: dist/*.whl
build-sdist:
needs: release
if: needs.release.outputs.released == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ needs.release.outputs.tag }}
- name: Build sdist
uses: PyO3/maturin-action@v1
with:
command: sdist
args: --out dist
- uses: actions/upload-artifact@v4
with:
name: sdist
path: dist/*.tar.gz
smoke-test-wheels:
needs: build-wheels
if: needs.release.outputs.released == 'true'
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
target: x86_64
- os: macos-14
target: aarch64
- os: macos-15-intel
target: x86_64
- os: windows-latest
target: x64
steps:
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- uses: actions/download-artifact@v4
with:
name: wheels-${{ matrix.os }}-${{ matrix.target }}
path: dist
- name: Install built wheel
shell: python
run: |
import glob
import subprocess
import sys
interpreter_tag = f"cp{sys.version_info.major}{sys.version_info.minor}"
wheels = glob.glob(f"dist/*{interpreter_tag}*.whl")
assert wheels, f"No wheel matching interpreter tag {interpreter_tag}"
subprocess.check_call([sys.executable, "-m", "pip", "install", wheels[0]])
- name: Smoke test wheel
shell: python
run: |
import numpy as np
import pandas as pd
from causal_impact import CausalImpact, ModelOptions
dates = pd.date_range("2020-01-01", periods=24, freq="D")
x = np.linspace(0.0, 1.0, 24)
y = 5.0 + 0.2 * np.arange(24) + 1.5 * x
y[18:] += 2.0
data = pd.DataFrame({"y": y, "x1": x}, index=dates)
ci = CausalImpact(
data,
["2020-01-01", "2020-01-18"],
["2020-01-19", "2020-01-24"],
model_args=ModelOptions(niter=100, nwarmup=50, seed=42),
)
assert ci.summary()
assert len(ci.inferences.columns) >= 11
upload-release-assets:
needs: [release, build-sdist, smoke-test-wheels]
if: needs.release.outputs.released == 'true'
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
with:
ref: ${{ needs.release.outputs.tag }}
- uses: actions/download-artifact@v4
with:
path: dist
merge-multiple: true
- name: Upload release assets to GitHub release
uses: python-semantic-release/publish-action@v10.5.3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ needs.release.outputs.tag }}
publish:
needs: [release, build-sdist, smoke-test-wheels]
if: needs.release.outputs.released == 'true'
runs-on: ubuntu-latest
environment: pypi
permissions:
contents: read
id-token: write
steps:
- uses: actions/download-artifact@v4
with:
path: dist
merge-multiple: true
- uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: dist/