-
Notifications
You must be signed in to change notification settings - Fork 6
262 lines (224 loc) · 9.05 KB
/
cd_release.yml
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
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
name: CD - Publish a new release
on:
release:
types:
- published
env:
PUBLISH_UPDATE_BRANCH: master
GIT_USER_NAME: "TEAM 4.0[bot]"
GIT_USER_EMAIL: "[email protected]"
CONTAINER_REGISTRY: ghcr.io
jobs:
update_version:
name: Update DLite version and release body
runs-on: ubuntu-latest
if: github.repository == 'SINTEF/dlite' && startsWith(github.ref, 'refs/tags/v')
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up git user
run: |
git config --global user.name "${GIT_USER_NAME}"
git config --global user.email "${GIT_USER_EMAIL}"
- name: Update version and tag
run: |
sed -i -E -e "s|^ +VERSION +[0-9.]+$| VERSION ${GITHUB_REF#refs/tags/v}|" CMakeLists.txt
git add CMakeLists.txt
git commit -m "Release ${GITHUB_REF#refs/tags/}"
TAG_MSG=.github/utils/release_tag_msg.txt
sed -i "s|TAG_NAME|${GITHUB_REF#refs/tags/}|" "${TAG_MSG}"
git tag -af -F "${TAG_MSG}" ${GITHUB_REF#refs/tags/}
- name: Update '${{ env.PUBLISH_UPDATE_BRANCH }}'
uses: CasperWA/push-protected@v2
with:
token: ${{ secrets.RELEASE_PAT }}
branch: ${{ env.PUBLISH_UPDATE_BRANCH }}
sleep: 15
force: true
tags: true
unprotect_reviews: true
- name: Get tagged versions
run: echo "PREVIOUS_VERSION=$(git tag -l --sort -version:refname | sed -n 2p)" >> $GITHUB_ENV
- name: Create release-specific changelog
uses: CharMixer/auto-changelog-action@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
release_branch: ${{ env.PUBLISH_UPDATE_BRANCH }}
since_tag: "${{ env.PREVIOUS_VERSION }}"
output: "release_changelog.md"
- name: Append changelog to release body
run: |
gh api /repos/${{ github.repository }}/releases/${{ github.event.release.id }} --jq '.body' > release_body.md
cat release_changelog.md >> release_body.md
gh api /repos/${{ github.repository }}/releases/${{ github.event.release.id }} -X PATCH -F body='@release_body.md'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
cd_build_wheels:
name: Build wheels
runs-on: ${{ matrix.os }}
if: github.repository == 'SINTEF/dlite' && startsWith(github.ref, 'refs/tags/v')
strategy:
fail-fast: false
matrix:
include:
# See ci_build_wheel.yml for a tested matrix of working combinations
# 32-bit linux
- os: ubuntu-20.04
system_type: ["manylinux", "2010"]
arch: i686
py_minors: 7,8,9
- os: ubuntu-20.04
system_type: ["manylinux", "2014"]
arch: i686
py_minors: 7,8,9,10,11,12
- os: ubuntu-20.04
system_type: ["musllinux", "_1_1"]
arch: i686
py_minors: 7,8,9,10,11
# 64-bit linux
- os: ubuntu-20.04
system_type: ["manylinux", "2010"]
arch: x86_64
py_minors: 7,8,9
- os: ubuntu-20.04
system_type: ["manylinux", "2014"]
arch: x86_64
py_minors: 7,8,9,10,11,12
- os: ubuntu-20.04
system_type: ["manylinux", "_2_28"]
arch: x86_64
py_minors: 7,8,9,10,11,12
- os: ubuntu-20.04
system_type: ["musllinux", "_1_1"]
arch: x86_64
py_minors: 7,8,9,10,11
# 32-bit Windows
# 64-bit Windows
- os: windows-2019
system_type: ["win", ""]
arch: amd64
py_minors: '7'
- os: windows-2019
system_type: ["win", ""]
arch: amd64
py_minors: '8'
- os: windows-2019
system_type: ["win", ""]
arch: amd64
py_minors: '9'
- os: windows-2019
system_type: ["win", ""]
arch: amd64
py_minors: '10'
- os: windows-2019
system_type: ["win", ""]
arch: amd64
py_minors: '11'
- os: windows-2019
system_type: ["win", ""]
arch: amd64
py_minors: '12'
steps:
- name: Checkout repository
uses: actions/checkout@v4
# This step is necessary because while this is done in the job above,
# this job runs with the original commit SHA and does not have this change.
# And to avoid checking out `master` (should someone push in-between all this),
# this seems like the most low-tech solution (instead of caching/using artifacts):
# Change the version in CMakeList.txt and build wheels
- name: Update version
run: sed -i -E -e "s|^ +VERSION +[0-9.]+$| VERSION ${GITHUB_REF#refs/tags/v}|" CMakeLists.txt
shell: bash # Enforce bash shell to make `sed` work also on Windows
- name: Set up Python 3
uses: actions/setup-python@v5
with:
python-version: "3.${{ contains(matrix.py_minors, ',') && 'x' || matrix.py_minors }}"
architecture: ${{ matrix.arch == '' && 'x86' || 'x64' }}
- name: Login to GitHub Container Registry
if: startsWith(matrix.os, 'ubuntu')
uses: docker/login-action@v3
with:
registry: ${{ env.CONTAINER_REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Install cibuildwheel
run: |
python -m pip install -U pip
python -m pip install -U setuptools wheel
python -m pip install -U cibuildwheel
# See pyproject.toml (under python/) for cibuildwheel configuration
- name: Build wheels
run: |
python -m cibuildwheel --print-build-identifiers python
python -m cibuildwheel --output-dir wheelhouse python
env:
CIBW_BUILD: cp3${{ contains(matrix.py_minors, ',') && format('{{{0}}}', matrix.py_minors) || matrix.py_minors }}-${{ matrix.system_type[0] }}${{ matrix.arch != '' && '_' || '' }}${{ matrix.arch }}
CIBW_MANYLINUX_X86_64_IMAGE: ${{ env.CONTAINER_REGISTRY }}/sintef/dlite-python-manylinux${{ matrix.system_type[1] }}_x86_64:latest
CIBW_MANYLINUX_I686_IMAGE: ${{ env.CONTAINER_REGISTRY }}/sintef/dlite-python-manylinux${{ matrix.system_type[1] }}_i686:latest
CIBW_MUSLLINUX_X86_64_IMAGE: ${{ env.CONTAINER_REGISTRY }}/sintef/dlite-python-musllinux${{ matrix.system_type[1] }}_x86_64:latest
CIBW_MUSLLINUX_I686_IMAGE: ${{ env.CONTAINER_REGISTRY }}/sintef/dlite-python-musllinux${{ matrix.system_type[1] }}_i686:latest
- name: Store wheels for publishing
uses: actions/upload-artifact@v4
with:
name: wheels_${{ matrix.os }}_${{ matrix.system_type[0] }}_${{ matrix.system_type[1] }}_${{ matrix.arch }}_${{ matrix.py_minors }}
path: wheelhouse/*.whl
build_sdist:
name: Build sdist
runs-on: ubuntu-latest
if: github.repository == 'SINTEF/dlite' && startsWith(github.ref, 'refs/tags/v')
steps:
- name: Checkout repository
uses: actions/checkout@v4
# This step is necessary because while this is done in the job above,
# this job runs with the original commit SHA and does not have this change.
# And to avoid checking out `master` (should someone push in-between all this),
# this seems like the most low-tech solution (instead of caching/using artifacts):
# Change the version in CMakeList.txt and build wheels
- name: Update version
run: sed -i -E -e "s|^ +VERSION +[0-9.]+$| VERSION ${GITHUB_REF#refs/tags/v}|" CMakeLists.txt
- name: Set up Python 3.9
uses: actions/setup-python@v5
with:
python-version: "3.9"
- name: Install Python dependencies
run: |
python -m pip install -U pip
pip install -U setuptools wheel
# Build package/tool
pip install -U build
# Build requirements
pip install -U oldest-supported-numpy cmake
- name: Build source distribution
run: python -m build --no-isolation --sdist python
- name: Store sdist for publishing
uses: actions/upload-artifact@v4
with:
# Note that they are moved to a common directory sdist_____ (5 underscores, as in the name below)
name: sdist_${{ matrix.os }}_${{ matrix.system_type[0] }}_${{ matrix.system_type[1] }}_${{ matrix.arch }}_${{ matrix.py_minors }}
path: python/dist/*
publish:
needs: [cd_build_wheels,build_sdist]
name: Publish DLite distributions
runs-on: ubuntu-latest
steps:
- name: Retrieve wheels and sdist
uses: actions/download-artifact@v4
with:
path: dist
- name: Move sdist files to dist/m wheel files already there
run: |
ls -lah dist
mv dist/sdist_____/* dist/
rm -rf dist/sdist_____
ls -lah dist
# - name: Publish package to Test PyPI
# uses: pypa/gh-action-pypi-publish@release/v1
# with:
# user: __token__
# password: ${{ secrets.TEST_PYPI_TOKEN }}
# repository-url: https://test.pypi.org/legacy/
- name: Publish package to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_TOKEN }}