-
Notifications
You must be signed in to change notification settings - Fork 1
303 lines (261 loc) · 9.86 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
---
# This workflow automates the creation of GitHub and PyPI releases.
# It builds Python packages for multiple OS and architecture combinations,
# generates release notes by using commitizen Espressif plugin,
# uploads artifacts to GitHub Releases, and publishes the release to PyPI.
name: 📦 Create Release GitHub and PyPI
on:
workflow_dispatch:
inputs: {version: {description: 'Release version (e.g., v1.3.0)', required: true}}
push: {tags: ['*v[0-9]*']}
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
build-python:
permissions:
contents: write
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.x'
cache: pip
- name: Set build environment
run: |-
python -m venv venv
source venv/bin/activate
pip install --require-virtualenv --upgrade pip
pip install --require-virtualenv build
- name: Build a binary wheel and a source tarball
run: |
source venv/bin/activate
python3 -m build
ls -la dist/
- name: Store the distribution packages
uses: actions/upload-artifact@v4
with:
name: release-assets
path: dist/*
test-builds-linux:
needs: [build-python]
permissions:
contents: read
strategy:
fail-fast: true
matrix:
python-version: ['3.9', '3.10', '3.11', '3.12']
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 1 # shallow
- name: Download all builds
uses: actions/download-artifact@v4
with:
path: ./release-assets
- uses: getsentry/[email protected]
id: venv
with:
python-version: ${{ matrix.python-version }}
cache-dependency-path: dist/*.whl
install-cmd: pip install --require-virtualenv $(find release-assets -name "*.whl")
- name: Install plugin from wheel
run: |
for whl in $(find release-assets -name "*.whl"); do
python -m pip install --require-virtualenv "$whl" || echo "Failed to install $whl"
done
- name: Add pyproject.toml with set plugin
run: |
echo "[tool.commitizen]" > pyproject.toml
echo " name = 'czespressif'" >> pyproject.toml
- name: Test plugin functions
run: |
cz info | grep -q "Commitizen plugin for Espressif Systems" || exit 1
cz example | grep -q "github.com/espressif" || exit 1
test-builds-macos:
needs: [build-python]
permissions:
contents: read
strategy:
fail-fast: true
matrix:
python-version: ['3.9', '3.10', '3.11', '3.12']
os: [macos-12, macos-14] # macOS 12 (Intel),macOS 14 (Apple Silicon)
runs-on: ${{ matrix.os }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 1 # shallow
- name: Download all builds
uses: actions/download-artifact@v4
with:
path: ./release-assets
- uses: getsentry/[email protected]
id: venv
with:
python-version: ${{ matrix.python-version }}
cache-dependency-path: dist/*.whl
install-cmd: pip install --require-virtualenv $(find release-assets -name "*.whl")
- name: Install plugin from wheel
run: |
for whl in $(find release-assets -name "*.whl"); do
python -m pip install --require-virtualenv "$whl" || echo "Failed to install $whl"
done
- name: Add pyproject.toml with set plugin
run: |
echo "[tool.commitizen]" > pyproject.toml
echo " name = 'czespressif'" >> pyproject.toml
- name: Test plugin functions
run: |
cz info | grep -q "Commitizen plugin for Espressif Systems" || exit 1
cz example | grep -q "github.com/espressif" || exit 1
test-builds-windows:
needs: [build-python]
permissions:
contents: read
strategy:
fail-fast: true
matrix:
python-version: ['3.9', '3.10', '3.11', '3.12']
runs-on: windows-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Download all builds
uses: actions/download-artifact@v4
with:
path: ./release-assets
- name: Set up Python to install this project
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: pip
- name: Create virtual env
shell: pwsh
run: |
python -m venv venv-pwsh
.\venv-pwsh\Scripts\Activate.ps1
python -m pip install --require-virtualenv --upgrade pip
- name: Install plugin from wheel
shell: pwsh
run: |
.\venv-pwsh\Scripts\Activate.ps1
Get-ChildItem -Path "release-assets" -Recurse -Filter "*.whl" | ForEach-Object { try { python -m pip install --require-virtualenv $_.FullName } catch { Write-Host "Failed to install $($_.FullName)" } }
- name: Add pyproject.toml with set plugin
shell: pwsh
run: |
.\venv-pwsh\Scripts\Activate.ps1
"[tool.commitizen]`r`n name = 'czespressif'" | Set-Content -Path "pyproject.toml"
- name: Test plugin functions
shell: pwsh
run: |
.\venv-pwsh\Scripts\Activate.ps1
cz info | Select-String -Quiet "Commitizen plugin for Espressif Systems" || exit 1
cz example | Select-String -Quiet "github.com/espressif" || exit 1
create-github-release:
needs: [test-builds-linux, test-builds-macos, test-builds-windows]
permissions:
contents: write
id-token: write # IMPORTANT: mandatory for sigstore
runs-on: ubuntu-latest
steps:
- name: Checkout repository (full history)
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Download all builds
uses: actions/download-artifact@v4
- name: Get project release version
id: release_version
run: |
if [ -n "${{ github.event.inputs.version }}" ]; then
VERSION="${{ github.event.inputs.version }}"
else
VERSION=$(git describe --tags --abbrev=0)
fi
echo "Release version: $VERSION"
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
- name: Set up Python to install this project
uses: actions/setup-python@v5
with:
python-version: '3.9' # Minimum supported version by this project
cache: pip
- name: Install project
run: |-
python -m venv venv
source venv/bin/activate
pip install --require-virtualenv --upgrade pip
pip install --require-virtualenv .
- name: Create Release notes
run: |
source venv/bin/activate
cz changelog ${{ steps.release_version.outputs.VERSION }} --file-name RELEASE_NOTES.md
- name: Sign the dists with Sigstore
uses: sigstore/[email protected]
with:
inputs: >-
./release-assets/*.tar.gz
./release-assets/*.whl
upload-signing-artifacts: true
release-signing-artifacts: true
- name: List release assets
run: ls -la release-assets
- name: Check all assets ready (or fail here)
run: |
set -e
echo "Check version: ${{ steps.release_version.outputs.VERSION }}"
echo "Check version fits version pattern:; [[ "${{ steps.release_version.outputs.VERSION }}" =~ ^v?[0-9]+\.[0-9]+\.[0-9]+(\.[a-z0-9]+)?$ ]]"
echo "Check release notes file:"; cat RELEASE_NOTES.md
echo "Check python builds:"; ls -la release-assets/*.{whl,tar.gz}
echo "Check source code archive integrity:"; tar -tzf $(ls release-assets/*.tar.gz)
- name: Create GitHub release (and upload assets)
id: create_release
uses: softprops/action-gh-release@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
body_path: RELEASE_NOTES.md
name: ${{ steps.release_version.outputs.VERSION }}
tag_name: ${{ steps.release_version.outputs.VERSION }} # expects a tag with the same name as version
draft: false
prerelease: false
make_latest: true
files: |
release-assets/**
create-pypi-release:
needs: [test-builds-linux, test-builds-macos, test-builds-windows]
permissions:
contents: write
id-token: write # For trusted publishing and sigstore
runs-on: ubuntu-latest
steps:
- name: Checkout repository (need README.md used as long_description for PyPI)
uses: actions/checkout@v4
- name: Download all builds and merge
uses: actions/download-artifact@v4
- name: Check all assets ready (or fail here)
run: |
set -e
echo "Check python builds:"; ls -la release-assets/*.{whl,tar.gz}
echo "Check source code archive integrity:"; tar -tzf $(ls release-assets/*.tar.gz)
- name: Publish to TestPyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/
packages-dir: release-assets/
verify-metadata: true # 'twine check' before upload
skip-existing: true
# Trusted publisher TestPyPI: espressif/cz-plugin-espressif/create-release.yml
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: release-assets/
verify-metadata: true # 'twine check' before upload
skip-existing: true
# Trusted publisher PyPI: espressif/cz-plugin-espressif/create-release.yml