-
-
Notifications
You must be signed in to change notification settings - Fork 30
340 lines (294 loc) · 11.3 KB
/
create-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
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
on:
push:
# Sequence of patterns matched against refs/tags
tags:
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10
workflow_run:
workflows: [ "Vendor Update" ]
types:
- completed
#release:
# types: ['published']
name: Create Release
jobs:
version_check:
name: Check Version
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-python@v4
with:
python-version: '3.12'
- name: Install and Setup
run: |
python -m pip install -U pip setuptools wheel
- name: Get Version
id: get_version
run: |
set -ex
python -m pip install -e .
echo "PCAPKIT_VERSION=$(python -c 'import pcapkit; print(pcapkit.__version__)')" >> $GITHUB_OUTPUT
echo "PCAPKIT_PRERELEASE=$(python -c 'import pcapkit, pkg_resources; print(str(pkg_resources.parse_version(pcapkit.__version__).is_prerelease).lower())')" >> $GITHUB_OUTPUT
echo "PCAPKIT_CONDA_LABEL=$(python -c 'import pcapkit, pkg_resources; print("dev" if pkg_resources.parse_version(pcapkit.__version__).is_prerelease else "main")')" >> $GITHUB_OUTPUT
- uses: mukunku/[email protected]
id: check_tag
with:
tag: "v${{ steps.get_version.outputs.PCAPKIT_VERSION }}"
outputs:
PCAPKIT_VERSION: ${{ steps.get_version.outputs.PCAPKIT_VERSION }}
PCAPKIT_PRERELEASE: ${{ steps.get_version.outputs.PCAPKIT_PRERELEASE }}
PCAPKIT_TAG_EXISTS: ${{ steps.check_tag.outputs.exists }}
PCAPKIT_CONDA_LABEL: ${{ steps.get_version.outputs.PCAPKIT_CONDA_LABEL }}
github:
name: GitHub Release
runs-on: ubuntu-latest
needs: [ version_check ]
if: ${{ startsWith(github.ref_name, 'v') || needs.version_check.outputs.PCAPKIT_TAG_EXISTS == 'false' }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
# ref: v${{ needs.version_check.outputs.PCAPKIT_VERSION }}
fetch-depth: 0
- name: Changelog
uses: Bullrich/generate-release-changelog@master
id: changelog
env:
REPO: ${{ github.repository }}
- name: Create Release
id: create_release
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
with:
# allowUpdates: true
# artifacts: |
# dist/*
# body: ${{ env.PCAPKIT_CHANGELOG }}
body: |
${{ steps.changelog.outputs.changelog }}
# generateReleaseNotes: true
# makeLatest: true
name: PyPCAPKit v${{ needs.version_check.outputs.PCAPKIT_VERSION }}
prerelease: ${{ needs.version_check.outputs.PCAPKIT_PRERELEASE }}
tag_name: "v${{ needs.version_check.outputs.PCAPKIT_VERSION }}"
token: "${{ secrets.GITHUB_TOKEN }}"
tag:
name: Conda Tag
runs-on: ubuntu-latest
needs: [ version_check ]
if: ${{ startsWith(github.ref_name, 'v') || needs.version_check.outputs.PCAPKIT_TAG_EXISTS == 'false' }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
token: ${{ secrets.PYPCAPKIT }}
# ref: v${{ needs.version_check.outputs.PCAPKIT_VERSION }}
fetch-depth: 0
- name: Reset Build Number
run: |
set -x
printf 0 > conda/build
- name: Commit Changes
run: |
set -x
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git add conda/build
git commit -m"Reset conda build number" || true
- name: Push Changes
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.PYPCAPKIT }}
- name: Create Tag
run: |
set -x
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git tag -d v${{ needs.version_check.outputs.PCAPKIT_VERSION }} || true
git tag "conda-${{ needs.version_check.outputs.PCAPKIT_VERSION }}+0" -m"Conda Build"
- name: Push Tag
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.PYPCAPKIT }}
atomic: false
tags: true
pypi:
name: PyPI distribution for Python ${{ matrix.python-version }}
runs-on: ubuntu-latest
## Specifying a GitHub environment is optional, but strongly encouraged
#environment: release
#permissions:
# # IMPORTANT: this permission is mandatory for trusted publishing
# id-token: write
permissions:
contents: write
id-token: write
needs: [ github, version_check ]
if: ${{ startsWith(github.ref_name, 'v') || needs.version_check.outputs.PCAPKIT_TAG_EXISTS == 'false' }}
strategy:
matrix:
python-version:
- "3.8"
- "3.9"
- "3.10"
- "3.11"
- "3.12"
- "pypy3.8"
- "pypy3.9"
- "pypy3.10"
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: v${{ needs.version_check.outputs.PCAPKIT_VERSION }}
fetch-depth: 0
- uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install and Setup
run: |
set -x
python -m pip install -U pip setuptools wheel
python -m pip install -U build
- name: Build Package
env:
PCAPKIT_VERSION: ${{ needs.version_check.outputs.PCAPKIT_VERSION }}
run: |
python -m build
# rename wheel's python tag
python util/wheel_rename.py dist/*.whl
- name: No Source Distribution for Python ${{ matrix.python-version }}
if: ${{ matrix.python-version != '3.11' }}
run: |
rm dist/*.tar.gz
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
# password: ${{ secrets.PYPI_API_TOKEN }}
skip-existing: true
- name: Publish package to TestPyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
# password: ${{ secrets.TEST_PYPI_API_TOKEN }}
repository-url: https://test.pypi.org/legacy/
skip-existing: true
- name: Upload package to GitHub Release
uses: softprops/action-gh-release@v1
with:
# allowUpdates: true
files: |
dist/*
tag_name: "v${{ needs.version_check.outputs.PCAPKIT_VERSION }}"
token: "${{ secrets.GITHUB_TOKEN }}"
conda:
name: Conda deployment of package for platform ${{ matrix.os }} with Python ${{ matrix.python-version }}
runs-on: ${{ matrix.os }}
needs: [ tag, github, version_check ]
if: ${{ startsWith(github.ref_name, 'v') || needs.version_check.outputs.PCAPKIT_TAG_EXISTS == 'false' }}
strategy:
matrix:
os:
- macos-latest
- ubuntu-latest
# - windows-latest # skip for now
python-version:
- "3.8"
- "3.9"
- "3.10"
- "3.11"
- "3.12"
steps:
- uses: actions/checkout@v4
with:
ref: conda-${{ needs.version_check.outputs.PCAPKIT_VERSION }}+0
fetch-depth: 0
- uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install and Setup
if: ${{ matrix.os != 'windows-latest' }}
run: |
set -x
python -m pip install -U pip setuptools wheel
python -m pip install -e .[all]
python -m pip install pathlib2 typing_extensions
- name: Install and Setup (Windows)
if: ${{ matrix.os == 'windows-latest' }}
run: |
python -m pip install -U pip setuptools wheel
python -m pip install -e .[all]
python -m pip install pathlib2 typing_extensions
- name: Setup Conda Distribution
if: ${{ matrix.os != 'windows-latest' }}
run: |
set -x
mkdir -p conda/wheels
python -m pip download -r conda/requirements.txt -d conda/wheels
- name: Setup Conda Distribution (Windows)
if: ${{ matrix.os == 'windows-latest' }}
run: |
mkdir -p conda/wheels
python -m pip download -r conda/requirements.txt -d conda/wheels
- name: Conda environment creation and activation
uses: conda-incubator/setup-miniconda@v3
env:
PCAPKIT_VERSION: ${{ needs.version_check.outputs.PCAPKIT_VERSION }}
PCAPKIT_BUILD: "0"
with:
python-version: ${{ matrix.python-version }}
environment-file: conda/conda-build.yaml # Path to the build conda environment
auto-update-conda: false
auto-activate-base: false
show-channel-urls: true
- name: Build and upload the conda packages (macOS)
uses: uibcdf/[email protected]
if: ${{ matrix.os == 'macos-latest' }}
env:
PCAPKIT_VERSION: ${{ needs.version_check.outputs.PCAPKIT_VERSION }}
PCAPKIT_BUILD: "0"
with:
meta_yaml_dir: conda/pypcapkit
python-version: ${{ matrix.python-version }} # Values previously defined in `matrix`
platform_osx-64: true
user: jarryshaw
label: ${{ needs.version_check.outputs.PCAPKIT_CONDA_LABEL }}
token: ${{ secrets.ANACONDA_TOKEN }} # Replace with the right name of your secret
- name: Build and upload the conda packages (Ubuntu)
uses: uibcdf/[email protected]
if: ${{ matrix.os == 'ubuntu-latest' }}
env:
PCAPKIT_VERSION: ${{ needs.version_check.outputs.PCAPKIT_VERSION }}
PCAPKIT_BUILD: "0"
with:
meta_yaml_dir: conda/pypcapkit
python-version: ${{ matrix.python-version }} # Values previously defined in `matrix`
platform_linux-64: true
user: jarryshaw
label: ${{ needs.version_check.outputs.PCAPKIT_CONDA_LABEL }}
token: ${{ secrets.ANACONDA_TOKEN }} # Replace with the right name of your secret
- name: Build and upload the conda packages (Windows)
uses: uibcdf/[email protected]
if: ${{ matrix.os == 'windows-latest' }}
env:
PCAPKIT_VERSION: ${{ needs.version_check.outputs.PCAPKIT_VERSION }}
PCAPKIT_BUILD: "0"
with:
meta_yaml_dir: conda/pypcapkit
python-version: ${{ matrix.python-version }} # Values previously defined in `matrix`
platform_win-64: true
user: jarryshaw
label: ${{ needs.version_check.outputs.PCAPKIT_CONDA_LABEL }}
token: ${{ secrets.ANACONDA_TOKEN }} # Replace with the right name of your secret
- name: Upload package to GitHub Release
if: ${{ matrix.os == 'ubuntu-latest' }}
uses: softprops/action-gh-release@v1
with:
# allowUpdates: true
files: |
/tmp/compilation-*/**/*.tar.bz2
tag_name: "v${{ needs.version_check.outputs.PCAPKIT_VERSION }}"
token: "${{ secrets.GITHUB_TOKEN }}"